Sunday, March 1, 2009

Mounting LVM

Mounting an LVM may seem a bit intimidating, it's not. In reality, despite the length of this entry, you will only be running a handful of commands, and most of those just to get the needed information. Do not despair, this will be as painless as possible. All of these commands will be run as root from a terminal. Please also remember that your volume names may differ from the guide, please make sure to adjust accordingly.

# pvs

This should give you an output similar to

sabayonx86 sabayonuser # pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 VolGroup00 lvm2 a- 7.88G 32.00M
If we look closely we can see that /dev/sda2 holds a lvm that is 7.88 gig in size. In this case, thats the one we want, as it is the only one.

So now we want to see what is actually in that lvm

# lvdisplay /dev/VolGroup00

sabayonx86 sabayonuser # lvdisplay /dev/VolGroup00

--- Logical volume ---
LV Name /dev/VolGroup00/LogVol00
VG Name VolGroup00
LV UUID SWp2V0-1xPU-0tOP-UnPs-snxF-THUl-pZMKb2
LV Write Access read/write
LV Status available
# open 0
LV Size 6.88 GB
Current LE 220
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 251:0

--- Logical volume ---
LV Name /dev/VolGroup00/LogVol01
VG Name VolGroup00
LV UUID MGBeJP-ohrX-KLju-5V78-iJOi-pP3w-huaOmC
LV Write Access read/write
LV Status available
# open 0
LV Size 992.00 MB
Current LE 31
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 251:1
We are looking for two things out of that list. LV name and LV Size. We have one that is 6.88 GB and one that is 992 MB. We can safely assume that the smaller of the two is /swap so the larger must be our real filesystem. That one is named /dev/VolGroup00/LogVol00.

So now we have all the information that we need. We need only to make a mount point and actually mount the volume.

# cd /mnt
# mkdir lvm
# vgscan --mknodes
# lvchange -ay /dev/VolGroup00/LogVol00
# mount /dev/VolGroup00/LogVol00 /mnt/lvm


If all went well then can now get inside and look around, make changes, chroot in, or whatever caused us to want to mount the LVM in the first place.

See that wasn't so hard now was it. ~Az

2 comments:

John Macey said...

sabayon is useless.

Azerthoth said...

well, you cant please everyone, but I do like your well thought out reasons for your opinion.