|
| |||
|
|
Linux: How to remove a stuck LUKS device Linux provides an easy way of mounting encrypted external disks: if they are formatted using LUKS, they are auto-mounted, with the passphrase stored in the login keyring. However, it sometimes happens that a LUKS encrypted volume or device is mounted and then not cleanly unmounted. This can happen when the system goes into sleep mode, or when power is cut to the external device, or when too many USB devices are connected to one USB slot via hubs. The result is that the LUKS disk(s) cannot be automatically mounted any more through the GUI file manager. The system starts to ask you again for the passphrase, which is a warning sign (it normally does not), and the filesystem cannot be mounted anyway. The error message is "device already exists" (although it is not so). Disconnecting the device from USB does not help. The reason is that the LUKS volume is still mounted, and usually cannot be automatically unmounted since there are still some applications using it. A reboot certainly helps, but is an overkill. Finally I found a recipe for solving this problem. https://askubuntu.com/questions/429612/d - find the mounted LUKS devices: $ sudo dmsetup ls - for each device, do a status check to see if the device is actually present. The problematic devices are shown as "device: (null)". $ sudo cryptsetup status luks-62395621-8c1a-f1e2-b3c1-914c2ca4d882 - try closing the LUKS volume. $ sudo cryptsetup close luks-62395621-8c1a-f1e2-b3c1-914c2ca4d882 If this fails with "Device busy", go to the next step. If this succeeds, you can mount the volume again using the GUI file manager. - determine which processes hold open files on these devices. Note the numbers "253:6" printed before by "dmsetup ls". Use these numbers with a comma to do this grep:
So, "evince" with PID 8635 is holding an open file on this volume. Close it or kill it.
Repeat the "sudo lsof | fgrep 253,6" and close all processes that hold open files on that device. After that, do "dmsetup remove luks-..." again, and it should work. Now you can mount the devices automatically again. |
||||||||||||||