Skip to content

Navigation Menu

Sign in
Sign up

Unable to remove loop: loop0 is still in use #519

franzos started this conversation in General
Discussion options

Hello everyone,

Every since I started using tomb, I have been having trouble removing the mount cleanly. After running tomb close I'm always left with a loop0 which prevents the tomb from mounting again.

This issue only occurs with the tomb I use on daily basis (and which many apps access to, and rely on) - not a throw-away tomb I may create for testing. What's odd is, that the tomb does unmount properly, but the loop0 is not removed.

Here's what this looks like after closing the tomb:

losetup --all
/dev/loop0: [64768]:19669748 (/home/franz/.d-crate.tomb)

Trying to remove it fails:

cryptsetup luksClose tomb..d-crate.b270c234643e0931cd63bca461cb7f3c759a8f85809f8ff3c7bb401a5f7c2b20.loop0
Device tomb..d-crate.b270c234643e0931cd63bca461cb7f3c759a8f85809f8ff3c7bb401a5f7c2b20.loop0 is still in use.

It looks like someone's accessing it:

dmsetup info -c tomb..d-crate.b270c234643e0931cd63bca461cb7f3c759a8f85809f8ff3c7bb401a5f7c2b20.loop0
Name Maj Min Stat Open Targ Event UUID
tomb..d-crate.b270c234643e0931cd63bca461cb7f3c759a8f85809f8ff3c7bb401a5f7c2b20.loop0 253 1 L--w 1 1 0 CRYPT-LUKS1-1b8ed227fda04fb6a898fbd87c657220-tomb..d-crate.b270c234643e0931cd63bca461cb7f3c759a8f85809f8ff3c7bb401a5f7c2b20.loop

I've tried a lot of things; Only reboot works.

Here's some more info:

uname -a
Linux panther 6.9.6 #1 SMP PREEMPT_DYNAMIC 1 x86_64 GNU/Linux
franz@panther ~$ tomb --version
 Tomb 2.9.0 - a strong and gentle undertaker for your secrets
 Copyright (C) 2007-2021 Dyne.org Foundation, License GNU GPL v3+
 This is free software: you are free to change and redistribute it
 For the latest sourcecode go to <http://dyne.org/software/tomb>
 This source code is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 When in need please refer to <http://dyne.org/support>.
 System utils:
main:318: command not found: zsh
 Sudo version 1.9.14p3
 cryptsetup 2.3.7
 pinentry-gtk2 (pinentry) 1.2.1
 findmnt from util-linux 2.37.4
 gpg (GnuPG) 2.2.39 - key forging algorithms (GnuPG symmetric ciphers):
 IDEA 3DES CAST5 BLOWFISH AES AES192 AES256 TWOFISH CAMELLIA128 CAMELLIA192 CAMELLIA256
 Optional utils:
 /gnu/store/amhk3vjn6npgb5qh6xb2g2nqb4fzyqar-gettext-minimal-0.21/bin/gettext
 dcfldd not found
 /gnu/store/9v9xjn6lvmavsqbsfr0s22ydmzldzq85-coreutils-9.1/bin/shred
 /gnu/store/jg90sh9cy35va656x2773kkl0rqfi9sb-steghide-0.5.1/bin/steghide
 /gnu/store/3r5a91mwgvg7np8773z2brgjv604skd8-e2fsprogs-1.47.0/sbin/resize2fs
 tomb-kdb-pbkdf2 not found
 /gnu/store/0csa6dgrn9sb62pxs21yn5a9nq16017q-qrencode-4.1.1/bin/qrencode
 swish-e not found
 unoconv not found
 /gnu/store/6nyp9cvksvyfww5d7j7rvm43jb46p521-lsof-4.94.0/bin/lsof

Any idea how I can:

  1. Figure out why the loop is in use (and by whom)?
  2. Remove the loop without rebooting?

Cheers

You must be logged in to vote

Replies: 1 comment 4 replies

Comment options

What I noticed from the output: Although tomb is a ZSH shell script you don't have zsh installed?
And regarding the first question: Did you check the loop device with lsof?

You must be logged in to vote
4 replies
Comment options

Although tomb is a ZSH shell script you don't have zsh installed?

Not sure why tomb --version cannot find zsh as it works as expected otherwise (minus my trouble with loop0).
Even though I don't have zsh installed directly, the tomb package provides zsh as dependency so it should be available.

