我想检查磁盘、分区、文件系统和 LV 的运行状况。所以我跑了fsck
。我听说要在文件系统上使用fsck
,我需要从可启动闪存驱动器启动到实时 Lubuntu 并事先卸载文件系统,所以我就这么做了。但为什么fsck
总是立即返回呢?如何实际fsck
检查磁盘、分区、文件系统和 LV 的运行状况?谢谢。
$ sudo fsck /dev/sda
fsck from util-linux 2.31.1
e2fsck 1.44.1 (24-Mar-2018)
/dev/sda is in use.
e2fsck: Cannot continue, aborting.
$ sudo umount /dev/sda
umount: /dev/sda: not mounted.
$ sudo fsck /dev/sda
fsck from util-linux 2.31.1
e2fsck 1.44.1 (24-Mar-2018)
/dev/sda is in use.
e2fsck: Cannot continue, aborting.
$ sudo fsck /dev/sda1
fsck from util-linux 2.31.1
fsck.fat 4.1 (2017-01-24)
/dev/sda1: 12 files, 1557/130812 clusters
$ sudo fsck /dev/sda2
fsck from util-linux 2.31.1
lubuntu@lubuntu:~$ echo $?
0
$ sudo parted -l
Model: ATA TOSHIBA MQ01ABF0 (scsi)
Disk /dev/sda: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 538MB 537MB fat32 EFI System Partition boot, esp
2 538MB 500GB 500GB lvm
Warning: The driver descriptor says the physical block size is 2048 bytes, but
Linux says it is 512 bytes.
Ignore/Cancel? I
Model: General UDisk (scsi)
Disk /dev/sdb: 16.1GB
Sector size (logical/physical): 2048B/512B
Partition Table: mac
Disk Flags:
Number Start End Size File system Name Flags
1 2048B 6143B 4096B Apple
2 6222kB 8614kB 2392kB EFI
Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/lubuntu--vg-home: 444GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags:
Number Start End Size File system Flags
1 0.00B 444GB 444GB ext4
Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/lubuntu--vg-swap: 4295MB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags:
Number Start End Size File system Flags
1 0.00B 4295MB 4295MB linux-swap(v1)
Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/lubuntu--vg-root: 51.5GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags:
Number Start End Size File system Flags
1 0.00B 51.5GB 51.5GB ext4
Model: Unknown (unknown)
Disk /dev/zram3: 444MB
Sector size (logical/physical): 4096B/4096B
Partition Table: loop
Disk Flags:
Number Start End Size File system Flags
1 0.00B 444MB 444MB linux-swap(v1)
Model: Unknown (unknown)
Disk /dev/zram1: 444MB
Sector size (logical/physical): 4096B/4096B
Partition Table: loop
Disk Flags:
Number Start End Size File system Flags
1 0.00B 444MB 444MB linux-swap(v1)
Model: Unknown (unknown)
Disk /dev/zram2: 444MB
Sector size (logical/physical): 4096B/4096B
Partition Table: loop
Disk Flags:
Number Start End Size File system Flags
1 0.00B 444MB 444MB linux-swap(v1)
Model: Unknown (unknown)
Disk /dev/zram0: 444MB
Sector size (logical/physical): 4096B/4096B
Partition Table: loop
Disk Flags:
Number Start End Size File system Flags
1 0.00B 444MB 444MB linux-swap(v1)
答案1
从man fsck.ext2
e2fsck 用于检查 ext2/ext3/ext4 系列文件系统。对于使用日志的 ext3 和 ext4 文件系统,如果系统在没有任何错误的情况下非正常关闭,通常在重放日志中已提交的事务后,文件系统应标记为干净。因此,对于使用日志记录的文件系统,e2fsck 通常会重播日志并退出,除非其超级块指示需要进一步检查。
从同一手册页的更下方:
-f 即使文件系统看起来干净,也强制检查。
所以...运行sudo fsck -f /dev/sda1
将导致 fsck 检查磁盘,即使超级块被标记为干净。
答案2
/dev/sda
(sdb、sdc...)是(硬件)设备——可以用作砖块的实际磁盘!/dev/sda1
(2,3...) 是上面的划分fsck
只能在第二个上工作- 你需要类似的东西聪明的为了第一
gparted
显示第二个如何嵌套在第一个中
诚然,Linux 将两者都称为“设备”,这引起了一些混乱。
LV 是(物理)FS 之上的额外抽象(见上文)。