Wednesday, March 31, 2010

Mount Lvm Partition and backup data using Live linux CD

Once I ran yum update on my fedora 12 lxde spin and it broke. System was unable to boot. I had to take backup before reinstalling so booted with the fedora 12 lxde live cd and ran regular mount command mount /dev/sda2 /mnt/hdd but got error - "mount: unknown filesystem type 'LVM2_member'"
After lot of googling I came across [http://forums.opensuse.org/archives/sf-archives/archives-software/337006-can-not-mount-lvm-partition-2.html] which was a life saver for me and my data. Then I ran following commands with output [indented] to mount my volume.

su

pvscan
PV /dev/sda2 VG vg_xps lvm2 [74.33 GB / 0 free]
Total: 1 [74.33 GB] / in use: 1 [74.33 GB] / in no VG: 0 [0 ]

vgscan -v
Wiping cache of LVM-capable devices
Wiping internal VG cache
Reading all physical volumes. This may take a while...
Finding all volume groups
Finding volume group "vg_xps"
Found volume group "vg_xps" using metadata type lvm2

vgchange -ay -v
Finding all volume groups
Finding volume group "vg_xps"
2 logical volume(s) in volume group "vg_xps" already active
2 existing logical volume(s) in volume group "vg_xps" monitored
Found volume group "vg_xps"
Found volume group "vg_xps"
Activated logical volumes in volume group "vg_xps"
2 logical volume(s) in volume group "vg_xps" now active

vgdisplay -v
Finding all volume groups
Finding volume group "vg_xps"
--- Volume group ---
VG Name vg_xps
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 1
Max PV 0
Cur PV 1
Act PV 1
VG Size 74.33 GB
PE Size 4.00 MB
Total PE 19029
Alloc PE / Size 19029 / 74.33 GB
Free PE / Size 0 / 0
VG UUID wDR2Xa-8km9-Q5f3-4y4f-jCyE-ebkn-pQbTev
--- Logical volume ---
LV Name /dev/vg_xps/lv_root
VG Name vg_xps
LV UUID OshzOn-H2WY-6GXP-W0D9-HBJ2-fqRD-6heWXi
LV Write Access read/write
LV Status available
# open 0
LV Size 72.33 GB
Current LE 18517
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2
--- Logical volume ---
LV Name /dev/vg_xps/lv_swap
VG Name vg_xps
LV UUID ScYasH-efcp-0yyP-i0FK-lcFJ-g33x-lo3bie
LV Write Access read/write
LV Status available
# open 1
LV Size 2.00 GB
Current LE 512
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:3
--- Physical volumes ---
PV Name /dev/sda2
PV UUID oENBs0-bYPL-8Uh3-bZsJ-H6nZ-tjDv-DUH99M
PV Status allocatable
Total PE / Free PE 19029 / 0

Note down the "LV Name" for running next command. Here LV name is /dev/vg_xps/lv_root

lvchange -ay -v /dev/vg_xps/lv_root
Using logical volume(s) on command line
Activating logical volume "lv_root"
Found volume group "vg_xps"

cd /mnt
mkdir hdd
mount /dev/vg_xps/lv_root /mnt/hdd

The logical volume has been mounted under /mnt/hdd and we can take backup now.

For those interested in knowing why the yum update created issue with my fedora 12 lxde boot, it's because of kernel update of kernel-2.6.32.10-90 on system. Defect at https://bugzilla.redhat.com/show_bug.cgi?id=578217#c8. I tried to install kernel-2.6.32.10-94.fc12.i686.rpm and kernel-2.6.32.10-94.fc12.src.rpm from http://koji.fedoraproject.org/koji/buildinfo?buildID=164636 but same issue. Hence reinstalled lxde spin and sticking to 2.6.31.5-127.fc12.i686 by disabling updates untill fedora 13 comes out.

3 comments:

Bhushan Karia said...

Thanks bhupendra this really helped us to backup data from linux lvm partition

Unknown said...

Bhupendra, this was simply and amazing. I have tried other means of retrieving data from failed LVM's before. They were hit and miss and this was solid and complete. My data is now safe. Thank you!

Anonymous said...

Very, Very helpful, it has helped my save 1TB of data.

many thanks.

fats