How to close a LUKS mounted image-file without ' Device ... is still in use' - need to wait maybe 15 minutes


Recommended Posts

I'm running unraid 6.12.4.
This is likely not unRaid specific, but I don't know.

TLDR: I can mount a LUKS drive but sometimes when on luksClose it won't close, but so far waiting 15 minutes helps.

I tried creating a LUKS encrypted file using this guide:

https://blog.tian.it/create-encrypted-luks-sparse-file/

When I unmount the mounted filesystem and then try to close the LUKS using

```
umount /cryptoarchive/stuff
cryptsetup luksClose "/dev/mapper/stuff"
```

then I get the following error:

```
Device /dev/mapper/stuff.img is still in use.
```

Running `df` I can see the unmount worked, and also the `umount` didn't fail. `lsof` shows me that the loop-device file is (of cause) still in use, but no files on the mounted dir `/cryptoarchive/stuff` is shown .

Once after waiting an hour or so, I tried remounting and then umounting immediately afterwards, and that one time luksClose succeeded. I have shared the mount point via samba, but as mentioned umount works.

I have attached my mount and unmount scripts.


Thx, Alex

 

 

luks-unmount.sh

luks-mount.sh

Edited by Alex R. Berg
Link to comment
  • Alex R. Berg changed the title to How to close a LUKS mounted image-file without ' Device ... is still in use' - need to wait maybe 15 minutes

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.