Debian

How to Do Encrypted Disk Partitioning for Debian 12 Installation

To ensure that your Debian 12 system and your data is safe and secure, you can install Debian 12 on partially encrypted or fully encrypted disks.

In this article, we will show you how to encrypt specific partitions from the Debian 12 installer and install Debian 12 on the encrypted partitions. We will also show you how to install Debian 12 on a fully encrypted disk as well.

Topic of Contents:

  1. Things to Know Before Encrypting the Partitions for Debian 12 Installation
  2. Encrypt Specific Partitions from the Debian 12 Installer
  3. Partition the Disks to Install Debian 12 on Fully Encrypted Disks
  4. Save the Changes and Continue the Debian 12 Installation
  5. Boot the Installed Debian 12 on Encrypted Partitions
  6. Conclusion

Things to Know Before Encrypting the Partitions for Debian 12 Installation

As of this writing, Debian 12 can’t boot from an encrypted ROOT (/) partition if you don’t have a separate unencrypted /boot and EFI partition. If you’re thinking about installing Debian 12 on a fully encrypted disk, you should create an unencrypted /boot partition, an unencrypted EFI boot partition, and must create an encrypted SWAP partition.

Encrypt Specific Partitions from the Debian 12 Installer

We create a typical disk partitioning layout for Debian 12 installation. For more information on ordinary (MBR/GPT) disk partitioning, read this article.

