13

I've got an external USB drive with an encrypted LUKS partition. I generally have no problems mounting the device; I click it from the xfce4 desktop and get a dialog where I enter the password.

When I try to mount the drive now, I type in the password and get the error:

Error unlocking /dev/sdc1: Command-line `cryptsetup luksOpen "/dev/sdc1" "luks-..."' exited with non-zero exit status 5: Device luks-... already exists

What do I need to do in order to mount the drive? Is it somehow corrupted? How can the device already exist if it's not mounted (and wasn't plugged in until a short time ago)?

Pointy
  • 1,623

3 Answers3

18

Yes, this happens when luks encrypted device was not cleanly deactivated with cryptsetup close.

You can try to remove the mapping using

dmsetup remove /dev/mapper/luks-... if you want to avoid rebooting.

6

From my side, when it happened the dmsetup remove /dev/mapper/luks- command didn't work due to the fact that the specified mapped disk is no more present under /dev/mapper ...

So I had to manually close the old mapping with:

cryptsetup luksClose /dev/sdxx /dev/mapper/luks-...

(where sdx correspond to the luks partition you have identified with fdisk -l

3

This one worked for me (change sde1 with your disk label):

sudo cryptsetup luksOpen /dev/sde1 lukslvm

Ikrom
  • 183