Hi guys.
First, thanks a lot for OMV.
I was following this guide michaelxander.com/diy-nas till I hit "After every reboot, all encrypted drives need to be unlocked through the Web UI".
That did not seem right, if we dont trust our OS to keep LUKS key, why we trust the whole setup? Encrypting root partition is not part of this mini guide, it's a must, but will be next step. This only makes all encrypted data drives auto-unlocked, mounted and in a MergerFS pool on boot.
- these steps do not mess with /etc/fstab
- sda, sdb and sdc are data drives (data and parity). Its not where OS is installed (my OS drive is mmcblk0)
- wdkey - can be any name, as well as /etc/luks-keys (you may use /root/keyfile for example)
- assuming clean install and drives configured exactly as in michaelxander's guide (stop after doing 4.5. Create MergerFS pool).
1. generate keyfile
dd if=/dev/urandom of=/etc/luks-keys/wdkey bs=1024 count=4
chmod 0400 /etc/luks-keys/wdkey
2. add key to a LUKS slot
cryptsetup -v luksAddKey /dev/sda /etc/luks-keys/wdkey
cryptsetup -v luksAddKey /dev/sdb /etc/luks-keys/wdkey
cryptsetup -v luksAddKey /dev/sdc /etc/luks-keys/wdkey
Enter any existing passphrase:
Key slot 0 unlocked.
Key slot 1 created.
Command successful.
3. create /etc/crypttab
/etc/crypttab is read before fstab, so that dm-crypt containers can be unlocked before the file system inside is mounted.
The unlocking process will map the partitions to a new device name using the device mapper. This alerts the kernel that device is actually an encrypted device and should be addressed through LUKS using the /dev/mapper/dm_name so as not to overwrite the encrypted data.
Use blkid to get uuid (Use uuid of /dev/sdx ones, not /dev/mapper/sdx-crypt). No new line at the end.
The fist item in each line, target, "sda-crypt", must be equal to output of blkid : "/dev/mapper/sda-crypt"
vi /etc/crypttab (Content should look like this)
sda-crypt UUID=2505567a-9e27-4efe-a4d5-15ad146c258b /etc/luks-keys/wdkey luks
sdb-crypt UUID=12345678-9abc-def012345-6789abcdef01 /etc/luks-keys/wdkey luks
sdc-crypt UUID=c67c557c-21b9-11eb-82d8-170fd1bb7315 /etc/luks-keys/wdkey luks
chmod 400 /etc/crypttab
4. backup luks headers
Encryption > Select drive > Recovery > Backup
Storage > Encryption > click the device and the backup header button becomes active (thanks Pluto2010)
5. Thats it, reboot