Let’s say, you want to encrypt the /home (sda disk partition #3) and swap (sda disk partition #4) the partitions.

A screenshot of a computer

Description automatically generated

To configure the encrypted volumes from the Debian 12 installer, select “Configure encrypted volumes” from the Manual disk partitioning window.

A screenshot of a computer

Description automatically generated

Select “Yes”[1] and click on “Continue”[2].

A screenshot of a computer

Description automatically generated

Select “Create encrypted volumes” and press <Enter>.

A screenshot of a computer

Description automatically generated

Select the partitions that you want to encrypt (sda3 and sda4 in this case)[1] and click on “Continue”[2].

A screenshot of a computer

Description automatically generated

You will have to configure the encryption for each of the partitions that you selected earlier one by one.

The disk (sda disk in this case) and partition number (partition #3 in this case) that you’re encrypting should be displayed at the top[1].

To pick an encryption method for the partition, select “Encryption” and press <Enter>[2].

Select the encryption algorithm that you want to use for this partition and press <Enter>. The currently supported encryption algorithms are AES (Advanced Encryption Standard), Blowfish, Serpent, and Twofish.

A screenshot of a computer

Description automatically generated

To select a key size for the encrypted partition, select the “Key size” and press <Enter>.

A screenshot of a computer

Description automatically generated

Select your desired key size for the encryption algorithm from the list and press <Enter>.

The larger the key size, the more secure the encryption will be. The larger the key size, the more time (or processing power) it takes to decrypt the encrypted file.

A screenshot of a computer

Description automatically generated

To select an Initialization Vector (IV) algorithm for the encryption, select the “IV algorithm” and press <Enter>.

A screenshot of a computer

Description automatically generated

Select your desired initialization vector generation algorithm from the list and press <Enter>.

A screenshot of a computer

Description automatically generated

To select the type of encryption key that you want to use, select the “Encryption key” and press <Enter>.

A screenshot of a computer

Description automatically generated

Select one of the encryption key types from the list and press <Enter>.

Passphrase: Select this option if you want to use a password as an encryption key. You will be asked for it every time you boot your Debian 12 system. The password will be used to decrypt the encrypted disks.

Random Key: Select this option if you want to use a randomly generated encryption key. You will not be asked for the encryption key while booting Debian 12. Instead, the randomly generated encryption key will be read from a secured file.

If you want to erase all the data from the partition, toggle on “Erase data” to “yes”.

To toggle on “Erase data”, select it, and press <Enter>.

Once you’re done, select “Done setting up the partition” and press <Enter>.

A screenshot of a computer

Description automatically generated

You can configure the encryption for the other partitions in the same way.

Just select your preferred encryption options for the partition[1], select “Done setting up the partition”[2], and press <Enter>.

Select “Finish” and press <Enter>.

A screenshot of a computer

Description automatically generated

You will be asked whether you want to erase the data of the partition (sda disk partition #3) that you selected for encryption.

Select “Yes”[1] and click on “Continue”[2].

A screenshot of a computer

Description automatically generated

The data of the partition (sda disk partition #3) to be encrypted is being erased. It takes a while to complete depending on the size of the partition.

A screenshot of a computer

Description automatically generated

You will be asked to erase the data of all the partitions that you selected to encrypt one by one.

Just select “Yes”[1] and click on “Continue”[2] as you did earlier.

A screenshot of a computer

Description automatically generated

The data of the partition (sda disk partition #4) to be encrypted is being erased. It takes a while to complete depending on the size of the partition.

A screenshot of a computer

Description automatically generated

Once the data of all the partitions are erased, you will be asked to enter an encryption passphrase for each of the partitions that you selected for encryption.

Type in an encryption passphrase for the partition (sda disk partition #3 in this case) and click on “Continue”.

A screenshot of a computer

Description automatically generated

Type in an encryption passphrase for the partition (sda disk partition #4 in this case) and click on “Continue”.

A screenshot of a computer

Description automatically generated

The selected partitions should be encrypted.

A screenshot of a computer

Description automatically generated

The filesystem and mount point configuration of the partition that you encrypted might be lost. So, you have to reconfigure the filesystem and mount point for the encrypted partitions.

To reconfigure a filesystem and mount point for an encrypted partition, select it and press <Enter>.

A screenshot of a computer

Description automatically generated

For this partition, the filesystem is selected correctly; only the mount point is not correct.

So, select the “Mount point” and press <Enter>.

A screenshot of a computer

Description automatically generated

Select the correct mount point for the encrypted partition and press <Enter>.

A screenshot of a computer

Description automatically generated

Once you’re done, select “Done setting up the partition” and press <Enter>.

A screenshot of a computer

Description automatically generated

The correct mount point should be set for the encrypted partition.

A screenshot of a computer

Description automatically generated

In the same way, select the second encrypted partition and press <Enter>.

A screenshot of a computer

Description automatically generated

Since this was a swap partition, the filesystem type should be changed for this partition.

Select “Use as” and press <Enter>.

A screenshot of a computer

Description automatically generated

Select “Swap area” and press <Enter>.

A screenshot of a computer

Description automatically generated

Select “Done setting up the partition” and press <Enter>.

A screenshot of a computer

Description automatically generated

An encrypted swap partition should be configured. Now, you can save the changes and install Debian 12 on the disk.

A screenshot of a computer

Description automatically generated

Partition the Disks to Install Debian 12 on Fully Encrypted Disks

To install Debian 12 on a fully encrypted disk, you must create an EFI boot partition and a /boot partition on the disk first. Then, you have to encrypt the remaining FREE SPACE and manage the encrypted disk with LVM. Finally, you can create an encrypted ROOT and a SWAP partition using LVM and install Debian 12 on the encrypted partitions.

For more information on LVM disk partitioning from the Debian 12 installer, read this article.

For more information on disk partitioning (MBR/GPT) from the Debian 12 installer, read this article.

For manual disk partitioning, select “Manual” and press <Enter>.

A screenshot of a computer

Description automatically generated

You will see all the disks that are installed on your computer.

To create a new partition table on a disk, select it and press <Enter>.

A screenshot of a computer

Description automatically generated

Select “Yes”[1] and click on “Continue”[2].

A screenshot of a computer

Description automatically generated

A new partition table should be created.

To create a new partition on the disk, select “FREE SPACE” and press <Enter>.

A screenshot of a computer

Description automatically generated

Select “Create a new partition” and press <Enter>.

A screenshot of a computer

Description automatically generated

This will be the EFI boot partition. So, type in “512 MB” as the partition size[1] and click on “Continue”[2].

A screenshot of a computer

Description automatically generated

Select “Beginning” and press <Enter>.

A screenshot of a computer

Description automatically generated

Select the “EFI System Partition” as the filesystem type (Use as)[1], select “Done setting up the partition”[2], and press <Enter>.

A screenshot of a computer

Description automatically generated

An EFI boot partition should be created.

To create another partition, select “FREE SPACE” and press <Enter>.

A screenshot of a computer

Description automatically generated

Select “Create a new partition” and press <Enter>.

A screenshot of a computer

Description automatically generated

This will be the /boot partition. So, type in “1 GB” as the partition size[1] and click on “Continue”[2].

A screenshot of a computer

Description automatically generated

Select “Beginning” and press <Enter>.

A screenshot of a computer

Description automatically generated

Select the “Ext4 journaling file system” as the filesystem type (Use as)[1], select /boot as the Mount point for the filesystem[2], select “Done setting up the partition”[3], and press <Enter>.

A screenshot of a computer

Description automatically generated

A /boot partition should be created.

A screenshot of a computer

Description automatically generated

To encrypt the remaining FREE SPACE, select “Configure encrypted volumes” and press <Enter>.

A screenshot of a computer

Description automatically generated

Select “Yes”[1] and click on “Continue”[2].

A screenshot of a computer

Description automatically generated

Select “Create encrypted volumes” and press <Enter>.

A screenshot of a computer

Description automatically generated

Select the remaining FREE SPACE[1] and click on “Continue”[2].

A screenshot of a computer

Description automatically generated

Configure the encryption settings for the disk, select “Done setting up the partition”, and press <Enter>.

We explained each of the encryption settings in the Encrypt Specific Partitions from Debian 12 Installer section of this article.

A screenshot of a computer

Description automatically generated

Select “Yes”[1] and click on “Continue”[2].

A screenshot of a computer

Description automatically generated

Select “Finish” and press <Enter>.

A screenshot of a computer

Description automatically generated

Select “Yes”[1] and click on “Continue”[2].

A screenshot of a computer

Description automatically generated

The data of the partition is being erased. It takes a while to complete depending on the size of the partition.

A screenshot of a computer

Description automatically generated

Once the data of the partition is erased, type in an encryption passphrase and click on “Continue”.

A screenshot of a computer

Description automatically generated

An encrypted partition should be created[1]. To configure LVM on the encrypted partition, select “Configure the Logical Volume Manager” and press <Enter>[2].

A screenshot of a computer

Description automatically generated

Select “Yes”[1] and click on “Continue”[2].

A screenshot of a computer

Description automatically generated

Select “Create volume group” and press <Enter>.

A screenshot of a computer

Description automatically generated

Type in a name for the volume group[1] and click on “Continue”[2].

A screenshot of a computer

Description automatically generated

Select the encrypted partition from the list[1] and click on “Continue”[2].

A screenshot of a computer

Description automatically generated

Select “Yes”[1] and click on “Continue”[2].

A screenshot of a computer

Description automatically generated

Select “Create logical volume” and press <Enter>.

A screenshot of a computer

Description automatically generated

Select the volume group that you created earlier and press <Enter>.

A screenshot of a computer

Description automatically generated

Type in “ROOT” as the name of the LVM logical volume[1] and click on “Continue”[2].

A screenshot of a computer

Description automatically generated

Type in a size for the ROOT LVM logical volume[1] and click on “Continue”[2].

A screenshot of a computer

Description automatically generated

An encrypted LVM logical volume ROOT should be created.

To create a new partition, select “Create logical volume” and press <Enter>.

A screenshot of a computer

Description automatically generated

Select the volume group that you created earlier and press <Enter>.

A screenshot of a computer

Description automatically generated

Type in “SWAP” as the name of the LVM logical volume[1] and click on “Continue”[2].

A screenshot of a computer

Description automatically generated

Type in a size for the SWAP LVM logical volume[1] and click on “Continue”[2].

A screenshot of a computer

Description automatically generated

An encrypted LVM logical volume SWAP should be created.

Select “Finish” and press <Enter>.

A screenshot of a computer

Description automatically generated

The encrypted LVM logical volumes ROOT and SWAP should be created.

A screenshot of a computer

Description automatically generated

Select the encrypted LVM logical volume ROOT and press <Enter>.

A screenshot of a computer

Description automatically generated

Select the “Ext4 journaling file system” as the filesystem type (Use as)[1], select “/” as the Mount point for the filesystem[2], select “Done setting up the partition”[3], and press <Enter>.

A screenshot of a computer

Description automatically generated

The correct filesystem and mount point should be set for the encrypted LVM logical volume ROOT[1].

Select the encrypted LVM logical volume SWAP and press <Enter>[2].

A screenshot of a computer

Description automatically generated

Select the “Swap area” as the filesystem type (Use as)[1], select “Done setting up the partition”[2], and press <Enter>.

A screenshot of a computer

Description automatically generated

Select the encrypted LVM logical volume SWAP and press <Enter>. Now, you can save the changes and install Debian 12 on the disk.

Save the Changes and Continue the Debian 12 Installation

Whether you decided to encrypt specific partitions or install Debian 12 on fully encrypted disk, once you’ve done the necessary partitioning, save the changes to the disk and continue the Debian 12 installation.

To save the changes to the disk, select “Finish partitioning”, write the changes to disk, and press <Enter>.

Select “Yes”[1] and click on “Continue”[2].

A screenshot of a computer

Description automatically generated

Debian 12 is being installed on the encrypted disk. It takes a while to complete.

A screenshot of a computer

Description automatically generated

Boot the Installed Debian 12 on Encrypted Partitions

Once Debian 12 is installed on the encrypted disk and you boot Debian 12, you will be prompted to enter the encryption passphrase for the disk.

Type in the encryption passphrase and press <Enter>.

A black screen with white text

Description automatically generated

Debian 12 will boot as usual.

A black screen with white text

Description automatically generated

As you can see, Debian 12 is installed on encrypted partitions.

$ lsblk

$ sudo cryptsetup status sda3_crypt

A screenshot of a computer

Description automatically generated

Conclusion

We showed you how to encrypt specific partitions from the Debian 12 installer and install Debian 12 on the encrypted partitions. We also showed you how to install Debian 12 on a fully encrypted disk and how to verify whether Debian 12 is installed on encrypted disk/partitions as well.

About the author

Shahriar Shovon

Freelancer & Linux System Administrator. Also loves Web API development with Node.js and JavaScript. I was born in Bangladesh. I am currently studying Electronics and Communication Engineering at Khulna University of Engineering & Technology (KUET), one of the demanding public engineering universities of Bangladesh.