So you have a Linux machine that is installed with LVM and you have assigned root partition to sit on that LVM pool. One day your machine is crashed and the root partition is corrupted. It failed to boot properly and asked you to fill in root password to run fsck. Sadly, you lost the root password and you need a recovery CD (or installation CD) to boot and recover the disk.
Now your machine is booted and you found that your just couldn't run fsck against a LVM partition.
root@test:/# fdisk -l
Disk /dev/vda: 21.5 GB, 21474836480 bytes
16 heads, 63 sectors/track, 41610 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00014ef8
Device Boot Start End Blocks Id System
/dev/vda1 * 3 389 194560 83 Linux
/dev/vda2 391 41609 20773888 8e Linux LVM
So rescue CD by default just won't automatically activate the LVM (and its underlaying volumes). What you need to do is to activate the LVM partition. and then run fsck on the volumes.
### Run lvm from rescue CD
bash-4.1# lvm
### This will scan and list the PV
lvm> pvscan
PV /dev/vda2 VG volgroup01 lvm2 [19.78GiB/ 0 free]
Total: 1 [19.78 GiB] / in use: 1 [19.78 GiB] / in no VG: 0 [0 ]
### This will scan and list the VG
lvm> vgscan
Reading all physical volumes. This may take a while...
Found volume group "volgroup01" using metadata type lvm2
### This will list and scan the LV (the meat is here)
lvm> lvscan
inactive '/dev/volgroup01/root' [11.78 GiB] inherit
inactive '/dev/volgroup01/swap' [8.00 GiB] inherit
### And then execute lvchange
bash-4.1# lvchange -ay /dev/volgroup01/root
### So quit the lvm
lvm > exit
Adding dirhash hint to filesystem
### now time to run fsck
bash-4.1# fsck -y /dev/volgroup01/root
沒有留言:
張貼留言