1

I have backed up a drive with all its partitions using the command

dd if=/dev/sda of=/media/oshirowanen/external-drive/backups-2019/full_drive_backup.img 

/dev/sda is an ssd which has a Linux OS with full encryption.

Before I wipe this drive and re-purpose it, I want to make sure the backup has worked.

I have tried the following by searching unix.stackexchange and other stackexchange sites:

sudo losetup -P /dev/loop0 /media/oshirowanen/external-drive/backups-2019/full_drive_backup.img 
[sudo] password for oshirowanen: [password goes here]
losetup: /media/oshirowanen/external-drive/backups-2019/full_drive_backup.img: failed to set up loop device: Device or resource busy

sudo losetup -P /dev/loop100 /media/oshirowanen/external-drive/backups-2019/full_drive_backup.img 
sudo cryptsetup luksOpen /dev/loop100p5 img5
Enter passphrase for /dev/loop100p5: [password goes here]

cd /mnt
mkdir img5
sudo mount /dev/mapper/img5 img5
mount: /mnt/img5: unknown filesystem type 'LVM2_member'.

What am I doing wrong? Both cryptsetup and lvm2 are already installed.

If this is not the best way to backup the drive, please suggest something else which is better.


UPDATE 1:

Here is a screenshot of /dev/sda's partitions:

enter image description here


UPDATE 2:

Output from LiveUSB:

liveusb@liveusb:~$ sudo losetup -P /dev/loop100 /media/external-drive/backups-2019/full_drive_backup.img 
liveusb@liveusb:~$ sudo cryptsetup luksOpen /dev/loop100p5 img5
Enter passphrase for /dev/loop100p5: 
liveusb@liveusb:~$ cd /mnt
liveusb@liveusb:/mnt$ sudo mkdir img5
liveusb@liveusb:/mnt$ sudo mount /dev/mapper/img5 img5
mount: /mnt/img5: unknown filesystem type 'LVM2_member'.
liveusb@liveusb:/mnt$ sudo pvscan
  PV /dev/mapper/img5   VG ubuntu-vg       lvm2 [232.16 GiB / 0    free]
  Total: 1 [232.16 GiB] / in use: 1 [232.16 GiB] / in no VG: 0 [0   ]
liveusb@liveusb:/mnt$ sudo vgscan
  Reading volume groups from cache.
  Found volume group "ubuntu-vg" using metadata type lvm2
liveusb@liveusb:/mnt$ sudo vgs
  VG        #PV #LV #SN Attr   VSize   VFree
  ubuntu-vg   1   2   0 wz--n- 232.16g    0 
liveusb@liveusb:/mnt$ sudo lvs
  LV     VG        Attr       LSize    Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root   ubuntu-vg -wi-a----- <231.21g                                                    
  swap_1 ubuntu-vg -wi-a-----  980.00m                                                    
liveusb@liveusb:/mnt$ ls /dev/mapper/
control  img5  ubuntu--vg-root  ubuntu--vg-swap_1
liveusb@liveusb:/mnt$ 
5
  • Are there any partitions on /dev/sda? Is /dev/sda encrypted, or are one or more of the partitions encrypted? – Olaf Dietsche Dec 24 '19 at 15:18
  • @OlafDietsche, please see screenshot of partitions in OP. Yes, at least 1 partition is encrypted. – oshirowanen Dec 24 '19 at 16:24
  • Ok, does askubuntu.com/q/766048/108339 help you here? Particularly vgscan and maybe vgrename? – Olaf Dietsche Dec 24 '19 at 16:29
  • Have you tried pvs (physical volumes), vgs (volume groups) and lvs (logical volumes) to see what the system recognizes? – Olaf Dietsche Dec 24 '19 at 16:35
  • @OlafDietsche, please see output in update 2 from liveusb. – oshirowanen Dec 24 '19 at 17:27
1

Judging from the image, the partition seems to be a physical volume. This is verified by pvscan.

lvs lists two logical volumes, one of them a swap partition (LV swap_1) it seems, and the other the actual file system (LV root). This is the relevant one, to be mounted by

mount -o ro /dev/mapper/ubuntu--vg-root /mnt/img5
0

In this specific case the LUKS volume contains a Logical Volume Manager Physical Volume (hence the LVM2_member error you received while trying to mount).

The outputs

# pvscan
  PV /dev/mapper/img5   VG ubuntu-vg       lvm2 [232.16 GiB / 0    free]

and

# vgs
  VG        #PV #LV #SN Attr   VSize   VFree
  ubuntu-vg   1   2   0 wz--n- 232.16g    0 

both indicate that the LUKS volume contains (fully) the volume group ubuntu-vg, which contains the logical volumes

$ sudo lvs
  LV     VG        Attr       LSize    Pool Origin Data%  Meta%  Move Log  Cpy%Sync Convert
  root   ubuntu-vg -wi-a----- <231.21g                                                    
  swap_1 ubuntu-vg -wi-a-----  980.00m   

You can mount the filesystem under root through the command

sudo mount /dev/ubuntu-vg/root /mnt/img5

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.