Войти в систему

Home
    - Создать дневник
    - Написать в дневник
       - Подробный режим

LJ.Rossia.org
    - Новости сайта
    - Общие настройки
    - Sitemap
    - Оплата
    - ljr-fif

Редактировать...
    - Настройки
    - Список друзей
    - Дневник
    - Картинки
    - Пароль
    - Вид дневника

Сообщества

Настроить S2

Помощь
    - Забыли пароль?
    - FAQ
    - Тех. поддержка



Пишет Journal de Chaource ([info]lj_chaource)
@ 2017-08-27 22:33:00


Previous Entry  Add to memories!  Tell a Friend!  Next Entry
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/device-mapper-remove-ioctl-on-luks-xxxx-failed-device-or-resource-busy

- find the mounted LUKS devices:

$ sudo dmsetup ls
luks-2b9d9fc43811-9fc4-42ed-b283-4cfa12d04f24 (253:3)
sda5_crypt (253:0)
luks-62395621-8c1a-f1e2-b3c1-914c2ca4d882 (253:6)

etc.


- 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  
/dev/mapper/luks-62395621-8c1a-f1e2-b3c1-914c2ca4d882 is active and is in use.
type: n/a
cipher: aes-cbc-essiv:sha256
keysize: 256 bits
device: (null)
offset: 4096 sectors

etc.


- 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:


$ sudo lsof | fgrep 253,6
evince 8635 user 15r REG 253,6 135270552 46176044 /...

etc.


So, "evince" with PID 8635 is holding an open file on this volume. Close it or kill it.


$ kill 8635


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.


(Читать комментарии) (Добавить комментарий)