[20180806]tune2fs调整保留块百分比.txt

在Linux下让大家选取tune2fs来查看和硬盘有关的参数吧,只怕那里有您所需的音讯:

linux中inode是个什么概念吗?简单来说inode是三个不可能再度的标号一样,每个文件或目录对应3个inode值,这几个inode包罗如何部分,有何效果吗?那里拿ext3文件系统的inode数据结构来说:
struct ext3_inode {
tune2fs调整保留块百分比,Linux下使用tune2fs命令来查看硬盘相关音信。 __u16 i_mode;    /* File mode */
 __u16 i_uid;     /* Low 16 bits of Owner Uid */
 __u32 i_size;    /* 文件大小,单位是 byte */
 __u32 i_atime;   /* Access time 访问时间*/
 __u32 i_ctime;   /* Creation time 创立时间*/
 __u32 i_mtime;   /* Modification time 修改时间*/
 __u32 i_dtime;   /* Deletion Time 删除时间*/
 __u16 i_gid;     /* Low 16 bits of Group Id *澳门金沙国际 ,/
 __u16 i_links_count;          /* Links count */
 __u32 i_blocks;               /* blocks 计数 */
 __u32 i_flags;                /* File flags */
 __u32 l_i_reserved1;          /* 能够忽略 */
 __u32 i_block[EXT3_N_BLOCKS]; /* 一组 block 指针
,指向数据文件在磁盘上的指针*/
 __u32 i_generation;           /* 可以忽略 */
 __u32 i_file_acl;             /* 可以忽略 */
 __u32 i_dir_acl;              /* 能够忽略 */
 __u32 i_faddr;                /* 能够忽略 */
 __u8  l_i_frag;               /* 能够忽略 */
 __u8  l_i_fsize;              /* 能够忽略 */
 __u16 i_pad1;                 /* 可以忽略 */
 __u16 l_i_uid_high;           /* 能够忽略 */
 __u16 l_i_gid_high;           /* 能够忽略 */
 __u32 l_i_reserved2;          /* 能够忽略 */
};
事先在(浅析ext3刨除文件慢的缘故
http://www.linuxidc.com/Linux/2012-05/59492.htm)也差不多研讨过它。

blockdev命令  blkid命令  lsblk命令

–//生产系统一台dg磁盘空间满了.小编前一阵子已经将*convert参数修改,增添磁盘,不过这些分区里面包车型客车数据文件还足以增长,那样还是存
–//在磁盘空间不足的意况,符合规律应该移动数据文件到其他分区,然后rename.突然想起建立分区时有一定的保留区给root用户,大家以此分
–//区磁盘十分的大接近2T,那样依据5%的比例计算,有贴近100G的上空也许浪费了.

[root@localhost ~] ~# tune2fs -l /dev/sdc1
tune2fs 1.35 (28-Feb-2004)
Filesystem volume name: /data2
Last mounted on: <not available>
Filesystem UUID: cc571d4e-715d-43fa-802b-50e30a3ccb16
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal resize_inode filetype needs_recovery
sparse_super large_file
Default mount options: (none)
Filesystem state: clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 36634624
Block count: 73240327
Reserved block count: 3662016
Free blocks: 72066127
Free inodes: 36634613
First block: 0
Block size: 4096
Fragment size: 4096
Reserved GDT blocks: 1024
Blocks per group: 32768
Fragments per group: 32768
Inodes per group: 16384
Inode blocks per group: 512
Filesystem created: Sat Jun 21 06:38:52 2008
Last mount time: Sat Jun 21 06:41:59 2008
Last write time: Sat Jun 21 06:41:59 2008
Mount count: 1
Maximum mount count: 34
Last checked: Sat Jun 21 06:38:52 2008
Check interval: 15552000 (6 months)
Next check after: Thu Dec 18 06:38:52 2008
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
First inode: 11
Inode size: 128
Journal inode: 8
Default directory hash: tea
Directory Hash Seed: db692f72-bbb3-43d4-8011-1664854a8364
Journal backup: inode blocks
[root@localhost ~] ~# tune2fs -l /dev/sde1
tune2fs 1.35 (28-Feb-2004)
Filesystem volume name: /data3
Last mounted on: <not available>
Filesystem UUID: 68985487-0e63-4c7c-a5f6-e2f36da55d33
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal resize_inode filetype needs_recovery
sparse_super large_file
Default mount options: (none)
Filesystem state: clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 36634624
Block count: 73240327
Reserved block count: 3662016
Free blocks: 72066127
Free inodes: 36634613
First block: 0
Block size: 4096
Fragment size: 4096
Reserved GDT blocks: 1024
Blocks per group: 32768
Fragments per group: 32768
Inodes per group: 16384
Inode blocks per group: 512
Filesystem created: Sat Jun 21 06:40:24 2008
Last mount time: Sat Jun 21 06:41:59 2008
Last write time: Sat Jun 21 06:41:59 2008
Mount count: 1
Maximum mount count: 26
Last checked: Sat Jun 21 06:40:24 2008
Check interval: 15552000 (6 months)
Next check after: Thu Dec 18 06:40:24 2008
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
First inode: 11
Inode size: 128
Journal inode: 8
Default directory hash: tea
Directory Hash Seed: 17a1e87f-434b-468d-8048-9a35b66b227c
Journal backup: inode blocks
[root@localhost ~] ~#

因为inode首借使挤占磁盘空间的,那么明日就斟酌一下inode分配与占用磁盘难点,此前听人说xfs文件系统inode占用的磁盘空间达到了一对一多G,当然那是因为她的文件系统本来正是用来存放在小文件的,所以导致inode占用的长空也相当大。

–//参考在此以前测试的链接:
–//注意假诺在mount状态下修改无效!!

[ The End ]

在你为2个硬盘或是分区建好文件系统今后,文件系统已经明显了那块硬盘或是分区最终能有稍许inode被分配,这一个inode能占用多大的空间。查看二个硬盘或分区的文件系统音信,能够因此dumpe2fs
-h device_name 来查阅,比如作者的连串中贰个分区/dev/sda8 (ext3)
$ dumpe2fs -h /dev/sda8

block相关的下令

1.环境:
# cat /proc/version
Linux version 2.6.39-300.26.1.el5uek
(mockbuild@ca-build56.us.oracle.com) (gcc version 4.1.2 20080704 (Red
Hat 4.1.2-52)) #1 SMP Thu Jan 3 18:31:38 PST 2013

澳门金沙国际 1

dumpe2fs 1.41.12 (17-May-2010)
Filesystem volume name:   home
Last mounted on:          <not available>
Filesystem UUID:          78a58693-dc1a-43c0-9eaf-6c0807626c14
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal ext_attr resize_inode
dir_index filetype needs_recovery sparse_super large_file
Filesystem flags:         signed_directory_hash 
Default mount options:    (none)
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              16318464
Block count:              65241965
Reserved block count:     652419
Free blocks:              58319070
Free inodes:              16135620
First block:              0
Block size:               4096
Fragment size:            4096
Reserved GDT blocks:      1008
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         8192
Inode blocks per group:   512
Filesystem created:       Fri Oct 14 16:13:01 2011
Last mount time:          Wed Feb 29 16:29:51 2012
Last write time:          Wed Feb 29 16:29:51 2012
Mount count:              5
Maximum mount count:      -1
Last checked:             Fri Oct 14 16:13:01 2011
Check interval:           0 (<none>)
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
First inode:              11
Inode size:          256
Required extra isize:     28
Desired extra isize:      28
Journal inode:            8
First orphan inode:       8437776
Default directory hash:   half_md4
Directory Hash Seed:      0eddc0e6-7fa9-4226-8534-59b633b5e88b
Journal backup:           inode blocks
Journal features:         journal_incompat_revoke
日志大小:             128M
Journal length:           32768
Journal sequence:         0x006cea77
Journal start:          
 3735澳门金沙国际 2

 

# df -h /u02
Filesystem            Size  Used Avail Use% Mounted on
/dev/cciss/c0d1p1     1.7T  1.6T   20G  99% /u02
–//剩余20G.

那篇小说首要介绍了Linux blockdev命令设置文件预读大小介绍,blockdev
工具允许从命令行调用区块设备控制造进度序,本文就讲解了它的应用实例,要求的仇人能够参见下

# tune2fs -l /dev/cciss/c0d1p1
tune2fs 1.39 (29-May-2006)
Filesystem volume name:   /u02
Last mounted on:          <not available>
Filesystem UUID:          d9c0c411-25ea-4e21-b383-3ef446d2c064
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal resize_inode dir_index filetype
needs_recovery sparse_super large_file
Default mount options:    (none)
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              219774976
Block count:              439520246
Reserved block count:     21976012

在指令行调用配备的ioctl函数。在Linux系统中,就如对装备的第叁手操作唯有ioctl函数了。他经受的参数不是太多,而且都以逐一对应的。

Free blocks:              432573167  
Free inodes:              219774965  
First block:              0  
Block size:               4096

blockdev – 从命令行调用区块设备控制程序

Fragment size:            4096
Reserved GDT blocks:      919
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         16384
Inode blocks per group:   512
Filesystem created:       Thu Feb 23 09:42:17 2017
Last mount time:          Thu Feb 23 09:55:13 2017
Last write time:          Thu Feb 23 09:55:13 2017
Mount count:              3
Maximum mount count:      -1
Last checked:             Thu Feb 23 09:42:17 2017
Check interval:           0 (<none>)
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
First inode:              11
Inode size:               128
Journal inode:            8
Default directory hash:   tea
Directory Hash Seed:      6e38ec2b-9916-496f-a143-b9b22a7e1f09
Journal backup:           inode blocks

blockdev [options] commands devices

–//21976012*4096/1024/1024/1024 = 83.83183288574218750000,保留84G.
–//实际上-m 1也是浪费,笔者使用-r参数保留一定数额的块.
–//保留1G ,1024*1024*1024/4096 = 262144

blockdev 工具允许从命令行调用区块设备控制造进度序。

2.调整保留块百分比:
–//关闭数据库.
SYS@xxxxdg> shutdown immediate ;
Database closed.
Database dismounted.
ORACLE instance shut down.

–getra 读取预读值
–getfra 读取文件系统预读
–setfra FSREADAHEAD 设置文件系统预读
–setra READAHEAD 设置设备预读
–getra 读取设备的预读值
–setbsz BLOCKSIZE 在文件讲述符打开块设备的时候设置块大小
–getioopt 读取设备优化IO大小
–getiomin 读取设备最小IO大小
-–setro 设置设备为只读
-–getro 读取设备是或不是为只读(成功为1,0则为可读写)
-–setrw 设置设别为可读写
-–getss 打字与印刷设备的扇区大小也叫逻辑块大小,平日是512
–getpbsz 读取设备物理块大小,平时是4096
–getbsz 读取设备块大小,常常是4096
-–getsize(-getsz) 打字与印刷设备的容积,遵照七个扇区512个字节计算
–getsize64 打字与印刷设备的体积,以字节为单位出示
-–setra N 设置预读扇区(512字节)为N个.Set readahead to N 512-byte
sectors.
-–getra 打字与印刷readahead(预读扇区)
-–flushbufs 刷新缓冲
-–rereadpt 重读分区表。

# umount /dev/cciss/c0d1p1
umount: /u02: device is busy
umount: /u02: device is busy

觉得–setro,setrw比较有用,这么些mount -o
ro(rw)是有分别的,mount是在文件系统这么些级别上对某些分区挂载为只读或可读写。而blockdev则是在设别这一个级别上设置为只读和可读写。
看上面包车型客车一声令下输出结果就一目领悟了。

# lsof /u02
COMMAND  PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
tnslsnr 9361 oracle  cwd    DIR 104,17     4096    2 /u02
–//奇怪.监听过程怎么会涉嫌到/u02

 

# cat /proc/9361/environ  | tr ‘\0’ ‘\n’| grep u02
PWD=/u02

[root@lancy ~]# blockdev –setro /dev/hda4
[root@lancy ~]# blockdev –getro /dev/hda4
1
[root@lancy ~]# mount /dev/hda4 /misc -o rw
mount: block device /dev/hda4 is write-protected, mounting read-only
[root@lancy ~]# umount /dev/hda4
[root@lancy ~]# blockdev –setrw /dev/hda4
[root@lancy ~]# blockdev –getro /dev/hda4
0
[root@lancy ~]# mount /dev/hda4 /misc -o rw
[root@lancy ~]# touch /misc/one
[root@lancy ~]# umount /dev/hda4
[root@lancy ~]# mount /dev/hda4 /misc -o ro
[root@lancy ~]# rm -f /misc/one
rm: 不恐怕删除‘/misc/one’: 只读文件系统

–//原来当时监听运营时的目录是/u02,结束监听进程.
$ lsnrctl stop
LSNRCTL for Linux: Version 11.2.0.4.0 – Production on 06-AUG-2018
08:29:12
Copyright (c) 1991, 2013, Oracle.  All rights reserved.
Connecting to
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.100.76)(PORT=1521)))
The command completed successfully

 

