0

I have a device that is encrypted using dm-crypt. This is a mini SD card that I use on my laptop.

I've had some issues with my laptop freezing recently, and in the journal these messages come up:

Mar 20 17:18:30 gorgonzola kernel: EXT4-fs (dm-0): warning: mounting fs with errors, running e2fsck is recommended
Mar 20 17:18:30 gorgonzola kernel: EXT4-fs (dm-0): recovery complete
Mar 20 17:18:30 gorgonzola kernel: EXT4-fs (dm-0): mounted filesystem with ordered data mode. Opts: (null)
...
Mar 20 17:23:30 gorgonzola kernel: EXT4-fs (dm-0): error count since last fsck: 84
Mar 20 17:23:30 gorgonzola kernel: EXT4-fs (dm-0): initial error at time 1505289981: ext4_journal_check_start:60
Mar 20 17:23:30 gorgonzola kernel: EXT4-fs (dm-0): last error at time 1551543757: ext4_reserve_inode_write:5903: inode 1054920: block 4194732

I have tried running fsck, but I get this error:

Bad magic number in super-block

Before attempting to resolve this, I just want to make sure that I should indeed be able to run fsck on a dm-encrypted drive. Or is this error expected? The reason why I am mystified is because I can mount this device just fine. For all intents and purposes, the drive works well. It mounts, it can read and write all data... the only problem is that I get this error at boot. So is there really a problem with the super block?

1

Are you trying to run fsck on the /dev/sd* (or whatever) device that refers to the actual SD or its partition, just like on an unencrypted device?

If so, that device is fully encrypted, and that's why fsck cannot make any sense of it at all. If it found anything recognizable as a filesystem, that would be a sign of dm-crypt not working: the encrypted data is supposed to look like nondescript pseudorandom noise.

You need to point the fsck to the dm-crypt target, which will probably be named /dev/mapper/<something>. And that requires using cryptsetup to open the encrypted device first, just like when preparing to mount the encrypted device, before trying to run fsck on it. Since dm-crypt has several possible modes, I cannot suggest a correct cryptsetup command without knowing more about your setup. Perhaps your /etc/crypttab file might contain the necessary details?

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.