Linux Verschlüsselung mit LUKS

Index

Partition sicher verschlüsseln

  1. Partition mit Zufallsdaten füllen

    dd if=/dev/urandom of=/dev/sd[a-z][1-9] bs=2048 status=progress
    oder schneller mit
    mkfs.[ext2,ext3,ext4,xfs,btrfs,reiserfs,jfs] /dev/sd[a-z][1-9]
    mount /dev/sd[a-z][1-9] /mnt/tmp
    openssl enc -aes-256-ctr -pass pass:"$(dd if=/dev/urandom bs=128 count=1 2>/dev/null | base64)" -nosalt < /dev/zero > /mnt/tmp/randomfile.bin
    umount /mnt/tmp 
    oder, wenn fio installiert ist
    fio -name="fill" -ioengine=libaio -direct=1 -bs=512m -rw=write -iodepth=4 -size=100% -filename=/dev/sdx2

  2. Formatieren

    cryptsetup -c aes-xts-plain64 -s 512 luksFormat /dev/sd[a-z][1-9]

  3. Verschlüsselte Partition öffnen

    cryptsetup luksOpen /dev/sdx2 luksVol

  4. Schlüsseldatei hinzufügen

    cryptsetup luksAddKey /dev/sdx2 /path/to/key_file
    mkinitrd.conf
    LUKSKEY="LABEL=XXX:/keys/xxx"