The Ubuntu installation disk has an option to install Ubuntu encrypted using LUKS. However, there is no option to perform an encrypted installation along-side existing partitions for a dual-boot scenario.
How can I install Ubuntu encrypted alongside another partition from the live disk?
First of all, if you want to install Ubuntu encrypted on a hard disk, replacing any existing partitions and operating systems, you can do this directly from the graphical installer. This manual process is only required for dual-booting.
This answer has been tested with Ubuntu 13.04.
Boot from an Ubuntu live DVD or USB stick, and select "Try Ubuntu".
Create two partitions using GParted included in the live disk. The first partition should be unformatted and should be large enough for root and swap, in my example, this is
/dev/sda3
. The second partition should be several hundred megabytes big and formatted in ext2 or ext3, it will be unencrypted and mounted to/boot
(in my example this is/dev/sda4
).In this screenshot, I have an existing unencrypted Ubuntu installation in two partitions:
/dev/sda1
and/dev/sda5
, highlight in the circle to the left. I have created an unformatted partition in/dev/sda3
and an ext3 partition in/dev/sda4
, intended for the encrypted Ubuntu installation, higlighted in the circle to the right:Create a LUKS container using these commands. Replace
/dev/sda3
with the unformatted partition created earlier, andcryptcherries
with a name of your choice.Warning: You'll notice that the
luksFormat
step completed very quickly, because it doesn't securely erase the underlying block device. Unless you're just experimenting and don't care about security against various types of forensic attack, it is critical to properly initialize the new LUKS container before creating filesystems in it. Writing zeros to the mapped container will cause strong random data to be written to the underlying block device. This can take a while, so it's best to use thepv
command to monitor the progress:or, if you're doing an offline install and can't easily get
pv
:Inside the mounted LUKS container, create an LVM physical volume, a volume group and two logical volumes. The first logical volume will be mounted at
/
, and the second one will be used as swap.vgcherries
is the name of the volume group, andlvcherriesroot
andlvcherriesswap
are the names of the logical volumes, you can choose your own.Create filesystems for the two logical volumes: (You can also do this step directly from the installer.)
Without rebooting, install Ubuntu using the graphical installer (shortcut is on the desktop in Xubuntu 18.04), choosing manual partitioning. Assign
/
to/dev/mapper/vgcherries-lvcherriesroot
and/boot
to the unencrypted partition created in step 2 (in this example,/dev/sda4
).Once the graphical installer is finished, select "continue testing" and open a terminal.
Find the UUID of the LUKS partitions (
/dev/sda3
in this case), you will need it later:Mount the appropriate devices to the appropriate locations in
/mnt
, and chroot into it:Create a file named
/etc/crypttab
in the chrooted environment to contain this line, replacing the UUID value with the UUID of the LUKS partition, andvgcherries
with the name of the volume group:Run the following command in the chrooted environment:
Reboot and boot into the encrypted Ubuntu. You should be prompted for a password.
Check that you're using the encrypted partition for
/
by runningmount
:Check that you're using the encrypted swap partition (not any unencrypted swap partitions from any other installations) by running this command:
Check that you can boot into recovery mode, you don't want to find out later during an emergency that recovery mode doesn't work :)
Install any updates, which are likely to rebuild the ramdisk and update the grub configuration. Reboot and test both normal mode and recovery mode.
It is possible to create an encrypted dual-boot setup using only the GUI tools of the Ubuntu LiveCD.
Prerequisites
gdisk
), but you should do an backup first. If you convert the Partition table, you will need to fix the windows boot loader afterwards.Windows
In the start bar type
disk partition
and select the first option (opening the disk partition manager from settings).Shrink your primary partition to your desired Ubuntu size (I just used the default, splitting my 500GB drive into a 240GB Windows OS and 240GB unallocated space).
BIOS
Ubuntu LiveCD
Finally - Boot into the 19.04 Installer USB
Hit Enter on the default Install Ubuntu option.
When you get to the screen that says Erase entire disk and has some checkboxes, click the Something else (manual partitioning) option. Otherwise you will lose you Windows Data!
Once the disk partition manager loads your disk, you'll have a large unallocated space. Click that and hit the Add button to create partitions.
/boot
partition (primary, ext4)./
partition. Saying it differently, hit the "change" button on/dev/mapper/sdaX_crypt
and set the mount point to/
When you boot for the first time, log in, open a terminal, run
sudo apt-get update
andsudo apt dist-upgrade
, reboot and log in again.A 2GB swap file will be created automatically. If you want an 8GB one instead, read this answer.
First, points why only encrypting the Linux partition may not be secure enough for you:
Now on, I followed this tutorial:
On this answer, I am presenting a step by step (with pictures) installation of Linux
Mint 19.1 XFCE
andUbuntu 18.04.2
, both fully encrypted in a single disk. First I installedUbuntu 18.04.2
on/dev/sda5
and I did not create the swap partitions becauseLinux Mint 19.1
andUbuntu 18.04.2
do not use them, i.e., they use swap files.Ubuntu 18.04.2 Bionic Beaver
First, insert the
Ubuntu
installation media and reboot the machine into theUbuntu
live session, then, selectTry Ubuntu
and open one terminal, thensudo su -
fdisk /dev/sda
, then, create the following partitionscryptsetup luksFormat /dev/sda5
cryptsetup luksOpen /dev/sda5 sda5_crypt
pvcreate /dev/mapper/sda5_crypt
vgcreate vgubuntu /dev/mapper/sda5_crypt
lvcreate -L10G -n ubuntu_root vgubuntu
lvcreate -l 100%FREE -n ubuntu_root vgubuntu
(optional, instead of runninglvcreate -L10G -n ubuntu_root vgubuntu
, you can run thislvcreate -l 100%FREE -n ubuntu_root vgubuntu
to use your whole disk free space, instead of only 10GB)/dev/sda1
mounted as/boot
partition withext2
format/dev/mapper/vgubuntu-ubuntu_root
mounted as/
withext4
format./dev/sda
as boot loader installationInstall Now
after selecting the above optionsmkdir /mnt/newroot
mount /dev/mapper/vgubuntu-ubuntu_root /mnt/newroot
mount -o bind /proc /mnt/newroot/proc
mount -o bind /dev /mnt/newroot/dev
mount -o bind /dev/pts /mnt/newroot/dev/pts
mount -o bind /sys /mnt/newroot/sys
cd /mnt/newroot
chroot /mnt/newroot
mount /dev/sda1 /boot
blkid /dev/sda5
(copy UUID without quotes and use it on the next step)echo sda5_crypt UUID=5f22073b-b4ab-4a95-85bb-130c9d3b24e4 none luks > /etc/crypttab
/etc/grub.d/40_custom
/etc/default/grub
and setGRUB_TIMEOUT_STYLE=menu
GRUB_TIMEOUT=10
update-initramfs -u
update-grub
exit
reboot
Ubuntu
and it will correctly ask for your encryption passwordsudo apt-get update
sudo apt-get install gparted
gparted
you will find thisFor more detailed instructions, read the original tutorial pointed out on the top of this question or search on google about the usage of these commands.
Linux Mint 19.1 Cinnamon
For the remaining Linux installations,
reboot
yourUbuntu
machine, boot withMint 19.1
(Live CD) installer, and open a terminal windowsudo su -
cryptsetup luksFormat /dev/sda6
cryptsetup luksOpen /dev/sda6 sda6_crypt
pvcreate /dev/mapper/sda6_crypt
vgcreate vgmint /dev/mapper/sda6_crypt
lvcreate -L10G -n mint_root vgmint
lvcreate -l 100%FREE -n mint_root vgmint
(optional, instead of runninglvcreate -L10G -n mint_root vgmint
, you can run thislvcreate -l 100%FREE -n mint_root vgmint
to use you whole disk free space, instead of only 10GB)/dev/sda2
mounted as/boot
partition withext2
format/dev/mapper/vgmint-mint_root
mounted as/
withext4
format./dev/sda2
as boot loader installation (do not select/dev/sda
as before)Install Now
after selecting the above optionsmkdir /mnt/newroot
mount /dev/mapper/vgmint-mint_root /mnt/newroot
mount -o bind /proc /mnt/newroot/proc
mount -o bind /dev /mnt/newroot/dev
mount -o bind /dev/pts /mnt/newroot/dev/pts
mount -o bind /sys /mnt/newroot/sys
cd /mnt/newroot
chroot /mnt/newroot
mount /dev/sda2 /boot
blkid /dev/sda6
(copy UUID without quotes and use it on the next step)echo sda6_crypt UUID=5f22073b-b4ab-4a95-85bb-130c9d3b24e4 none luks > /etc/crypttab
update-initramfs -u
update-grub
exit
reboot
Linux Mint on /dev/sda2
Mint 19.1
and asked for the encryption passwordsudo apt-get update
sudo apt-get install gparted
gparted
you will find thisRelated links:
Adding another answer here as many of the other resources I've found (here and elsewhere) are quite a bit outdated, and I think some of the steps can be simplified.
First, as mentioned in other answers, If you don't want to dual boot, simply choose the encryption option in the automated installer.
It is worth noting that this method doesn't encrypt
/boot
. While there are valid reasons for encrypting/boot
, the graphical installer does not encrypt it when you do a graphical install with LUKS. As such, I'm matching that precedent, and keeping the simplicity of an unencrypted/boot
partition.Ubuntu 20.04 and Windows 10
Throughout this guide, I'm going to reference
/dev/sda
. Yours might be different - in particular, it might be/dev/nvme0n1
. Simply make the substitutions as appropriate below, noting also that/dev/sda1
would correspond to/dev/nvme0n1p1
.1Partitioning can be done with GParted, sgdisk, or gdisk. sgdisk is easiest to reference here as commands.
C:
drive. This will make another partition./boot
. The other is for Ubuntu and will be encrypted with LUKS and use LVM (similar to how the default installation process would set it up). (If you didn't set up BitLocker before, your partition numbers will be off by 1 from my example below (so my sda5 is your sda4)./dev/sda5
asext4
for/boot
/dev/mapper/ubuntu--vg-root
asext4
for/
/dev/mapper/ubuntu--vg-swap_1
asswap
/dev/sda
/etc/crypttab
(as root). This is what will trigger your passphrase prompt on boot. Replace the UUID in the file with the UUID of your drive, obtained fromsudo blkid /dev/sda6
Done! If you use BitLocker on Windows, it won't like being booted with grub. Instead, boot directly to Windows from your BIOS boot options.