Skip to content

How to mount LVM partition

Connect the drive

First plug in the drive as normal and let Gnome/KDE mount the partitions it can see. My USB connected disk gets mounted to /media and is device /dev/sdb.

$ cd /media
$ ls -l
total 14
drwxr-xr-x 4 root root 1024 2007-12-05 07:10 _boot
drwxr-xr-x 11 bobpeers root 4096 1970-01-01 01:00 DATA
drwxrwxrwx 1 root root 8192 2007-10-19 23:00 SYSTEM

Here you can see the 3 mounted partitions

  • _boot is my Linux boot partition
  • DATA is my FAT32 partition
  • SYSTEM is my main Windows NTFS partition

So no Linux partitions visible. To see what’s actually on the disk we can use fdisk as root.

# /sbin/fdisk -l /dev/sdb

Disk /dev/sdb: 40.0 GB, 40007761920 bytes
255 heads, 63 sectors/track, 4864 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x86c986c9

Device Boot Start End Blocks Id System
/dev/sdb1 * 1 1567 12586896 7 HPFS/NTFS
/dev/sdb2 1568 2220 5245222+ c W95 FAT32 (LBA)
/dev/sdb3 2221 2245 200812+ 83 Linux
/dev/sdb4 2246 4864 21037117+ 5 Extended
/dev/sdb5 2246 4864 21037086 8e Linux LVM

So we see that /dev/sda1 through 3 are mounted but /dev/sdb4 and 5 are the Logical Volume holding the Linux data I need to mount and copy to the new drive.

Scan the drive with pvscan

To see what logical volumes are available use the following command as root. The man page for pvscan says ‘pvscan scans all supported LVM block devices in the system for physical volumes’.

# /sbin/pvscan
PV /dev/sdb5 VG Fedora_volume lvm2 [20.03 GB / 0 free]
PV /dev/sda5 VG Linux_volume lvm2 [44.81 GB / 32.00 MB free]
Total: 2 [64.84 GB] / in use: 2 [64.84 GB] / in no VG: 0 [0 ]

Here we can now see 2 logical volume groups, the first (Fedora_volume) is the one we want on /dev/sdb5 (the USB drive) while the second (Linux_volume) is the one on my new internal drive, /dev/sda5

Scan the drive with lvscan

We can also use lvscan to scan for logical volumes and to give more detail.

# /usr/sbin/lvscan
inactive '/dev/Fedora_volume/LogVol00' [14.03 GB] inherit
inactive '/dev/Fedora_volume/LogVol02' [5.00 GB] inherit
inactive '/dev/Fedora_volume/LogVol01' [1.00 GB] inherit
ACTIVE '/dev/Linux_volume/LogVol00' [33.78 GB] inherit
ACTIVE '/dev/Linux_volume/LogVol02' [10.00 GB] inherit
ACTIVE '/dev/Linux_volume/LogVol01' [1.00 GB] inherit

The reason why I can’t see the USB logical volume is now clear, it’s marked as inactive. Here we see 3 logical volumes in the Fedora_volume volume group. These are the 3 partitions I created: 1GB swap, 5GB Home and 14GB root.

Activate the Volume Group with lvchange

To activate the volume group is very simple.

# /usr/sbin/lvchange -a y /dev/Fedora_volume

Now the volume group is active I can create mount points and mount each partition within the volume group.

Mount the partitions as normal

# mkdir /mnt/root
# mkdir /mnt/home

Note that I didn’t create a mount point for /dev/Fedora_volume/LogVol01 as this is my swap partition.

To mount the volumes is now simple.

# mount -t ext3 /dev/Fedora_volume/LogVol00 /mnt/root
# mount -t ext3 /dev/Fedora_volume/LogVol02 /mnt/home

Now we can access all our data contained on the LV’s. When finished just unmount (umount) the partitions and mark the Volume Group as inactive.

# /usr/sbin/lvchange -a n /dev/Fedora_volume

Leave a Reply