Skip to content

Instantly share code, notes, and snippets.

@ourownstory
Last active October 23, 2024 14:32
Show Gist options
  • Save ourownstory/728e5894b9b86d6b21579fd9ded4c30e to your computer and use it in GitHub Desktop.
Save ourownstory/728e5894b9b86d6b21579fd9ded4c30e to your computer and use it in GitHub Desktop.
Encrypted dual boot setup for Pop!_OS and Windows 10 using LUKS and Bitlocker on Dell XPS 17 9700

Encrypted dual boot setup with Pop!_OS and Windows 10

How to guide, using LUKS and Bitlocker on Dell XPS 17 9700

This guide is for those who want to use their XPS 17 in dual boot with their (preinstalled) Windows 10 and a new Pop!_OS installation, without giving up Bitlocker Encryption in Windows nor LUKS encryption in Linux.

The only guides that I could find were for Ubuntu, which it should be identical to, but I found the ommission of a few steps to resolve issues that I encountered in my first install attempt. Hoping to save you some trouble, I am sharing the steps that worked for me, linking the original guides that I found useful.

1. Preparation

  • 1.1 Of course: Backup all your data! You always do this when people tell you to, right? Maybe this time better be safe than sorry.

  • 1.2 Safely note your Bitlocker recovery key somewhere off your XPS. Where to find it

  • 1.3 Prepare your installation medium. You can use Etcher on Windows to create a USB stick with POP!_OS

  • 1.4 SATA operation mode: Change your SSD's SATA operation mode from RAID to AHCI in your BIOS (WAIT, finish reading the next two senctences first). Dell ships the XPS' SSD in RAID, but Ubuntu won't be able to work with it. By default, your preinstalled Windows does not work in AHCI with the Dell provided Drivers, so you can not just change it in the BIOS. To get it to work without re-installing Windows, you have to do this simple but effective trick to change the SATA Operation mode: follow the steps for Option 2

  • 1.5 Disable Secure Boot: You can simply disable it in your BIOS. If you're hesitating: It's a proprietary piece of code that's not all that important for security. Most Linux distributions refuse to get listed as "Secure" due to philosophical differences. The only downside is: You may have to enter the long recovery key to acess your Windows partition again. Don't worry, the screen looks bad, but you just have to enter it once and nothing is lost.

2. Install Pop!_OS

  • 2.1 Boot from your USB medium, by hitting F12 on startup and then selecting it.

  • 2.2 select your language and keyboard, But stop before installing it. Select "Try Demo Mode" instead.

  • 2.3 Set up two partitions, one for /boot and another one that we will encrypt and then use for root and swap. You can either follow the sgdisk instructions on the terminal (first half of Phase 3) or do the same on the visual Gparted tool. Either way, I recommend also reading the corresponding sections on the original thread on askubuntu and the instructions for XPS 15 9560 on github. You may skip the /home partition.

    Using sgdisk:

    sudo sgdisk -n=8:0:+768M /dev/nvme0n1
    sudo sgdisk -n=9:0:0 /dev/nvme0n1
    sudo sgdisk -c=8:/boot -c=9:rootfs /dev/nvme0n1
    sudo sgdisk -t=8:8300 -t=9:8300 /dev/nvme0n1
    sudo mkfs.ext4 -L boot /dev/nvme0n1p8
    
  • 2.4 Setup LUKS:

$ sudo cryptsetup luksFormat --type=luks1 /dev/nvme0n1p9
WARNING!
========
This will overwrite data on /dev/nvme0n1p9 irrevocably.
   
Are you sure? (Type uppercase yes): YES
Enter passphrase for /dev/nvme0n1p9: 
Verify passphrase: 
   
$ sudo cryptsetup open /dev/nvme0n1p9 pop_crypt
Enter passphrase for /dev/nvme0n1p9: 
   
$ ls /dev/mapper/
control pop_crypt
  • 2.5 Configure LVM on the ecrypted partition. Create at least as much swap space as you have RAM, and assign the rest to root.