# sync;sync
# umount /dev/cciss/c0d1p1
# tune2fs -r 262144 /dev/cciss/c0d1p1
tune2fs 1.39 (29-May-2006)
Setting reserved blocks count to 262144

刷新buffer

# tune2fs -l /dev/cciss/c0d1p1 | egrep “Reserved block count”
Reserved block count:     262144

free -m
total used free shared buffers cached
Mem: 15907 15665 242 0 158 4702
-/+ buffers/cache: 10803 5104
Swap: 7999 0 7999

# mount /u02
# df -h /u02
Filesystem            Size  Used Avail Use% Mounted on
/dev/cciss/c0d1p1     1.7T  1.6T  103G  94% /u02

# blockdev –flushbufs /dev/sda5
# free -m
total used free shared buffers cached
Mem: 15907 15536 371 0 31 4702
-/+ buffers/cache: 10802 5105
Swap: 7999 0 7999

–//以后多了83G,应该不会再遇上磁盘空间不足的题材在/u02分区.

 

3.起步数量库.略.
$ lsnrctl start


SYS@xxxxdg> startup open read only;
ORACLE instance started.

 

Total System Global Area 8.0973E+10 bytes
Fixed Size                  2261968 bytes
Variable Size            9663679536 bytes
Database Buffers         7.1135E+10 bytes
Redo Buffers              171487232 bytes
Database mounted.
Database opened.

