0

I have a little problem using an encrypted physical volume from an external usb3 disk encloser.

This is the situation:

  1. I put a sata hard disk into the disk case and plugin the usb3 cable to my laptop, running linux.
  2. Now I do a cryptsetup open --type plain with a stored key. I'm save to use plain, because I know how not to loose keys, so luks is not needed here.
  3. The cryptsetup introduces a new device /dev/mapper name for the device manager.
  4. After using the device some time, why ever, the usb3 disconnects and reconnects again. The kernel introduces a new /dev/sdX drive letter for the disk now (currently it switches between /dev/sdb and /dev/sde). (Of course I used /dev/disk-by-uuid/ to have a constant location to read in the disk, but within dm-crypt the device is linked to the /dev/sdX device:
/dev/mapper/sec-2019-feb is active and is in use.
  type:    PLAIN
  cipher:  aes-cbc-essiv:sha256
  keysize: 256 bits
  key location: dm-crypt
  device:  (null)
  sector size:  512
  offset:  0 sectors
  size:    1714844033 sectors
  mode:    read/write

Now the device: entry in the dm-crypt module is (null), which is the root of evil, I guess!

I also get dmesg errors like this:

[ 4440.280478] EXT4-fs warning (device dm-1): htree_dirblock_to_tree:997: inode #2: lblock 0: comm bash: error -5 reading directory block
[ 4440.392495] EXT4-fs warning (device dm-1): htree_dirblock_to_tree:997: inode #2: lblock 0: comm bash: error -5 reading directory block
[ 4441.208683] EXT4-fs warning (device dm-1): htree_dirblock_to_tree:997: inode #2: lblock 0: comm ls: error -5 reading directory block
[ 4444.307065] EXT4-fs warning (device dm-1): htree_dirblock_to_tree:997: inode #2: lblock 0: comm ls: error -5 reading directory block
  1. When I now try to restart the disk, the name is in use and I cannot remap it to a new device.

I haven't tried a new name for the device. That might be possible, but such approaches will very likely fail, as pending disk writes will never be executed, if there are any.

How do I stop a USB drive from being assigned to a new /dev/sdX letter or how can I tell dm-crypt that the device letter changed or is there any other way to requeue calls moving through dm-crypt to the new device slot?

2
  • 1
    You may be able to force the name of the device using udev rules. But what about fixing the problem with the USB3 connection? The Linux device mapper (the "dm" in "dm-crypt") has "multipath" which can be used for situations where the connection to a storage device breaks, but I don't think it works with USB devices. Commented Oct 17, 2019 at 14:20
  • Thank you! The next day when I used the drive, I managed to stabilize the connection. As far as I know, you are not able to force the original kernel name /dev/sda for example for a drive. I think that is purpose of a bios / bootloader mapping (drive order). Your comment makes me thinking about turning the question into a project, though.
    – ikrabbe
    Commented Oct 25, 2019 at 7:16

0

You must log in to answer this question.

Browse other questions tagged .