Tag Archiv für LUKS

Encrypt external HDD / flash drive with dm-crypt & LUKS

To encrypt the whole HDD or only one partition on an internal or external drive, there is always the same procedure. I have tested the following steps on an Arch Linux with systemd and GRUB2 running.

1. Find the correct device (eg. /dev/sdb1 as a second interal SATA-HDD):


2. Consider overwriting your old or even new device. Find some hints in the Arch wiki.

3. Create the partitions you need. If you want to encrypt the whole disk, create only one big partiton using the whole space.


or whatever you prefer.

4. Encrypt the partition using LUKS, for example with AES 256 bit keylength:

cryptsetup -c aes-xts-plain64 -y -s 512 luksFormat /dev/sdXY

5. Open it, so it will be in /dev/mapper/mycryptedhdd:

cryptsetup luksOpen /dev/sdXY mycryptedhdd

6. Set up a filesystem on it:

mkfs.ext4 /dev/mapper/mycryptedhdd

7. Test mounting:

mount /dev/mapper/mycryptedhdd /mnt/
df -h

8. umount and close container:

umount /mnt/
cryptsetup luksClose /dev/mapper/mycryptedhdd

Automount encrypted HDDs with LUKS on bootup

1. Add a new line in /etc/crypttab (man crypttab) to encrypt and open it under /dev/mapper/mycryptedhdd during bootup. (This equals the manual step 5 form above):

mycryptedhdd	UUID=00000000-0000-0000-0000-000000000000	none	tries=3

Field 1: Choose a name for your LUKS container
Field 2: Identify the disk / partition you want to open (find your UUID with: $ blkid /dev/sdXY, or enter the path like /dev/sdXY)
Field 3: Path to the keyfile, or „none“ if you only use passwords
Field 4: Write your password wrong this often

2. Add a new line in /etc/fstab (man fstab) to automatically mount the LUKS container generated by crypttab:

/dev/mapper/mycryptedhdd		/mnt/tv      ext4        defaults    0   2

Field 1: Path to the LUKS container you created with the crypttab
Field 2: Path to the folder you want your LUKS container to be mounted to (folders must exist)
Field 3: Used filesystem (the one you used above in step 6)
Field 4, 5, 6: rtfm (man fstab) or trust the values I used

3. That’s all. Consider using keyfiles or take a look at PasswordAgents if you start hating to type your password ;)

Arch Linux installation with full disk encryption using LVM, LUKS and GRUB2

This is gonna be a „quick“ walk-through on how to install Arch Linux with a nearly (/boot won’t be) fully encrypted HDD.
I have tested this guide with the archlinux-2012.09.07-dual.iso which uses systemV and archlinux-2012.10.06-dual.iso which was the first one using systemd, so this tutorial covers both init daemons.

Update: This article got translated to Swedish. Thx Sam!

The tutorials I found were all outdated or caused problems because of one of the following:

  • The former included Arch Linux Installation Framework (AIF) executed by /arch/setup is no longer included in the Arch Linux-isos, the command will only respond with: „no such file or directory“.
  • GRUB2 replaces GRUB legacy and needs to be configured differently.
  • The keyboard layout didn’t fit to mine so i got some problems entering my passphrase;)

Let’s start…

Arch Linux Logo

Arch Linux Logo from archlinux.org/art/