Tips & How-To's

[How-To]Mounting LVM partitions from a command prompt or a Root Shell

Today as I booted into my openSUSE box, for reasons unknown to me, my LVM partitions failed to mount. fsck didn’t help, and and LVM based container system meant that I couldn’t use the standard mount /dev/sdxx style of mounting as well. With my /home and / configured as a LVM, the root (/) partition was active, but the /home partition was not being mounted, as a result, X and KDM wouldn’t start, giving a console login. After a bit of digging around the man files, I found thw lvm manfile and started experimenting(remember, no net access too!) and found out how to mount the LVM’d partitions.

The below set of commands require root privileges so switch over root using
su root
Next, list out all your partitions, type

linux:/ # lvmdiskscan

You will get a list of something like this

 

File descriptor 3 left open
File descriptor 4 left open
/dev/dm-0 [ 9.67 GB]
/dev/sda1 [ 78.41 MB]
/dev/dm-1 [ 6.44 GB]
/dev/sda2 [ 115.52 GB]
/dev/dm-2 [ 2.00 GB]
/dev/sda3 [ 18.11 GB] LVM physical volume
/dev/sda5 [ 15.33 GB]

 

Make a note of /dev/dm-x, those are the devices which correspond to the LVM partitions. Also do note the sizes.

Next, type

lvdisplay

to show a detailed list of all logical volumes available.

lvdisplay |more


LV Name /dev/system/home
VG Name system
LV UUID 1QP9XM-vlKi-umNO-CXvV-TnZN-RCLk-e1FDIr
LV Write Access read/write
LV Status available
# open 1
LV Size 9.67 GB
Current LE 2475
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0

— Logical volume —
LV Name /dev/system/root
VG Name system
LV UUID D1fKUJ-uU1C-jlVB-4imh-rrgy-FQu0-TC2Ssm
LV Write Access read/write
LV Status available
# open 1

LV Size 6.44 GB
Current LE 1649
Segments 1
Allocation inherit
Read ahead sectors auto
– currently set to 256
Block device 253:1

— Logical volume —
LV Name /dev/system/swap
VG Name system
LV UUID w5LqIb-xvcr-Xsbk-y3wg-lT3i-LqdN-GFK8Mi
LV Write Access read/write
LV Status available
# open 0
LV Size 2.00 GB
Current LE 512
Segments 1
Allocation inherit
Read ahead sectors auto
– currently set to 256
Block device 253:2
Now from the above set of data we can deduce that my /homepartition, of size 9.67 GB is available as LV group /dev/system/home on /dev/dm-0

Now that we know where the partition is available, we can proceed with the mounting using the mount command, as
mount /dev/dm-0 /home
And there you go, your LV partition is mounted!

4 Comments

  1. Hey man, your post was interesting for me but not worked. Here my screen below. Can you help me? Thank you!

    root@PartedMagic:~# lvmdiskscan
    /dev/ram0 [ 16.00 MiB]
    /dev/loop0 [ 39.25 MiB]
    /dev/vg1/lv1 [ 2.72 TiB]
    /dev/ram1 [ 16.00 MiB]
    /dev/loop1 [ 184.09 MiB]
    /dev/sda1 [ 9.77 GiB]
    /dev/ram2 [ 16.00 MiB]
    /dev/sda2 [ 160.42 GiB]
    /dev/ram3 [ 16.00 MiB]
    /dev/sda3 [ 150.01 GiB]
    /dev/ram4 [ 16.00 MiB]
    /dev/ram5 [ 16.00 MiB]
    /dev/sda5 [ 145.56 GiB]
    /dev/ram6 [ 16.00 MiB]
    /dev/ram7 [ 16.00 MiB]
    /dev/ram8 [ 16.00 MiB]
    /dev/ram9 [ 16.00 MiB]
    /dev/ram10 [ 16.00 MiB]
    /dev/ram11 [ 16.00 MiB]
    /dev/ram12 [ 16.00 MiB]
    /dev/ram13 [ 16.00 MiB]
    /dev/ram14 [ 16.00 MiB]
    /dev/ram15 [ 16.00 MiB]
    /dev/sdb1 [ 20.00 MiB]
    /dev/sdb2 [ 20.00 MiB]
    /dev/sdb3 [ 1.00 GiB]
    /dev/sdb4 [ 1.00 GiB]
    /dev/sdb5 [ 1.00 GiB]
    /dev/sdb6 [ 1.00 GiB]
    /dev/sdb7 [ 1.00 GiB]
    /dev/sdb8 [ 2.72 TiB] LVM physical volume
    /dev/sdc1 [ 931.51 GiB]
    /dev/sdd1 [ 7.45 GiB]
    0 disks
    32 partitions
    0 LVM physical volume whole disks
    1 LVM physical volume
    root@PartedMagic:~# lvdisplay | more
    — Logical volume —
    LV Path /dev/vg1/lv1
    LV Name lv1
    VG Name vg1
    LV UUID xNSaOD-x413-xAxY-ELtK-DIZF-5UbI-ng1aa3
    LV Write Access read/write
    LV Creation host, time ,
    LV Status available
    # open 0
    LV Size 2.72 TiB
    Current LE 714106
    Segments 1
    Allocation inherit
    Read ahead sectors auto
    – currently set to 256
    Block device 254:0

    root@PartedMagic:~# mount /dev/sdb8 /home
    mount: unknown filesystem type ‘LVM2_member’

  2. that’s because you typed in the name of the physical volume. it should have been:
    #mount /dev/ /
    #mount /dev/lv1 /home

Leave a Reply

Your email address will not be published. Required fields are marked *