最後更新: 2015-04-24
介紹
fsck
- -y option will cause the fs-specific fsck to always attempt to fix any detected filesystem corruption automatically. ( 一定要小心用, 可能會出事架 @@!!)
tune2fs
- -l
- List the contents of the filesystem superblock
tune2fs 1.41.12 (17-May-2010) Filesystem volume name: <none> Last mounted on: / Filesystem UUID: 9ae9f254-1a5c-455f-975f-90628cc88386 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: 1281120 Block count: 5120000 Reserved block count: 256000 Free blocks: 1953546 Free inodes: 1107416 First block: 0 Block size: 4096 Fragment size: 4096 Reserved GDT blocks: 1022 Blocks per group: 32768 Fragments per group: 32768 Inodes per group: 8160 Inode blocks per group: 510 Flex block group size: 16 Filesystem created: Tue Feb 18 23:31:05 2014 Last mount time: Wed Feb 19 12:38:06 2014 Last write time: Wed Feb 19 11:18:40 2014 Mount count: 10 Maximum mount count: 28 Last checked: Tue Feb 18 23:31:05 2014 Check interval: 15552000 (6 months) Next check after: Sun Aug 17 23:31:05 2014 Lifetime writes: 533 MB 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: 661608 Default directory hash: half_md4 Directory Hash Seed: f1e66d6f-6636-4619-992d-b03eb383a4d7 Journal backup: inode blocks
保留幾多空間比 root
-m <percentage> //保留塊的百分比, default 5%
Example:
tune2fs -m 1 /dev/sda3
Setting reserved blocks percentage to 0% (0 blocks)
Checking
Reserved blocks uid: 0 (user root) Reserved blocks gid: 0 (group root)
有關 fsck 的設定
-c max-mount-counts <-- 0 or -1 => disregarded by e2fsck(8) and the kernel.
-C mount-count <-- 每次 mount 時會自動 update
Checking
Mount count: 70 Maximum mount count: -1
P.S.
Enable 它的原因
Bad disk drives, cables, memory, and kernel bugs could all corrupt a filesystem without marking the filesystem dirty
Label
-L volume-label
Errors-behavior
errors-behavior:
- continue (Default)
- remount-ro
- panic
i.e.
# -e errors-behavior
tune2fs -e remount-ro /dev/sdc1
tune2fs 1.42.13 (17-May-2015) Setting error behavior to 2
Bypass a fsck
touch /forcefsck
它是由 /etc/init.d/checkfs.sh 引發
sudo touch /forcefsck
有機會出現的問題:
touch: cannot touch `/forcefsck': Read-only file system
fsck 的設定
-i <n> N 天 check 一次 // interval-between-checks, m as months, w as weeks, default 6 個月
-c <n> // 每當檔案系統被掛載成讀寫模式時 mount count ++, 當到 n 時, 那就 fsck
-C mount-count // 設置 mount count // 當 -C > -c 時, 下次 reboot就一定會 fsck
-n // fsck to avoid attempting to repair any problems, report problems to stdout
設置開機完全不 fsck
tune2fs -c 0 -i 0 /dev/sdb1
介分區後看不到新介的分區
fdisk -l 看到, 而 ls /dev/sd* 看不到
parted
+ partprobe
Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy).
As a result, it may not reflect all of your changes until after reboot.
掛載信息
/etc/mtab <-- 已掛載的分區信息
/etc/fstab
<file system> <mount point> <type> <options> <dump> <pass>
獲得 HardDisk 的 UUID
ls -l /dev/disk/by-uuid/
vol_id /dev/sda1
blkid /dev/sda1
not aligned
parted: "The resulting partition is not aligned... "
Modern HDD starting after about 1TB can use 4kB physical sectors.
Its important for performance that filesystems are aligned on 4kB boundaries,
as the drive will do read/modify/write to fake 512B physical sectors.
找 USB HardDisk
找出本機的 Block Device
ls /sys/block
OR
lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 232.9G 0 disk ├─sda1 8:1 0 94M 0 part /boot ├─sda2 8:2 0 9.3G 0 part / ├─sda3 8:3 0 1.9G 0 part [SWAP] ├─sda4 8:4 0 1K 0 part ├─sda5 8:5 0 18.5G 0 part ├─sda6 8:6 0 18.6G 0 part ├─sda7 8:7 0 18.6G 0 part ├─sda8 8:8 0 18.6G 0 part └─sda9 8:9 0 44.7G 0 part /mnt/vm
是不是 hotplug 的 Disk ?
cat /sys/block/sd*/removable
0 1 1 1 1
lsscsi:
apt-get install lsscsi
lsscsi
[0:0:0:0] disk ATA Hitachi HDP72502 GM2O /dev/sd
ls -al /dev/disk/by-id/
total 0 lrwxrwxrwx 1 root root 9 Oct 24 08:51 scsi-3600508e000000000cc17b439c8f08602 -> ../../sda lrwxrwxrwx 1 root root 10 Oct 24 08:51 scsi-3600508e000000000cc17b439c8f08602-part1 -> ../../sda1 lrwxrwxrwx 1 root root 10 Oct 24 08:51 scsi-3600508e000000000cc17b439c8f08602-part2 -> ../../sda2 lrwxrwxrwx 1 root root 10 Oct 24 08:51 scsi-3600508e000000000cc17b439c8f08602-part3 -> ../../sda3 lrwxrwxrwx 1 root root 9 Oct 24 08:51 usb-BUFFALO_External_HDD_0000000204019FA -> ../../sdc lrwxrwxrwx 1 root root 10 Oct 24 08:51 usb-BUFFALO_External_HDD_0000000204019FA-part1 -> ../../sdc1 lrwxrwxrwx 1 root root 9 Oct 24 08:51 usb-BUFFALO_External_HDD_00000002E077D26 -> ../../sdb lrwxrwxrwx 1 root root 10 Oct 24 08:51 usb-BUFFALO_External_HDD_00000002E077D26-part1 -> ../../sdb1
blktrace
用它可以獲得以下資訊
- sync
- read
- write
- queue
- requeue
- issue
- complete
安裝:
apt-get install blktrace
使用:
blktrace -a write /dev/sda5
重讀 partion table
partprobe /dev/sdX
相當於
echo 1 > /sys/block/sdd/device/rescan