tune2fs 命令


【NAME】

     tune2fs-adjust tunable filesystem parameters on ext2/ext3/ext4 filesystems

     调整ext2/ext3/ext4文件系统参数

【SYNOPSIS】

     tune2fs [OPTIONS] device

【OPTIONS】

     -l:查看超级块的内容;

修改指定文件系统的属性:

     -j:ext2 --> ext3,将ext2升级为ext3;

     -L LABEL:修改卷标;

     -m #:调整预留空间百分比;

     -O [^]FEATHER:开启或关闭某种特性;

     -o [^]mount_options:开启或关闭某种默认挂载选项

          acl

          ^acl

【EXAMPLES】

示例:tune2fs -l参数,查看磁盘属性

[root@Centos6.8-180 ~]# tune2fs -l /dev/sda3   tune2fs 1.41.12 (17-May-2010)Filesystem volume name:   MYDATA   #卷标Last mounted on:          <not available>Filesystem UUID:          98873684-812d-40ae-86ad-5065e17d205bFilesystem magic number:  0xEF53   Filesystem revision #:    1 (dynamic)   Filesystem features:      has_journal ext_attr resize_inode dir_index filetype sparse_super large_file  #表示已启用特性Filesystem flags:         signed_directory_hash   #标志Default mount options:    (none)      #默认的挂载选项Filesystem state:         clean       #文件系统状态Errors behavior:          Continue    Filesystem OS type:       LinuxInode count:              655360Block count:              2620699Reserved block count:     131034     #预留块数量Free blocks:              2541003    #空闲块数量Free inodes:              655349     #空闲inode数量First block:              0          #第一个块从几号开始编号Block size:               4096       #块大小Fragment size:            4096       #片段大小Reserved GDT blocks:      639        #预留给GDT块数量Blocks per group:         32768      #第组多少块Fragments per group:      32768      #第组多少个片断Inodes per group:         8192       #每组多少indoeInode blocks per group:   512        #每组多少块Filesystem created:       Tue Dec  6 07:06:14 2016Last mount time:          n/aLast write time:          Tue Dec  6 07:26:38 2016Mount count:              0Maximum mount count:      26Last checked:             Tue Dec  6 07:06:14 2016Check interval:           15552000 (6 months)Next check after:         Sun Jun  4 07:06:14 2017Reserved blocks uid:      0 (user root)Reserved blocks gid:      0 (group root)First inode:              11Inode size:	          256Required extra isize:     28Desired extra isize:      28Journal inode:            8Default directory hash:   half_md4Directory Hash Seed:      784da73d-a979-465d-ae10-5093a3cc0420Journal backup:           inode blocks

示例:-O参数,开启或关闭文件系统某种特性;

 
  
  1. [root@Centos6.8-180 ~]# tune2fs -O has_journal /dev/sda3   #开启has_journal特性

  2. tune2fs 1.41.12 (17-May-2010)

  3. Creating journal inode: 完成

  4. This filesystem will be automatically checked every 26 mounts or

  5. 180 days, whichever comes first.  Use tune2fs -c or -i to override.

  6. [root@Centos6.8-180 ~]# tune2fs -l /dev/sda3 | grep "features"

  7. Filesystem features:      has_journal ext_attr resize_inode dir_index filetype sparse_super large_file

  8. [root@Centos6.8-180 ~]# blkid /dev/sda3

    /dev/sda3: LABEL="MYDATA" UUID="98873684-812d-40ae-86ad-5065e17d205b" SEC_TYPE="ext2" TYPE="ext3"

  9. [root@Centos6.8-180 ~]# tune2fs -O ^has_journal /dev/sda3   #关闭has_journal特性

  10. tune2fs 1.41.12 (17-May-2010)

  11. [root@Centos6.8-180 ~]# tune2fs -l /dev/sda3 | grep "features"

  12. Filesystem features:      ext_attr resize_inode dir_index filetype sparse_super large_file  

  13. #查看并没有has_journal特性了;

  14. [root@Centos6.8-180 ~]# blkid /dev/sda3 /dev/sda3: LABEL="MYDATA" UUID="98873684-812d-40ae-86ad-5065e17d205b" TYPE="ext2"

示例:-j参数,将ext2升级为ext3;

[root@Centos6.8-180 ~]# blkid /dev/sda3/dev/sda3: LABEL="MYDATA" UUID="98873684-812d-40ae-86ad-5065e17d205b" TYPE="ext2" [root@Centos6.8-180 ~]# tune2fs -j /dev/sda3tune2fs 1.41.12 (17-May-2010)Creating journal inode: 完成This filesystem will be automatically checked every 26 mounts or180 days, whichever comes first.  Use tune2fs -c or -i to override.[root@Centos6.8-180 ~]# blkid /dev/sda3/dev/sda3: LABEL="MYDATA" UUID="98873684-812d-40ae-86ad-5065e17d205b" SEC_TYPE="ext2" TYPE="ext3"

示例:-m,设置预留块大小;

[root@Centos6.8-180 ~]# tune2fs -m 2 /dev/sda3tune2fs 1.41.12 (17-May-2010)Setting reserved blocks percentage to 2% (52413 blocks)[root@Centos6.8-180 ~]# tune2fs -l /dev/sda3 | grep "Reserved block count"Reserved block count:     52413

示例:-o,开启某种挂载选项

[root@Centos6.8-180 ~]# tune2fs -o acl /dev/sda3   #启用acltune2fs 1.41.12 (17-May-2010)[root@Centos6.8-180 ~]# tune2fs -l /dev/sda3 | grep "Default mount options"Default mount options:    acl   #已经开启[root@Centos6.8-180 ~]# tune2fs -o ^acl /dev/sda3   #关闭acltune2fs 1.41.12 (17-May-2010)[root@Centos6.8-180 ~]# tune2fs -l /dev/sda3 | grep "Default mount options"Default mount options:    (none)   #已经关闭