Thursday, March 2, 2017

How to mount LVM-Thin volume - mounting the backup of it or directly

Creating snapshot of LVM-Thin volume
lvcreate -L30G -s -n snp111 /dev/pve/vm-111-disk-1

Creating disk dump from LVM-thin snapshot
dd if=/dev/pve/snp111 of=vm111.dd

Creating logical drive for the importing the backup
lvcreate -L30G -n drv30g external
Importing the disk dump to locical drive for backup
dd if=vm111.dd of=/dev/external/drv30g

Make partitions mountable with kpartx
kpartx -a /dev/external/drv30g
Check which partitions there are:
 kpartx -l /dev/external/drv30g
ls /dev/mapper
Mount the partition you want and browse files
mount /dev/mapper/external-drv30g3 /mnt/drv30
Dismount partition after ready
umount /mnt/drv30
 Remove kpartx created partitions
 kpartx -d -v /dev/external/drv30g

kpartx part could be used without using snapshot.