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.
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
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)
Have you enabled FEATURES=mount-sandbox? Maybe your external drive is still mounted inside namespace?
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.
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"
This seems to work, thanks. I'm not sure I'll keep this configuration, though (as these seem important things to enable).
The following thread from the Gentoo forums is probably related to this bug: https://forums.gentoo.org/viewtopic-t-1116050.html