tune2fs简介:
tune2fs是调整和查看ext2/ext3文件系统的文件系统参数,Windows下面如果出现意外断电死机情况,下次开机一般都会出现系统自检。Linux系统下面也有文件系统自检,而且是可以通过tune2fs命令,自行定义自检周期及方式。
tune2fs用法:
tune2fs [ -l ] [ -c max-mount-counts ] [ -e errors-behavior ] [ -f ] [ -i interval-between-checks ] [ -j ] [ -J journal-options ] [ -m
reserved-blocks-percentage ] [ -o [^]mount-options[,...] ] [ -r reserved-blocks-count ] [ -s sparse-super-flag ] [ -u user ] [ -g
group ] [ -C mount-count ] [ -L volume-name ] [ -M last-mounted-directory ] [ -O [^]feature[,...] ] [ -T time-last-checked ] [ -U UUID ] device
常用选项说明:
-l 查看文件系统信息
-c max-mount-counts 设置强制自检的挂载次数,如果开启,每挂载一次mount conut就会加1,超过次数就会强制自检
-i interval-between-checks[d|m|w] 设置强制自检的时间间隔[d天m月w周]
-m reserved-blocks-percentage 保留块的百分比
-j 将ext2文件系统转换为ext3类型的文件系统
-L volume-label 类似e2label的功能,可以修改文件系统的标签
-r reserved-blocks-count 调整系统保留空间
-O [^]mount-option[,...] Set or clear the indicated default mount options in the filesystem. 设置或清除默认挂载的文件系统选项
tune2fs -c 30 /dev/hda1 设置强制检查前文件系统可以挂载的次数
tune2fs -c -l /dev/hda1 关闭强制检查挂载次数限制。
tune2fs -i 10 /dev/hda1 10天后检查
tune2fs -i 1d /dev/hda1 1天后检查
tune2fs -i 3w /dev/hda1 3周后检查
tune2fs -i 6m /dev/hda1 半年后检查
tune2fs -i 0 /dev/hda1 禁用时间检查
tune2fs -j /dev/hda1 添加日志功能,将ext2转换成ext3文件系统
tune2fs -r 40000 /dev/hda1 调整/dev/hda1分区的保留空间为40000个磁盘块
tune2fs -O acl,user_xattr /dev/hda1 设置/dev/hda1挂载选项,启用Posix Access Control Lists和用户指定的扩展属性
tune2fs -O ^dir_index /dev/hda1 卸载/dev/hda1的挂载选项
开机取消自检:
tune2fs -l /dev/sdb1 | grep -E ‘Maximum mount count:|Check interval’
tune2fs -i 0 -c 0 /dev/sdb1
一般文件都不是太小,最好用less来配合一下。格式:hexdump -C 文件名 | less
Last mounted on: /mnt/ram0 //文件系统挂载的目录Filesystem UUID: 22a7b0d1-06b5-485c-a5a1-3c4398a583d8Filesystem magic number: 0xEF53Filesystem revision #: 1 (dynamic)Filesystem features: has_journal ext_attr resize_inode dir_index filetype needs_recovery extent flex_bg sparse_super huge_file uninit_bg dir_nlink extra_isizeFilesystem flags: signed_directory_hashDefault mount options: user_xattr acl //预设挂载的参数Filesystem state: clean //文件系统的状态,表明文件系统没有问题Errors behavior: ContinueFilesystem OS type: LinuxInode count: 124928 //inode总数Block count: 498976 //block总数Reserved block count: 24948 //保留的block数目Free blocks: 472699 //可用的block数目Free inodes: 124916 //可用的inode数目First block: 1Block size: 1024 //block的大小Fragment size: 1024Reserved GDT blocks: 256Blocks per group: 8192 //每个group的blocks数量Fragments per group: 8192Inodes per group: 2048 //每个group的inodes数量Inode blocks per group: 256 //每个group的inode块数量:由inode size参数可知,inode大小为128bytes,2048个inodes,每个inode 128 bytes,2048*128=256KB。1个block的大小是1024bytes=1KB,所以用于存放inode的块就是256.Flex block group size: 16 //flex block group的大小,一个flex block group有16个groupsFilesystem created: Sun Oct 10 13:40:48 2010Last mount time: Thu Sep 4 18:31:05 2014Last write time: Thu Sep 4 18:31:05 2014Mount count: 3Maximum mount count: -1Last checked: Sun Oct 10 13:40:48 2010Check interval: 0 (<none>)Lifetime writes: 24 MBReserved blocks uid: 0 (user root)Reserved blocks gid: 0 (group root)First inode: 11Inode size: 128 //inode的大小:128byteJournal inode: 8Default directory hash: half_md4Directory Hash Seed: 2710df5a-4c10-4dd1-9793-0a02d7363e33Journal backup: inode blocksJournal features: journal_incompat_revokeJournal size: 8MJournal length: 8192Journal sequence: 0x00000008Journal start: 1
Group 0: (Blocks 1-8192) [ITABLE_ZEROED]Checksum 0x9737, unused inodes 2036Primary superblock at 1, Group descriptors at 2-3 //超级块信息在1号block,group描述在2~3号blockReserved GDT blocks at 4-259Block bitmap at 260 (+259), Inode bitmap at 276 (+275)Inode table at 292-547 (+291) //inode table占用的块3791 free blocks, 2036 free inodes, 2 directories, 2036 unused inodesFree blocks: 4402-8192Free inodes: 13-2048