Dual boot Windows 10 and Ubuntu 18.04 with Ubuntu encrypted

Run GParted

  • Resize for some free space
  • Create an ext4 400MB /boot on the free space
    (It will become /dev/nvme0n1p5 in my case)
  • Create an ext4 partition on the remaining space
    (It will become /dev/nvme0n1p6 in my case)

Run Terminal

sudo cryptsetup luksFormat /dev/nvme0n1p6
  • type YES and then enter passphrase twice for encryption
sudo cryptsetup luksOpen /dev/nvme0n1p6 encrypted
  • "encrypted" is just the label. You can choose whatever you like.
sudo pvcreate /dev/mapper/encrypted
sudo vgcreate vg /dev/mapper/encrypted
  • "vg" is the "volume group" label. You can choose whatever you like.
  • Create a 3GB swap volume, and use the rest to create the root volume.
    (Yet I don't want swap for myself...)
sudo lvcreate -L 3G -n swap vg
sudo lvcreate -n root -l 100%FREE vg

Run "Install Ubuntu" on the desktop

  • Choose "Something else" on the "Installation type" page, and "Continue"
  • Double click the boot partition created above (/dev/nvme0n1p5), use as ext4, mount as /boot, mark as "format"
  • Double click /dev/mapper/vg-root/. Use as "ext4" and mount as "/", mark as "format"
  • Double click the /dev/mapper/vg-swap/. Use as "swap area"
  • Choose the /dev/nvme0n1 as the "device for bootloader"
  • "Install Now", and finish the rest of the steps. DO NOT REBOOT!

Run terminal

sudo mkdir /mnt/root

sudo mount /dev/mapper/vg-root /mnt/root
sudo mount /dev/nvme0n1p5 /mnt/root/boot

sudo mount --bind /dev /mnt/root/dev
sudo mount --bind /dev/pts /mnt/root/dev/pts
sudo mount --bind /proc  /mnt/root/proc
sudo mount --bind /sys /mnt/root/sys
sudo mount --bind /run /mnt/root/run

sudo chroot /mnt/root
mount /boot/efi
  • Find the UUID of the partition where "encrypted" (/dev/nvme0n1p6) is located.
    NOT the /dev/mapper/encrypted one!
blkid
  • Put this line and replace the UUID with yours
nano /etc/crypttab
encrypted UUID=MY_UUID none luks

Save the file.

update-grub

grub-install /dev/nvme0n1
update-initramfs -u -k all

Exit the chroot. Reboot.

Reference: https://www.summet.com/blog/2016/11/26/installing-an-encrypted-partition-with-lvm-dual-boot-on-ubuntu-16-04/comment-page-1/?unapproved=186330&moderation-hash=0fe204e26f3906e97e92d1d4bcbcf5fe#comment-186330