My blog has moved!

You should be automatically redirected in 6 seconds. If not, visit
http://sourceperfect.wordpress.com/
and update your bookmarks.

Wednesday, February 4, 2009

How to mount a Linux LVM volume

Hah! I thought mounting a LVM volume would be a straight forward thing, but, I guess thinking like that was my first mistake. Anyways, I found the solution to mounting a LVM partition on my USB hard-drive and I'm re-writing it here for me to remember it always :-))

Plugged in my USB hard-drive with a LVM partition on it...No automatic appearance of a windows manager...hmmmmm....

Firstly I need to know the device so firstly a dmesg at the prompt will tell me that:

# dmesg
lot's of info...but I see a /dev/hda appearing..
Next I need to know more detailed the partition structure...

# fdisk -l /dev/hda

Disk /dev/hda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hda1 * 1 13 104391 83 Linux
/dev/hda2 14 19457 123183789 8e Linux LVM

Ah! there it is...

# mount /dev/hda2 /tmp/mnt
WHOOPS !!
mount: /dev/hda2 already mounted or /tmp/mnt busy

okay, googling...googling...googling... Found a bunch of sites, which helped me out and here's a step by step guide as to how to proceed...

We need to now run the command pvs in-order to get info about the Volume Group...(all commands from here on need to be run as root user or using "sudo")

# pvs
PV VG Fmt Attr PSize PFree
/dev/hda2 VolGroup01 lvm2 a- 148.94G 32.00M

Next, we need to list the logical volumes in VolGroup01.

# lvdisplay /dev/VolGroup01
--- Logical volume ---
LV Name /dev/VolGroup01/LogVol00
VG Name VolGroup01
LV UUID zOQogm-G8I7-a4WC-T7KI-AhWe-Ex3Y-JVzFcR
LV Write Access read/write
LV Status NOT available
...and a bunch of more info...

so, logically that means I can mount
/dev/VolGroup01/LogVol00 ... here goes... (drum roll)...

# mount /dev/VolGroup01/LogVol00 /tmp/mnt

WHOOPS again...it doesn't work...hmmm seems the error is "LV Status NOT available"...

...another little command to make the status changes...
# vgchange -ay

# mount /dev/VolGroup01/LogVol00 /tmp/mnt

BINGO !!! finally got it right :-))


6 comments:

Anonymous said...

EXCELLENT! Exactly what I was looking for. Thanks for taking the time to post your solution.

Unknown said...

Glad to know it helped you out :-)

Chris said...

Wow, this worked out perfect for what I was trying to accomplish. Thank you very much!

Unknown said...

@Chris: Good to know it worked out for you :-)

Anonymous said...

God Bless you Man.. you saved our day..

~ A very happy programmer.

Unknown said...

@Happy Programmer: Cool :-)

Wednesday, February 4, 2009

How to mount a Linux LVM volume

Hah! I thought mounting a LVM volume would be a straight forward thing, but, I guess thinking like that was my first mistake. Anyways, I found the solution to mounting a LVM partition on my USB hard-drive and I'm re-writing it here for me to remember it always :-))

Plugged in my USB hard-drive with a LVM partition on it...No automatic appearance of a windows manager...hmmmmm....

Firstly I need to know the device so firstly a dmesg at the prompt will tell me that:

# dmesg
lot's of info...but I see a /dev/hda appearing..
Next I need to know more detailed the partition structure...

# fdisk -l /dev/hda

Disk /dev/hda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hda1 * 1 13 104391 83 Linux
/dev/hda2 14 19457 123183789 8e Linux LVM

Ah! there it is...

# mount /dev/hda2 /tmp/mnt
WHOOPS !!
mount: /dev/hda2 already mounted or /tmp/mnt busy

okay, googling...googling...googling... Found a bunch of sites, which helped me out and here's a step by step guide as to how to proceed...

We need to now run the command pvs in-order to get info about the Volume Group...(all commands from here on need to be run as root user or using "sudo")

# pvs
PV VG Fmt Attr PSize PFree
/dev/hda2 VolGroup01 lvm2 a- 148.94G 32.00M

Next, we need to list the logical volumes in VolGroup01.

# lvdisplay /dev/VolGroup01
--- Logical volume ---
LV Name /dev/VolGroup01/LogVol00
VG Name VolGroup01
LV UUID zOQogm-G8I7-a4WC-T7KI-AhWe-Ex3Y-JVzFcR
LV Write Access read/write
LV Status NOT available
...and a bunch of more info...

so, logically that means I can mount
/dev/VolGroup01/LogVol00 ... here goes... (drum roll)...

# mount /dev/VolGroup01/LogVol00 /tmp/mnt

WHOOPS again...it doesn't work...hmmm seems the error is "LV Status NOT available"...

...another little command to make the status changes...
# vgchange -ay

# mount /dev/VolGroup01/LogVol00 /tmp/mnt

BINGO !!! finally got it right :-))


6 comments:

Anonymous said...

EXCELLENT! Exactly what I was looking for. Thanks for taking the time to post your solution.

Unknown said...

Glad to know it helped you out :-)

Chris said...

Wow, this worked out perfect for what I was trying to accomplish. Thank you very much!

Unknown said...

@Chris: Good to know it worked out for you :-)

Anonymous said...

God Bless you Man.. you saved our day..

~ A very happy programmer.

Unknown said...

@Happy Programmer: Cool :-)