I've an image backup file of my harddisk, which consists of three partitions (
sudo fdisk -l /mnt/hdd/19_02.img):
Device Start End Sectors Size Type /mnt/hdd/19_02.img1 2048 1050623 1048576 512M EFI System /mnt/hdd/19_02.img2 1050624 34686975 33636352 16G Linux swap /mnt/hdd/19_02.img3 34686976 976773134 942086159 449.2G Linux filesystem
The third partition ist of type
crypto_LUKS. If it wouldn't be encrypted I could mount it with
sudo mount -o loop,offset=$(expr 512 \* 34686976) /mnt/hdd/19_02.img /mnt/img, which results in
mount: /mnt/img: unknown filesystem type 'crypto_LUKS'.
What I've tried
sudo cryptsetup luksOpen /mnt/hdd/19_02.img3 img results in
Device /mnt/hdd/19_02.img3 doesn't exist or access denied.
sudo cryptsetup plainOpen --offset=$(expr 512 \* 34686976) /mnt/hdd/19_02.img img asks for my passphrase which also gets accepted, but returns with
Requested offset is beyond real size of device /mnt/hdd/19_02.img.
cryptsetup does multiply the offset value with the block size by itself.
sudo cryptsetup plainOpen --offset=34686976 /mnt/hdd/19_02.img img asks for my passphrase which also gets accepted and returns fine. But
sudo mount /dev/mapper/img /mnt/img complains
mount: /mnt/img: wrong fs type, bad option, bad superblock on /dev/mapper/img. Analysing with
sudo lsblk -f /dev/mapper/img shows there is no filesystem recognized.
NAME FSTYPE LABEL UUID FSAVAIL FSUSE% MOUNTPOINT img
The encrypted device was created by
LUKS mode, so it properly makes not much sense opening it with
luksOpen doesn't offer an
sudo cryptsetup luksOpen --offset=34686976 /mnt/hdd/19_02.img img results in
cryptsetup: Option --offset is supported only for open of plain and loopaes devices and for luksFormat. (Didn't tried
luksFormat, but it sets up the LUKS device header and encrypts the master-key.)
The question after all
How to do
cryptsetup luksOpen with offset on an image file?