Score:0

Imaged a LUKS drive while unenencryted, now can't mount

gb flag

while imaging a LUKS drive I accidentally imaged it while it was unencrypted (only imaged sdx1 instead of whole drive, sdx2 was boot). Now it won't mount. I've tried pretty much all methods to try and mount it but no luck. It can still be unlocked and locked via disk tool or luksOpen command, is this salvageable?

I've tried imaging to a separate drive, losetup, mount, mounting the image,etc. When unlocked it sets up a loop but doesn't actually mount anything.

after unlocking in disk utility:

sudo mount -t ext4 diskimg.img /mnt
[sudo] password for user: 
mount: /mnt: /dev/loop5 already mounted or mount point busy.

sudo mount -t ext4 diskimg.img /media
mount: /media: wrong fs type, bad option, bad superblock on                          
/dev/loop32, missing codepage or helper program, or other error.

in disk util:

Device /dev/mapper/luks-eff2a9f0-4edb-460c-908a-4a3384b0246f
mount: /mnt: wrong fs type, bad option, bad superblock on /dev/mapper/luks-eff2a9f0-4edb-460c-908a-4a3384b0246f, missing codepage or helper program, or other error.

What I've tried:

user@user:~/Documents$ mke2fs -n /dev/sdb1
mke2fs 1.45.7 (28-Jan-2021)
/dev/sdb1 contains a crypto_LUKS file system
Proceed anyway? (y,N) y
Creating filesystem with 30629632 4k blocks and 7659520 inodes
Filesystem UUID: e8c13120-2388-4147-a6e8-7591dee60d8e
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
    4096000, 7962624, 11239424, 20480000, 23887872

user@user:~/Documents$ sudo fsck -t ext4 /dev/sdb1
fsck from util-linux 2.36.1

user@user:~/Documents$ e2fsck -b 32768 /dev/sdb1
e2fsck 1.45.7 (28-Jan-2021)
e2fsck: Bad magic number in super-block while trying to open /dev/sdb1

The superblock could not be read or does not describe a valid ext2/ext3/ext4
filesystem.  If the device is valid and it really contains an ext2/ext3/ext4
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
    e2fsck -b 8193 <device>
 or
    e2fsck -b 32768 <device>

/dev/sdb1 contains a crypto_LUKS file system

Is there some way of saving the data in the image/device?

I also tried to use the same method on the device or LVM layer when unlocked:

e2fsck -b 163840 /dev/mapper/luks-eff2a9f0-4edb-460c-908a-     4a3384b0246f
e2fsck 1.45.7 (28-Jan-2021)
e2fsck: Bad magic number in super-block while trying to open /dev/mapper/luks-eff2a9f0-4edb-460c-908a-4a3384b0246f
Sebastian avatar
in flag
I cannot tell from your post if you're doing things in the right order since it only seems to contain part of the commands you use. But generally if your (encrypted) image is `diskimg.img`, then you would need to first unlock it using `cryptsetup` and then mount the mapped device created by `cryptsetup`. It seems that what you want to mount here is `/dev/mapper/luks-eff2...` and not `diskimg.img`.
Steven avatar
gb flag
I get an error for bad super block, did e2mkfs to find bad superblocks and tried e2fsck to repair it, but it informs me it is a LUKS device... I will update in OP.
Score:0
cn flag

You need to check the errors by typing mount without arguments. So you can check if /mount is free, and/or if /dev/loop5 is mounted

Steven avatar
gb flag
Sorry, I was reediting the OP when you answered.
Steven avatar
gb flag
I have a USB I've imaged to and used that to try and find how I can mount or fix it. Unfortunately I didn't find any lines relating to the drive in question.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.