Mount an LVM partition image cloned with dd

Written by BiRU Monday, 02 May 2016 20:38

Print

The mount procedure below use the loop0 device, check that its free with

[root@precision2 Scaricati]# losetup --all
[root@precision2 Scaricati]#

otherwise use loop1/2/3…

CHECK IMAGE

[root@precision2 Scaricati]# file backup-cloud.img
backup-cloud.img: LVM2 PV (Linux Logical Volume Manager), UUID: NiSuLv-fH2Z-eO4H-JoJ2-9yuG-fWvW-gmuJak, size: 10212081664
[root@precision2 Scaricati]# fdisk -l backup-cloud.img

Disk backup-cloud.img: 10.2 GB, 10212040704 bytes, 19945392 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

[root@precision2 Scaricati]#

MOUNT:

[root@precision2 Scaricati]# losetup /dev/loop0 backup-cloud.img
[root@precision2 Scaricati]# pvs
  PV         VG   Fmt  Attr PSize PFree
  /dev/loop0 vg   lvm2 a--  9,51g    0
[root@precision2 Scaricati]# vgchange -a y vg
  2 logical volume(s) in volume group "vg" now active
[root@precision2 Scaricati]# mount -o ro /dev/vg/lv_root /mnt/old/
[root@precision2 Scaricati]#

UMOUNT:

[root@precision2 Scaricati]# umount /mnt/old/
[root@precision2 Scaricati]# vgchange -a n vg
  0 logical volume(s) in volume group "vg" now active
[root@precision2 Scaricati]# losetup -d /dev/loop0