Skip to content

Instantly share code, notes, and snippets.

@fawkesley
Created January 11, 2019 10:51
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fawkesley/a7f1782d371ef4b53eb4df19218f317b to your computer and use it in GitHub Desktop.
Save fawkesley/a7f1782d371ef4b53eb4df19218f317b to your computer and use it in GitHub Desktop.
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