$ sudo pvcreate /dev/mapper/pop_crypt
Physical volume "/dev/mapper/pop_crypt" successfully created.
$ sudo vgcreate pop-vg /dev/mapper/pop_crypt
Volume group "pop-vg" successfully created
$ sudo lvcreate -L 32G -n swap_1 pop-vg
Logical volume "swap_1" created.
$ sudo lvcreate -l 100%FREE -n root pop-vg
Logical volume "root" created.
  • 2.6 NOT exiting the live demo, install Pop!_OS by running the installer from the sidebar, and choose "Something else" to configure partitions yourself.

    map the small boot partition (in my case nvme0n1p8) as ext4 to /boot)

    unlock the encrypted partition (in my case nvme0n1p9)

    map our encrypted logical volume /dev/mapper/pop--vg-root as ext4 with to /

    map our encrypted logical volume /dev/mapper/pop--vg-swap_1 as swap

  • 2.7 Skip the remaining instructions of the guides!*

    * When I followed the instructions in my first attempt, the encrypted swap was not properly set up, and booting took close to two minutes. Trying to fix it, it would not boot at all anymore, so I went for a clean reinstallation, and this time decided to skip the remaining step, which worked flawlessly. I assume that Pop!_OS may have it's automatic mechanism to correctly configure encrypted root and swap, so doing it manually may interfere with it.

  • 2.8 Reboot into your Pop!_OS

  • 2.9 Check that you are using the encryped partition for / by running mount:

$ mount | grep root
/dev/mapper/pop--vg-root on / type ext4 (rw,noatime,errors=remount-ro)
  • 2.10 Check that you are using the ecrypted swap partition:
$ swapon -s
Filename     Type       Size        Used    Priority
/dev/dm-1    partition  33554428	0	    -2

Note: you can use lsblk or sudo dmsetup info /dev/dm-1 to check what the dm-1 partition is (part of the device mapper in the kernel, used by LVM).

3. Post Setup

3.1 Boot

Bad solution

Sadly, Grub and Bitlocker don't play nice together, so you the basic solution is to select one OS as your default (set it as first in boot order in BIOS). To boot into the other OS, you have to hit F12 during startup and then select it.

Proper Solution

I sucessfully fixed this with the excellent rEFInd tool. After setting it up, it works like a charm, even with custom kernels. All you need to do is to run this in your terminal:

sudo apt-add-repository ppa:rodsmith/refind
sudo apt update
sudo apt install refind

3.2 Drivers for Audio, Microphone, Fingerprint

UPDATE: With PopOS! 21.04, the audio works out of the box. (I did not try the fingerprint scanner.) You can skip this section now.

This reddit user posted a complete set of instructions that worked well for me. Only thing I had to do additionally: Install dependency package libfprint-2-tod1 with sudo apt-get install libfprint-2-tod1 before installing the fingerprint driver (Step 8).

EDIT: these fixes stopped working after updates (on POP_OS! 20.10). 21.04 should include audio support in the mainline kernel.

4. Bonus

4.1 Access a Bitlocker data partition from Linux

TBD

4.2 Fix your clock:

From System76:

Windows and Linux store their time in the BIOS differently, this will cause your clock to be desynchronized when you switch from one OS to the other.

The easiest solution for it is to fix it in Linux, forcing it to work the same way as Windows. You can do this through the terminal: timedatectl set-local-rtc 1 --adjust-system-clock

You can verify if the change has been successful, by running this command:

timedatectl

You should see RTC in local TZ: yes. If you need to revert it, just set it to 0:

timedatectl set-local-rtc 0 --adjust-system-clock

Notes

Guides for encrypted Ubuntu and Windows dual boot that I found helpful:

Keys:

  • Hit F2 on startup to enter the BIOS
  • Hit F12 on startup to select your boot medium
@iuliuz
Copy link

iuliuz commented Mar 22, 2021

Thanks, worked excellent!

@ourownstory
Copy link
Author

Thanks, worked excellent!

Great! did the audio work for you? I just had to update the gist:
EDIT: these fixes stopped working after updates (on POP_OS! 20.10) To my understanding, 21.04 should include audio support in the mainline kernel. I'll just wait for that to properly fix this, hopefully.

@tae898
Copy link

tae898 commented Dec 21, 2021

Thanks this is amazing!!!

@ourownstory
Copy link
Author

Happy to hear its useful @tae898

@ourownstory
Copy link
Author

BTW, Audio is working decently on Pop 21.04 without any modifications.

@kema-dev
Copy link

Still useful in 2023, thank you !

@lucian303
Copy link

lucian303 commented Mar 25, 2023

Great write up! For the latest Pop 22.04, the changes I made was to have the boot partition be FAT32 and mount /boot/efi on there using the installer rather than /boot. I also added a 4GB FAT32 recovery partition and mounted /recovery on there. This is optional, but if set up, Pop will install system recovery there. Other than that, I just followed the tutorial and it worked great! I should have tried this the first time around and saved some time rather that using an unencrypted partition initially.

@ourownstory
Copy link
Author

Thank you @kema-dev !
Thank you @lucian303 for sharing your modifications!

@JYCabello
Copy link

Thanks to @lucian303 to share the updates and thanks to @ourownstory for the original guide. I'll give it a shot with my new XPS 17.

@cougarten
Copy link

cougarten commented Jan 7, 2024

Thanks!

for the current pop (and win11) I had to do 3 things differently:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment