Ubuntu - LVM - Mount LVM partition from USB
Execute:
vgscan
vgchange -a y
as root and all the partitions should have devices created in the form /dev/volumegroup/logicalvolume, which you can then mount in the usual way:
mount /dev/volumegroup/logicalvolume /mnt/somewhere
Extended Method
1. Boot from a live disk or USB.
2. Search for these tools: lvm2. If not found then install it.
sudo apt install lvm2
NOTE: Some command below may return with the following error after installing LVM2:
/proc/misc: No entry for device-mapper found Is device-mapper driver missing from kernel?
If so, then you load the dm-mod driver manually:
modprobe dm-mod
3. Make sure the harddisk is recognised.
fdisk -lu
4. Run pvscan to scan all disks for physical volume. This is to make sure your LVM harddisk is detected by Ubuntu.
pvscan
returns
PV /dev/sda2 VG VolGroup00 lvm2 [74.41 GB / 32.00 MB free] Total: 1 [74.41 GB] / in use: 1 [74.41 GB] / in no VG: 0 [0 ]
5. Run vgscan to scan disks for volume groups.
vgscan
returns
Reading all physical volumes. This may take a while... Found volume group "VolGroup00" using metadata type lvm2
6. Activate all volume groups available.
vgchange -a y
returns
2 logical volume(s) in volume group "VolGroup00" now active
7. Run lvscan to scan all disks for logical volume. You can see partitions inside the hard disk now active.
lvscan
returns
ACTIVE '/dev/VolGroup00/LogVol00' [72.44 GB] inherit ACTIVE '/dev/VolGroup00/LogVol01' [1.94 GB] inherit
8. Mount the partition to any directory you want, usually to /mnt
mount /dev/VolGroup00/LogVol00 /mnt
9. Access the partition in the /mnt directory as required.
Script
DISK=mydisk lvdisplay | grep $DISK | grep "LV Path" | sed 's/.* //g' LV_DISK=$(lvdisplay | grep $DISK | grep "LV Path" | sed 's/.* //g') fdisk -l $LV_DISK fdisk -lu $LV_DISK | sed -n '/lv[0-9]p[1-3]/ p' | grep p1 | awk '{print $2}' OFFSET=$(fdisk -lu $LV_DISK | sed -n '/lv[0-9]p[1-3]/ p' | grep p1 | awk '{print $2}') OFFSET=$((OFFSET * 512)) MOUNT=/mnt/$DISK mkdir -p $MOUNT mount -o loop,offset=$OFFSET $LV_DISK $MOUNT