Using fsck to check and repair LUKS encrypted disk?

Solution 1:

The exact method depends on how you have setup luks, and if you have LVM on top of luks or if you just have a filesystem within the luks volume.

If you don't have LVM in addition to luks then you would probably do something like this.

cryptsetup luksOpen /dev/rawdevice somename
fsck /dev/mapper/somename

# or

cryptsetup luksOpen /dev/sda2 _dev_sda2
fsck /dev/mapper/_dev_sda2

If you used the LVM on LUKS option providied by the Debian/Ubuntu installer, then you'll need to start up LVM. So vgchange -aly after opening the encrypted volume, then run fsck against the /dev/mapper/lvname.

(If commands are missing, you may need to do apt-get install cryptsetup first. Similarly if you need vgchange do apt-get install lvm.)

Solution 2:

You need to open the LUKS volume first.

cryptsetup luksOpen /dev/(whatever) someName

This'll ask you for the password, then create /dev/mapper/someName, which is the plaintext device that you can run fsck on. When you're done,

cryptsetup luksClose someName

will remove the /dev/mapper/someName plaintext device, .

Tags:

Linux

Fsck

Luks