Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 705014 - Cannot close LUKS device while emerge is running
Summary: Cannot close LUKS device while emerge is running
Status: UNCONFIRMED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-01-08 23:30 UTC by phkb
Modified: 2022-11-22 07:39 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description phkb 2020-01-08 23:30:26 UTC
I have an external HDD which is LUKS-encrypted. When a emerge command is running, I cannot "cryptsetup close" the mapper, even if the underlying partition is unmounted. cryptsetup says the device is busy. Killing the emerge process, although completely unrelated to the external drive, enables closing the mapper.

I hit this bug several times, also with older versions of portage, but I cannot say if it's consistently reproducible. What I did in this case was:

1) Mount the external drive
# cryptsetup open /dev/sdXN exthdd
# mount /dev/mapper/exthdd /media/exthdd
Then, start stuff on the external drive (eg. copy files)

2) Start an emerge command, in another root terminal, unrelated to 1)
emerge -a some/package

3) Unmount the external drive, when 1) is done, but the emerge in 2) is still running
# unmount /media/exthdd
(works, partition is really unmounted at this point)
# cryptsetup close exthdd
-> error, device is busy
If I kill the emerge command started in 2), then cryptsetup close works.
Comment 1 Zac Medico gentoo-dev 2020-01-09 00:07:29 UTC
Since portage does not have any direct interaction with devices like this, I don't know how to explain the correlation that you've observed.

Maybe you can get a clue from a tool like lsof.

Also, the output of this command might have a clue:

dmsetup info -C
Comment 2 phkb 2020-01-10 14:11:09 UTC
Thanks for your reply. I redid an experiment to run the commands you mentioned, and was able to reproduce the bug.

# cryptsetup open /dev/sdb2 exthdd
# mount /dev/mapper/exthdd /media/exthdd
# emerge -a firefox

I let that running (this rebuilds firefox which takes a long time).
In another terminal:

# umount /media/exthdd
# dmsetup info -C
Name             Maj Min Stat Open Targ Event  UUID
exthdd           253   1 L--w    1    1      0 CRYPT-LUKS1-d7a6aa075503420e8e8336e7ff28de97-exthdd
root             253   0 L--w    1    1      0 CRYPT-LUKS1-9bd4c21747d7497c90f004fcb05a208d-root
# lsof /dev/mapper/exthdd
(no output)
# cryptsetup close exthdd
Device exthdd is still in use.

Then I kill the emerge command.

# dmsetup info -C
Name             Maj Min Stat Open Targ Event  UUID
exthdd           253   1 L--w    0    1      0 CRYPT-LUKS1-d7a6aa075503420e8e8336e7ff28de97-exthdd
root             253   0 L--w    1    1      0 CRYPT-LUKS1-9bd4c21747d7497c90f004fcb05a208d-root
# lsof /dev/mapper/exthdd
(still no output)
# cryptsetup close exthdd
(works)
Comment 3 Alexander Tsoy 2020-01-13 10:05:05 UTC
Have you enabled FEATURES=mount-sandbox? Maybe your external drive is still mounted inside namespace?
Comment 4 phkb 2020-01-18 05:09:54 UTC
Thanks for the suggestion. I did not have it enabled, so I enabled it in make.conf and retried. But I still get the same error and command outputs as above.
Comment 5 Mike Gilbert gentoo-dev 2020-01-18 19:11:21 UTC
mount-sandbox is enabled by default. As well, if pid-sandbox is enabled we also create a new mount namespace.

Please disable both features and see if that makes a difference.

FEATURES="-mount-sandbox -pid-sandbox"
Comment 6 phkb 2020-01-25 23:34:14 UTC
This seems to work, thanks. I'm not sure I'll keep this configuration, though (as these seem important things to enable).
Comment 7 Francesco Turco 2022-11-22 07:39:29 UTC
The following thread from the Gentoo forums is probably related to
this bug: https://forums.gentoo.org/viewtopic-t-1116050.html