The following post was send by WebUpd8 reader rkv and it's a mix of story / how-to recover the LVM partition on a damaged HDD. Read on!
Scenario:
80GB SATA HDD, Bad Sectors, 4 Primary Partitions, boot, root, swap and a 60GB Volume Group can boot into the OS (very slow), LVM not recognized.
Solution:
I connected the hard-disk to another Linux box as a secondary drive, took a while to boot indicating bad HDD. After 20 mins (yeah 20 mins), box booted into single user mode, login as root.
I then ran the following commands:
found lots of bad blocks errors.
took a couple of minutes for the output but showed all the partitions.
didn't recognize any volume groups.
Now i realized that the HDD is failing, as all the above commands are taking a lot of time, so I thought taking a physical dump using dd will help a lot. I could take the raw dump of the entire /dev/sdb4 (the lvm partition) but i just needed data from the home folder i.e. 45 GB / 60 GB so I decided to try some more.
Nnow i tried to recover the lvm metadata for the volume group ( Thanks Purna! )
After 30 mins, i got no message, but fdisk -l shows a lot of mapper devices. vgdisplay gave me all the logical volumes in the physical volume.
Thanks for good labeling, i can see HOMEVOLUME, USRVOLUME, VARVOLUME, TMPVOLUME so now i know that i need to recover the HOMEVOLUME partition. So quickly I tried to mount the /dev/LVMVOLUME/HOMEVOLUME device but after couple of minutes, I got bad FS type error. I even tried specifying the partition type -- ext3 but with no luck.
I then thought its time for "the best command in linux": dd.
But it failed, gave some bad block error. Target file was 0 kb!
On further research, i found some switches for dd, to ignore bad blocks and move on:
You might be wondering why i specified block size as 64k, the reason is, if dd encounters a bad block, it will skip, so the block size defines how much to skip, so 64k ensures dd copies as much data as possible but will take lot of time to complete, as opposed to specifying higher block size, which will be fast but recovery wont be that successful.
Anyways so I left it overnight and in the morning i have my 47 GB iso file.
So enthusiastically i tried to mount it:
But didn't work, gave me unknown file system error.
So then i tired the command:
It started checking the disk for errors, and found lots of them, i had to type yes for all the questions. I should have specified the "assume yes and move on" switch, but didn't want to cancel and take chances so after the file system check completed, i tried to mount the iso image again and VOILA, it returned the prompt quietly (I love Linux when it does this!)
All the files needed were intact, I checked few files, they were okay, there might be some corrupt files, but will find out only when I open them.
Hope this article helps!
Also check out how I fixed the "Couldn't mount because of unsupported optional features (2000200)" error.
80GB SATA HDD, Bad Sectors, 4 Primary Partitions, boot, root, swap and a 60GB Volume Group can boot into the OS (very slow), LVM not recognized.
Solution:
I connected the hard-disk to another Linux box as a secondary drive, took a while to boot indicating bad HDD. After 20 mins (yeah 20 mins), box booted into single user mode, login as root.
I then ran the following commands:
dmesg
found lots of bad blocks errors.
fdisk -l
took a couple of minutes for the output but showed all the partitions.
vgdisplay
didn't recognize any volume groups.
Now i realized that the HDD is failing, as all the above commands are taking a lot of time, so I thought taking a physical dump using dd will help a lot. I could take the raw dump of the entire /dev/sdb4 (the lvm partition) but i just needed data from the home folder i.e. 45 GB / 60 GB so I decided to try some more.
Nnow i tried to recover the lvm metadata for the volume group ( Thanks Purna! )
lvgchange -ay
After 30 mins, i got no message, but fdisk -l shows a lot of mapper devices. vgdisplay gave me all the logical volumes in the physical volume.
Thanks for good labeling, i can see HOMEVOLUME, USRVOLUME, VARVOLUME, TMPVOLUME so now i know that i need to recover the HOMEVOLUME partition. So quickly I tried to mount the /dev/LVMVOLUME/HOMEVOLUME device but after couple of minutes, I got bad FS type error. I even tried specifying the partition type -- ext3 but with no luck.
I then thought its time for "the best command in linux": dd.
dd /dev/LVMVOLUME/HOMEVOLUME /mnt/homelvm.iso
But it failed, gave some bad block error. Target file was 0 kb!
On further research, i found some switches for dd, to ignore bad blocks and move on:
dd /dev/LVMVOLUME/HOMEVOLUME /mnt/homelvm.iso bs=64k conv=noerror,sync
You might be wondering why i specified block size as 64k, the reason is, if dd encounters a bad block, it will skip, so the block size defines how much to skip, so 64k ensures dd copies as much data as possible but will take lot of time to complete, as opposed to specifying higher block size, which will be fast but recovery wont be that successful.
Anyways so I left it overnight and in the morning i have my 47 GB iso file.
So enthusiastically i tried to mount it:
mount /mnt/homelvm.iso /opt -o loop
But didn't work, gave me unknown file system error.
So then i tired the command:
fsck.ext3 /mnt/homelvm.iso
It started checking the disk for errors, and found lots of them, i had to type yes for all the questions. I should have specified the "assume yes and move on" switch, but didn't want to cancel and take chances so after the file system check completed, i tried to mount the iso image again and VOILA, it returned the prompt quietly (I love Linux when it does this!)
All the files needed were intact, I checked few files, they were okay, there might be some corrupt files, but will find out only when I open them.
Hope this article helps!
Also check out how I fixed the "Couldn't mount because of unsupported optional features (2000200)" error.
This post was written by WebUpd8 reader rkv, so all the credits go to him! |
Tidak ada komentar:
Posting Komentar