Linux 磁盘自检设置
Linux磁盘自检可以通过自行设置自检时间间隔,自动对硬盘进行检测,第一时间监测硬盘的健康状况,提高硬盘可靠性。
不同的文件系统(xfs,reiserfs,ext4)都有自己的检测和修复工具,本文讲解ext4文件系统的磁盘自检设置方法。
1、检查指定硬盘的文件系统:
df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda2 xfs 32G 3.3G 29G 11% /
devtmpfs devtmpfs 7.8G 0 7.8G 0% /dev
tmpfs tmpfs 7.8G 0 7.8G 0% /dev/shm
tmpfs tmpfs 7.8G 17M 7.8G 1% /run
tmpfs tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup
/dev/sdb5 ext4 631G 297G 303G 50% /data
tmpfs tmpfs 1.6G 0 1.6G 0% /run/user/0
或者blkid /dev/sdb5
# blkid /dev/sdb5
/dev/sdb5: UUID="5e1f3504-8808-4ebb-82be-c318fcbd6d63" TYPE="ext4"
2、查看/etc/fstab确认挂载分区
3、查看相应硬盘的文件系统的自检时间
通过下面的命令可以显示ext文件系统相关参数:
tune2fs -l /dev/sdb5
tune2fs 1.42.9 (28-Dec-2013)
Filesystem volume name:
Last mounted on: /data
Filesystem UUID: 5e1f3504-8808-4ebb-82be-c318fcbd6d63
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: (none)
Filesystem state: clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 42000384
Block count: 167975624
Reserved block count: 8398781
Free blocks: 92897263
Free inodes: 42000355
First block: 0
Block size: 4096
Fragment size: 4096
Reserved GDT blocks: 983
Blocks per group: 32768
Fragments per group: 32768
Inodes per group: 8192
Inode blocks per group: 512
Flex block group size: 16
Filesystem created: Mon Aug 7 16:04:19 2017
Last mount time: Thu Nov 30 15:02:15 2017
Last write time: Thu Nov 30 15:02:15 2017
Mount count: 12
Maximum mount count: 39
Last checked: Mon Aug 7 16:04:19 2017
Check interval: 15552000 (6 months)
Next check after: Sat Feb 3 16:04:19 2018
Lifetime writes: 10 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
Default directory hash: half_md4
Directory Hash Seed: 17716f76-ff63-402e-9ecd-00b0e400f6f0
Journal backup: inode blocks
或者
tune2fs -l /dev/sdb5 | grep 'Check interval'
4.修改Check interval自检间隔时间
Check interval指的是文件系统间隔多长时间进行一次完整性检查,您可以根据您的需要通过下面的命令手工指定:
tune2fs –i 30/dev/sdb5
其默认的单位是天,其他可用的单位有12m(12个月),7w(7周)