tune2fs命令

DGMGRL> show database xxxxdg
Database – xxxxdg
  Enterprise Manager Name: xxxx_dg
  Role:                    PHYSICAL STANDBY
  Intended State:          APPLY-ON
  Transport Lag:           0 seconds (computed 0 seconds ago)
  Apply Lag:               0 seconds (computed 0 seconds ago)
  Apply Rate:              34.40 MByte/s
  Real Time Query:         ON
  Instance(s):
    xxxxdg
Database Status:
SUCCESS

翻看文件系统音讯

tune2fs -l /dev/sda5
tune2fs 1.41.12 (17-May-2010)
Filesystem volume name: <none>
Last mounted on: /data
Filesystem UUID: 35389d47-d4ed-406d-a8b8-2c7a69cfa4ce
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal ext_attr resize_inode dir_index
filetype needs_recovery extent flex_bg sparse_super large_file
huge_file uninit_bg dir_nlink extra_isize
Filesystem flags: signed_directory_hash
Default mount options: user_xattr acl
Filesystem state: clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 58589184
Block count: 234333952
Reserved block count: 11716697
Free blocks: 226871715
Free inodes: 58589166
First block: 0
Block size: 4096
Fragment size: 4096
Reserved GDT blocks: 968
Blocks per group: 32768
Fragments per group: 32768
Inodes per group: 8192
Inode blocks per group: 512
RAID stride: 1
Flex block group size: 16
Filesystem created: Tue Jul 26 16:18:18 2016
Last mount time: Wed Aug 3 08:42:19 2016
Last write time: Wed Aug 3 08:42:19 2016
Mount count: 8
Maximum mount count: -1
Last checked: Tue Jul 26 16:18:18 2016
Check interval: 0 (<none>)
Lifetime writes: 14 GB
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
First inode: 11
Inode size: 256
Required extra isize: 28
Desired extra isize: 28
Journal inode: 8
First orphan inode: 38666243
Default directory hash: half_md4
Directory Hash Seed: d4449666-888f-4552-aa4d-eccde1fda9e1
Journal backup: inode blocks


