LUKS Partition – Error Unlocking a LUKS Partition (Failed to Activate Device)

dolphinkdeluksmount

I'm having problems unlocking a luks-encrypted disk with KDE dolphin, in a system with manjaro.

The issue is not critical. It can be solved by rebooting, but sometimes it is not convenient to do so, and I find that it might be useful to understand why this problem appears in the first place.

So the first time I unlock the device after a reboot everything is fine. If I unmount the system, next times will also be ok. The problem is that sometimes, I connect the device, and after entering the password I get the following error:

An error occurred while accessing 'Home', the system responded: The requested operation has failed: Error unlocking /dev/sdxy: Failed to activate device: File exists

But this file cannot be seen with df -h, and it is not mounted via /etc/fstab, it is always mounted and unlocked when connected. The command fuser won't show anything relevant, and lsof only returns:

lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1000/gvfs
      Output information may be incomplete.
lsof: WARNING: can't stat() fuse file system /run/user/1000/doc
      Output information may be incomplete.

In fact, I see some processes using this folder (ps aux | grep 1000), but do not know whether this actually helps to solve the problem.

1779 ?        Sl     0:03 /usr/lib/gvfsd-fuse /run/user/1000/gvfs -f -o big_writes
1847 ?        S      0:03 file.so [kdeinit5] file local:/run/user/1000/klaunchermRxLKs.1.slave-socket local:/run/user/1000/kded5IKggHu.1.slave-socket
23434 ?        S      0:00 file.so [kdeinit5] file local:/run/user/1000/klauncherDwiyfV.1.slave-socket local:/run/user/1000/dolphinaVwzoi.58.slave-socket

I suspect killing these processes might help, but do not know if it's safe (cannot risk to do so right know, not without knowing). Any ideas?

EDIT: Output for dmsetup info and dmsetup table:

dmsetup info

Name:              luks-92bde790-5ca6-441b-bad3-5c3163292c8b
State:             ACTIVE
Read Ahead:        256
Tables present:    LIVE
Open count:        0
Event number:      0
Major, minor:      254, 1
Number of targets: 1
UUID: CRYPT-LUKS1-92bde7905ca6441bbad35c3163292c8b-luks-92bde790-5ca6-441b-bad3-5c3163292c8b

Name:              luks-1f919383-2d4a-44e2-b28e-21bffd11dd6c
State:             ACTIVE
Read Ahead:        256
Tables present:    LIVE
Open count:        1
Event number:      0
Major, minor:      254, 0
Number of targets: 1
UUID: CRYPT-LUKS1-1f9193832d4a44e2b28e21bffd11dd6c-luks-1f919383-2d4a-44e2-b28e-21bffd11dd6c

dmsetup table

luks-92bde790-5ca6-441b-bad3-5c3163292c8b: 0 4294963200 crypt aes-xts-plain64 0000000000000000000000000000000000000000000000000000000000000000 0 8:33 4096
luks-1f919383-2d4a-44e2-b28e-21bffd11dd6c: 0 3906401473 crypt aes-xts-plain64 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0 8:2 4096

Best Answer

If, after looking at the output of dmsetup ls you find that you have stale devices you can remove them with dmsetup remove – ideally after carefully verifying that the device is indeed not in use.

I had the same problem and after doing so I was able to unlock and mount my encrypted USB hard disk again:

# dmsetup ls --tree
luks-f53274db-3ede-4a27-9aa6-2525d9305f94 (254:5)
 `- (8:34)

# ls -l /dev/mapper/
total 0
crw------- 1 root root 10, 236 Nov 24 15:22 control
lrwxrwxrwx 1 root root       7 Nov 27 09:42 luks-f53274db-3ede-4a27-9aa6-2525d9305f94 -> ../dm-5

# dmsetup remove /dev/dm-5
Related Question