Thursday, 12 December 2013

Mount LVM partition

1) Once we were in live session, we opened a terminal and ran
[root]# fdisk -l
This lists out the partition table of the system and it looked something like this
Device        Boot   Start       End      Blocks           Id     System
/dev/sda1     *        1           4864     39070048+    7     HPFS/NTFS
/dev/sda2            4865       6691     14675377+    83   LVM2_member
...
2) The good news was that the system was at least able to distinguish the partitions. So, in order to backup the data, the next step was to access the /dev/sda2 partition. But since it is an lvm partition we will had to take some additional steps to mount it.
Now, run the pvs command. Please note that while in live session you may find that this is not installed by default. In order to install the required tools, run the following command.
[root]$ sudo apt-get install lvm2
Of course, you should be connected to internet. Once you are done with this run pvs.
[root]# pvs
This will list the volume groups to which our physical volume /dev/sda2 belonged. It would be of the form
PV               VG                Fmt    Attr    PSize       PFree
/dev/hda2   VolGroup01  lvm2   a-      148.94G   32.00M
The second field, VG, shows the Volume group. The above output is just an example, showing that we are concerned with the Volume group "VolGroup01". The next step is to list the information about this volume group.

Incase if PVS does not show any output run   pvdisplay, or pvscan.
There are three commands you can use to display properties of LVM physical volumes: pvs, pvdisplay, and pvscan.
[root]# lvdisplay /dev/VolGroup01
It will throw a bunch of ouput, but the one we are concerned with is LV Name. It will look something like this
LV Name /dev/VolGroup01/LogVol00
In our case, there were two entries of type LV Name, the other being LogVol01, the swap. The whole output along with it will help you to identify the target logical volume you are looking for. Assuming that the above one is the partition that we need to mount, just use the usual method to mount it.
[root]# mount /dev/VolGroup01/LogVol00   /mnt

If mounting throws below error
[root]# mount /dev/VolGroup01/LogVol00   /mnt
mount: special device /dev/VolGroup01/LogVol00 does not exist
Execute command
 vgchange -a y VolGroup01
Output will be something like below
[root]# vgchange -a y VolGroup01
  3 logical volume(s) in volume group "VolGroup01" now active
Now, you can to find the data you were looking for in the /mnt folder.

No comments:

Post a Comment