Did you check the loop device with lsof?

Yes, this was one of my first steps. It doesn't return anything, hence my confusion. I should have probably mentioned this.

I originally thought it may be related to my bind-hooks, but they are all removed properly when I do tomb close.

$ tomb list
.tomb-real . [.d-crate] open on /media/.d-crate using (rw,nodev,noatime)
.tomb-real . [.d-crate] open since Sat 06 Jul 2024 06:48:01 PM WEST
.tomb-real . [.d-crate] open by franz from /dev/pts/0 on panther
.tomb-real . [.d-crate] size 270M of which 48M (19%) is used: 203M free
.tomb-real . [.d-crate] hooks /home/franz/.ssh
.tomb-real . [.d-crate] hooks /home/franz/.aws

I read somewhere that the kernel itself may be keeping the loop busy, but I'm not too familiar with this.

Comment options

Narrat Jul 10, 2024
Collaborator

Odd with zsh. No real magic involved. The script only invokes zsh --version. Is it available in $PATH?
After closing the tomb, does losetup -d <loopdevice> or losetup -D remove the loop device?
And can you maybe post a full open and close cycle of tomb with the debug output option -D? Do you have after a reboot automatically a loop device? It's odd if tomb can setup a loop device but doesn't get around to remove it in the endgame.

Comment options

Narrat Jul 10, 2024
Collaborator

Oh, and what distribution is at work? I noticed that the found programs are relatively old. Maybe tomb has something in place which isn't available for you. Something we may need to consider.

Comment options

Odd with zsh. No real magic involved. The script only invokes zsh --version. Is it available in $PATH?

This is how tomb runs:

which tomb
/home/franz/.guix-home/profile/bin/tomb
#!/gnu/store/v9p25q9l5nnaixkhpap5rnymmwbhf9rp-bash-minimal-5.1.16/bin/bash
export PATH="/gnu/store/hp1wfjq5vpnyhc23fgnqzl1kvjhpixw5-mlocate-0.26/bin:/gnu/store/9v9xjn6lvmavsqbsfr0s22ydmzldzq85-coreutils-9.1/bin:/gnu/store/3r5a91mwgvg7np8773z2brgjv604skd8-e2fsprogs-1.47.0/sbin:/gnu/store/8bcrzzbl8c1wdr8awkd7mirm949227lp-pinentry-1.2.1/bin:/gnu/store/llpxyyym3nvp2d8iny34m7z1b7dqgwpk-gnupg-2.2.39/bin:/gnu/store/zfymrgmxa7r3g59s8gisjzy3zr0fz342-cryptsetup-2.3.7/sbin:/gnu/store/amhk3vjn6npgb5qh6xb2g2nqb4fzyqar-gettext-minimal-0.21/bin:/gnu/store/6nyp9cvksvyfww5d7j7rvm43jb46p521-lsof-4.94.0/bin:/gnu/store/0csa6dgrn9sb62pxs21yn5a9nq16017q-qrencode-4.1.1/bin:/gnu/store/jg90sh9cy35va656x2773kkl0rqfi9sb-steghide-0.5.1/bin:/gnu/store/wgfvgbd0yayl77zpkc10ibc5g78accgm-util-linux-2.37.4/bin:/gnu/store/ln6hxqjvz6m9gdd9s97pivlqck7hzs99-glibc-2.35/bin${PATH:+:}$PATH"
exec -a "0ドル" "/gnu/store/vzpnv8v7y24wlwixbzakwb0dyx18c917-tomb-2.9/bin/.tomb-real" "$@"

I guess the problem with zsh --version comes from how dependencies are handled; Currently zsh is included as package input, whereas it should probably be a propagated-inputs, so that it's included in the path.

propagated-inputs is similar to inputs, but the specified packages will be automatically installed to profiles alongside the package they belong to

Not sure I understand why it works regardless - except for this detail.

After closing the tomb, does losetup -d or losetup -D remove the loop device?

I'll have to come back to you on this again later.
As of right now, I can cleanly open / close the mentioned tomb, without any issue.

The only changes are:

  • Newer Linux kernel (6.9.8 vs 6.9.6)

Oh, and what distribution is at work?

I'm on guix.

$ guix --version
guix (GNU Guix) c1d367f57e89c3f2efd964e6d638bd89b0b1df97

I do appreciate your input on this, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants

AltStyle によって変換されたページ (->オリジナル) /