blkid命令

另1个和block有关的通令

blkid

blkid
/dev/vda1: UUID=”fb1d72cf-8058-40e6-8b25-58f9759e1cf9″ TYPE=”ext3″
/dev/vdb1: UUID=”0169c89a-fe36-4b3d-b0ef-0d11497aca9e” TYPE=”ext4″
/dev/vdc1: UUID=”2da0e026-dbd5-4c9c-9b0d-3574a3403b2b” TYPE=”swap”

 


 

 

lsblk命令

 

lsblk把持有磁盘和分区展现出来,uuid也能够彰显出来

 

lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 252:0 0 8G 0 disk
└─vda1 252:1 0 8G 0 part /
vdb 252:16 0 10G 0 disk
└─vdb1 252:17 0 9G 0 part /data
vdc 252:32 0 2G 0 disk
└─vdc1 252:33 0 2G 0 part [SWAP]

 

显示uuid

lsblk -f
NAME FSTYPE LABEL UUID MOUNTPOINT
vda
└─vda1 ext3 fb1d72cf-8058-40e6-8b25-58f9759e1cf9 /
vdb
└─vdb1 ext4 0169c89a-fe36-4b3d-b0ef-0d11497aca9e /data
vdc swap lswap 887348e5-e421-470a-b5e5-e6bed3619e3c
└─vdc1 swap 2da0e026-dbd5-4c9c-9b0d-3574a3403b2b [SWAP]

 

展现全部设备

lsblk -a
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 0 loop
loop1 7:1 0 0 loop
loop2 7:2 0 0 loop
loop3 7:3 0 0 loop
loop4 7:4 0 0 loop
loop5 7:5 0 0 loop
loop6 7:6 0 0 loop
loop7 7:7 0 0 loop
vda 252:0 0 8G 0 disk
└─vda1 252:1 0 8G 0 part /
vdb 252:16 0 10G 0 disk
└─vdb1 252:17 0 9G 0 part /data
vdc 252:32 0 2G 0 disk
└─vdc1 252:33 0 2G 0 part [SWAP]

 

f

相关文章