Create a LUKS encrypted EXT4 filesystem in a partition under GNU/Linux

NOTE: This article assumes that you have the necessary software installed from your GNU/Linux distribution.

  • Do a "su -", or do everything here as root.
  • You should have a Linux partition (hex code 83 if you use fdisk in GNU/Linux) for this purpose. Mine is "/dev/sdb1".
  • Do the following:

    mkdir /encrypted

    # Note: The following 2 commands will ask you for input.

    cryptsetup -y -v luksFormat /dev/sdb1

    cryptsetup luksOpen /dev/sdb1 encrypted

    mkfs.ext4 /dev/mapper/encrypted

    mount /dev/mapper/encrypted /encrypted

  • To unmount your encrypted filesystem:

    umount /encrypted

    cryptsetup luksClose encrypted

  • To remount your encrypted filesystem:

    # Note: The following command will ask you for input.

    cryptsetup luksOpen /dev/sdb1 encrypted

    mount /dev/mapper/encrypted /encrypted