I'm asking as a new question because I don't have enough rep to comment on answers, and the drive in question here is removable.
I've set up an encrypted USB drive using cryptsetup luksFormat, but I'm having trouble mounting it on insertion as I can with other drives. After entering the correct passphrase, I seem to be encountering the same error as in this question.
However, the solution given there doesn't seem to be effective. Here are the results of a few tests based on the method (the UUID of the /dev/mapper file is replaced with $uuid):
$ sudo cryptsetup luksOpen /dev/sdb foo
Enter passphrase for /dev/sdb:
Cannot use device /dev/sdb which is in use (already mapped or mounted).
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 ... 0 disk
├─sda1 8:1 0 ... 0 part ...
└─sdaN 8:N 0 ... 0 part ...
sdb 8:16 1 ... 0 disk
└─luks-56a33913-5f65-48e9-8e6e-db1f72605b24 253:0 0 ... 0 crypt
$ ls -l /dev/mapper/
total 0
crw------- 1 root root 10, 236 Aug 17 07:46 control
lrwxrwxrwx 1 root root 7 Aug 17 10:48 luks-$uuid -> ../dm-0
$ sudo vgimportclone /dev/mapper/luks-$uuid
Failed to find physical volume "/dev/mapper/luks-$uuid".
Failed to find all devices.
I suspect the same error is arising from different circumstances.
For additional context, I have multiple encrypted USB devices that I've set up through the same port, so they appear as the same physical device (/dev/sdb), and are both being mapped to /dev/dm-0. Maybe that's causing some confusion?
Can anyone identify the root cause of the issue, and point me towards an effective solution?