How to mount Linux LVM volume partitions on Linux
So, one of my friends had this weird system breakdown while upgrading Fedora from DVD. Grub couldn't locate the grub.cfg file. In order to fix the system and take a backup of some important files, we booted in a live session, mounted a lvm partition to find out that most of the data was gone
. The end was pretty bad but I think, just like in my case, there will be many more who wouldn't know how to mount a lvm partition. This little adventure of mine might help you out.
In case you have to do something similar just follow the steps we took.
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.
[shredder12]$ 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.
[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
Now, you can to find the data you were looking for in the /mnt folder.
3 Comments
LVM is a Logical Volume Manager for the Linux kernel. With LVM you can abstract your storage space and have "virtual partitions" which are easier to modify. The basic building blocks of LVM are:
-Physical volume (PV): Partition on hard disk (or even hard disk itself or loopback file) on which you can have volume groups. It has a special header and is divided into physical extents. Think of physical volumes as big building blocks which can be used to build your hard drive.
-Volume group (VG): Group of physical volumes that are used as storage volume (as one disk). They contain logical volumes. Think of volume groups as hard drives.
-Logical volume (LV): A "virtual/logical partition" that resides in a volume group and is composed of physical extents. Think of logical volumes as normal partitions.
-Physical extent (PE): A small part of a disk (usually 4MB) that can be assigned to a logical Volume. Think of physical extents as parts of disks that can be allocated to any partition.
With LVM you can more easily handle your partitions (logical volumes) than normal hard drive partitions. For example, you can:
-Use any number of disks as one big disk(VG)
-Have partitions(LV) stretched over several disks (they can be as big as all of your disk storage together)
-Resize/create/delete partitions(LV) and disks(VG) as you like (it doesn't depend on position of the logical volumes within volume groups as with normal partitions)
-Resize/create/delete partitions(LV) and disks(VG) online (filesystems on them still need to be resized, but some support online resizing)
-Name your disks(VG) and partitions(LV) as you like
-Create small partitions(LV) and resize them "dynamically" as they get more filled (growing must be still done by hand, but you can do it online with some filesystems)
Post new comment