Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Raid-1 + LUKS encrypted filesystem

make encrypted luks partition on raid-1 array from free space

  • use cfdisk /dev/sda to create a new partition in free space with type "Linux RAID"
  • repeat for /dev/sdb
  • cat /proc/mdstat to see what /dev/mdX device is next
$ mdadm --create --verbose /dev/md4 --level=1 --raid-devices=2 /dev/sda6 /dev/sdb6

Now /dev/md4 is a block device

setup luks mapper

$ fdisk -l
$ cryptsetup -y -v luksFormat /dev/md4

[ type an encryption password ]

$ cryptsetup luksOpen /dev/md4 cryptodisk

^^ creates /dev/mapper/encrypted

mkfs.ext4 /dev/mapper/cryptodisk
mkdir -p /mnt/cryptodisk
mount /dev/mapper/cryptodisk /mnt/cryptodisk

mount

$ cryptsetup luksOpen /dev/ cryptodisk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.