1

I need turn a file into a encrypted device mapped on /dev/mapper/ and to do it the easier way I found is adding a named entry to /etc/crypttab pointing to image file and key file, it works fine and map the device but only on next reboot.
Im doing it on an automated way by an scrpt and want do the mapping and formatting the mapped device with filesystem on the same script but the device arent available on the first run of my script.

There is a way to execute the crypttab mapping from command line without reboot ?

Is possible execute crypttab config without rebooting making the encrypted device mapped and available ?

Would be nice execute the mapping from command line without reboot otherwise I will need send two scripts one to map the encrypted device and another to setup the filesystem after reboot.

Mark
  • 71
  • 1
  • 6
  • You could just call `cryptsetup` yourself. You already have all the necessary details. – Michael Hampton May 09 '19 at 00:02
  • @Michael Hampton , It is to be a swap partition and was trying using cryptsetup but i need it being mounted on every boot on same and the script was getting big and complex, also is necessary on this method an entry on rc.local and crypttab automate it all, thanks for the help and attention. – Mark May 09 '19 at 00:06

1 Answers1

2

As you can see here:

Taking as example the following crypttab entry:

myDesiredMappedDeviceName /home/myuser/myfolder/myfile.img /home/myuser/myfolder/mykeyfile swap,offset=1024,cipher=aes-xts-plain64

You can trigger crypttab with command:

cryptdisks_start myDesiredMappedDeviceName  

And will see the mapped device as:

/dev/mapper/myDesiredMappedDeviceName

Someone told it only works on Debian and debian derivatives.

If using this command take care with it too.

Mark
  • 71
  • 1
  • 6
  • After pointing swap on /etc/fstab to this mapped device gettting error: "WRITE ERROR ON SWAP DEVICE" on boot, I will search to fix it – Mark May 09 '19 at 02:23
  • The problem was not related with crypttab itself but with the created image file as you can see here: https://serverfault.com/q/966638/514993 – Mark May 09 '19 at 21:56