4

I notice that if a device mapping is created with the low-level dmsetup or through ioctls, the device mapping will no longer be there after reboot.

  1. Is this normal? I am using a USB to test out dm_crypt
  2. If it is normal, how do I go about making the mapping stay around? Do I need to look into udev?

Thanks!


Edit for clarification

What I mean by device mapping is the table entry that specifies how to map each range of physical block sectors to a virtual block device. You can see what I mean, if using LVM, with the dmsetup table command. This will dump all current device table mappings. Here's an example for the device mapping linear target, tying two disks together into a LVM swap (physical block abstraction):

vg00-lv_swap: 0 1028160 linear /dev/sdb 0
vg00-lv_swap: 1028160 3903762 linear /dev/sdc 0

The format here is:

<mapping_name>: <start_block> <segment_length> <mapping_target> <block_device> <offset> 

Where:

  • mapping_name: the name of the virtual device
  • start_block: starting block for virtual device
  • segment_length: length in sectors (512 byte chunks)
  • mapping_target: device mapping target such as linear, crypt, or striped
  • block_device: which physical block device to use, in this case defined by major:minor
  • offset: offset on physical block device

My problem is that, after creating a new entry in the device mapping table, it disappears after boot. That is, running something like:

dmsetup create TestEncrypted --table "0 $(blockdev --getsz /dev/sdb) crypt serpent-cbc-essiv:sha256 a7f67ad...ee 0 /dev/sdb 0"

and then rebooting causes the mapping table entry to disappear (i.e. doesn't show up with dmsetup table), as well as the corresponding /dev/mapper/TestEncrypted

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
Zomp
  • 117
  • 1
  • 7
  • Don't know but for discs UUID works. Hope that gives you a lead. I am not familiar with other device mapping. – mongo Apr 27 '17 at 01:42

1 Answers1

3

Not 100% I understand what you mean by mapping but, Yes this seems normal. You need to add the device to either /etc/crypttab or /etc/fstab like you would to mount any other drive.

https://wiki.archlinux.org/index.php/Dm-crypt/System_configuration#crypttab

^ Should have the information you're looking for.

Livinglifeback
  • 1,586
  • 10
  • 16
  • Thanks for the recommendation! Idk how I missed this when googling myself. I'll give it a read and see if it can address my problems. I also edited my post for clarity. – Zomp Apr 27 '17 at 19:16