1

I'm having problems unlocking an encrypted hard drive that has been working previously for well over a year. I'm sure the password is correct.

I found one post with a similar issue: LUKS encrypted drive will not accept password. Not sure if they ever got it resolved.

I'm running Ubuntu 18.04. The exact error is: Error unlocking /dev/sdc: Failed to activate device: File exists (udisks-error-quark, 0)

Edit: This error appeared regardless of whether the password was entered correctly or not.

Not sure what could have caused this to happen, never had anything like it happen before. Thank you for any help.

3 Answers3

1

So I tried to unlock the hard drive again, after reading that sometimes the problem resolves itself, and this time it unlocked without any problems.

I noticed that this time if I entered the wrong password, the error would read: Error unlocking /dev/sdb: Failed to activate device: Operation not permitted (udisks-error-quark, 0)

I'm not sure what could have caused this in the first place but it's resolved, at least for now.

0

In my case this was because I had some shell session (bash) that where still in folders of the previously mounted drive.

That is, say it was mounted on /media/alex/my-disk, I had a shell session still in /media/alex/my-disk/my-folder.

After killing this session, I was able to mount the disk.

Destroy666
  • 12,350
0

This happens when a running process is already using the LUKS device you're trying to mount. Often that happens if you've mounted the disk before, and it wasn't unmounted cleanly.

To solve this, you need to kill those processes. Obviously rebooting will kill them. Short of that, you can find the process IDs if you know the name of the LUKS device.

The command dmsetup ls will tell you the names of all connected logical devices. For example,

$ sudo dmsetup ls
luks-322c112e0-bfdf-4d10-9fe7-00eaba281805       (253:4)
nvme0n1p3_crypt (253:0)
womble--vg-home      (253:3)
womble--vg-root      (253:1)
womble--vg-swap_1    (253:2)

So there's our LUKS device, with device number 253:4. You can then grep for that number in the output of lsof, but remember to replace the colon with a comma:

$ sudo lsof|grep 253,4
bash      358678                          marnanel  cwd       DIR              253,4      4096          2 /

$ ps aux|grep 358678 marnanel 358678 0.0 0.0 9772 6168 pts/7 Ss+ Feb25 0:00 /bin/bash marnanel 465840 0.0 0.0 6336 2120 pts/8 S+ 00:37 0:00 grep 358678

There you are-- it's process 358678, a bash shell.