Skip to main content

Notes on a Tricky Linux Installation: Qubes OS and Windows

I recently tried to install Qubes OS alongside an existing Windows installation. It turned out to be surprisingly difficult—way harder than my last attempt—likely due to a combination of my encrypted /boot setup and older hardware. Here are some notes from the process.

Shrinking an NTFS Volume

I needed to free up some space from a Windows NTFS volume. Normally, this just takes a few clicks in Disk Management. This time, however, Windows reported a "shrinkable volume" that was suspiciously small.

Following this answer, I tried the standard fixes:

  • Disabled hibernation (powercfg /h off)
  • Disabled the pagefile
  • Disabled system protection

This increased the shrinkable volume a bit, but nowhere near the actual free space left on the partition.

Digging into the Windows Application logs in Event Viewer, I finally found the culprit: The last unmovable file appears to be: \$Mft::$DATA. It turns out $Mft is a special block in NTFS that cannot be easily moved, and a simple defrag wasn't going to cut it. I tried a few third-party partition managers, but they all failed initially. Following a hint from one of the tools, I temporarily disabled BitLocker. That did the trick—AOMEI Partition Assistant was finally able to shrink the volume. Once it was done, I just had to re-enable everything.

Configuring the Display

I use a dual-monitor setup (let's call them A and B). The Linux console and GUI installer assumed monitor A was the primary display, leaving monitor B either completely blank (in the terminal) or showing an empty desktop (in the GUI). I wanted everything on B, and the usual Super+Arrow Key shortcut wasn't working.

Here is how I forced the display:

Turn Off the Display in the Terminal

Note: This forces the GUI installer to the correct screen, but doesn't change the terminal itself.

  1. Switch to the terminal (Ctrl + Alt + F2).
  2. Find the "bad" display in /sys/class/drm/.
  3. Run echo off > /sys/class/drm/card0-<DEVICE_NAME>/status.
  • Example: echo off > /sys/class/drm/card0-HDMI-A-1/status
  1. Switch back to the GUI (Ctrl + Alt + F6). The installer should now be forced onto the only "active" screen.

Turn Off the Display via Kernel Parameters

  1. First, find the device/port name by running: ls -d /sys/class/drm/card*-*. Examples:
  • /sys/class/drm/card0-DP-1 (Integrated)
  • /sys/class/drm/card1-HDMI-A-1 (Discrete)
  1. Add something like video=eDP-1:d to the kernel parameters.
  2. This gets more complicated when the ports are the same but the cards are different, though I haven't tested that scenario.

GRUB and Encrypted /boot

GRUB 2.12 supports LUKS2, but it doesn't support the Argon2 hashing algorithm—that didn't arrive until GRUB 2.14.

While GRUB 2.14 works perfectly on my newer machine, it refused to boot properly on this older one. After hours of troubleshooting, I realized that while GRUB 2.14 could boot directly into Linux, but it failed completely when trying to boot through Xen. Suspecting the issue lay somewhere between GRUB and Xen, I eventually gave up and downgraded to GRUB 2.12, changing my LUKS partition to use PBKDF2 instead of Argon2.

Another quirk: GRUB's decryption implementation feels about 100 times slower than cryptsetup. It likely lacks hardware acceleration for decryption, and the -A parameter isn't available for the cryptomount command in my version of GRUB. To keep boot times reasonable, I had to decrease the number of PBKDF2 iterations in LUKS.

LVM Issues

Xen and Linux finally booted, but the celebration was cut short. The boot process stalled, complaining that the /dev/mapper/boot device timed out, and it wouldn't even let me enter the rescue shell.

I fixed the rescue shell issue by booting from a live USB and giving root a password. The timeout issue, however, was much weirder. It turned out that only the LVM logical volumes specifically listed in the rd.lvm.lv kernel parameters were being unlocked; the rest were completely invisible. Even running vgs and lvs returned empty results.

I was eventually able to recover everything using the vgimportdevices -a command. Oddly, this created a duplicate LVM entry in the system.devices file, and manually removing the duplicate broke everything again. I ended up just deleting the file entirely and letting vgimportdevices recreate it from scratch. It’s been running smoothly ever since.

Secure Boot

Just as I got Qubes OS working with Secure Boot enabled, Windows broke. The UEFI complained that the boot signature wasn't recognized.

After some debugging, I figured out what happened: I had reset the Secure Boot keys on my motherboard to their factory defaults. Because the laptop is old, the factory defaults only contained the 2011 Microsoft keys. However, my Windows boot loader had been updated and was signed with the newer 2023 key.

I tried copying the Secure Boot database from another machine, but that failed (likely due to PK/KEK mismatch issues). After hours of trial and error, I solved it with a combination of the following actions:

  • Set Secure Boot to Setup mode.
  • Reset to factory keys
  • Update Secure Boot variables via Windows registry and scheduled tasks (source)
reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Secureboot /v AvailableUpdates /t REG_DWORD /d 0x5944 /f

Start-ScheduledTask -TaskName "\Microsoft\Windows\PI\Secure-Boot-Update"

# Manually reboot the system when the AvailableUpdates becomes 0x4100

Start-ScheduledTask -TaskName "\Microsoft\Windows\PI\Secure-Boot-Update"
  • Boot SecureBootRecovery.efi from the Windows EFI partition.

I suspect running SecureBootRecovery.efi was the magic bullet, though the other steps likely set the stage. Surprisingly, this file never came up in my online troubleshooting; I just stumbled across it by accident while browsing the EFI partition.

Final Thoughts

Looking back, I definitely stacked too many tricky components together—older hardware, dual-booting, encrypted /boot, LVM, and Secure Boot—and hit a bit of bad luck along the way. Fortunately, it all worked out in the end. What a journey!

Comments

Popular posts from this blog

Exploring Immutable Distros and Declarative Management

My current server setup, based on Debian Stable and Docker, has served me reliably for years. It's stable, familiar, and gets the job done. However, an intriguing article I revisited recently about Fedora CoreOS, rpm-ostree, and OSTree native containers sparked my curiosity and sent me down a rabbit hole exploring alternative approaches to system management. Could there be a better way? Core Goals & Requirements Before diving into new technologies, I wanted to define what "better" means for my use case: The base operating system must update automatically and reliably. Hosted services (applications) should be updatable either automatically or manually, depending on the service. Configuration and data files need to be easy to modify, and crucially, automatically tracked and backed up. Current Setup: Debian Stable + Docker My current infrastructure consists of several servers, all running Debian Stable. System Updates are andled automatically via unattended-upgrades. Se...

A Rocky Migration: Moving from docker-compose to Podman and gVisor

I've been running a few containers for several years. They were all running under rootless Docker with a single user. Initially, I planned to  migrate the containers to VMs , but I couldn't get a stable workflow after about two months of effort. Later,  gVisor caught my attention , and I decided to migrate to Podman with gVisor instead. The new plan is to run each container with  --userns=auto  and use Quadlet for systemd integration. This approach provides better isolation and makes writing firewall rules easier. I'm now close to migrating all my containers. Here are a couple of rough edges I'd like to share. Network Layout I compared  various networking options  and spent a few hours trying the one-interface-per-group approach before giving up. I settled on a single macvlan network and decided to use static IP addresses for my containers. To prevent a randomly assigned IP address from conflicting with a predefined one, I allocated a large IP range for my ...

Determine Perspective Lines With Off-page Vanishing Point

In perspective drawing, a vanishing point represents a group of parallel lines, in other words, a direction. For any point on the paper, if we want a line towards the same direction (in the 3d space), we simply draw a line through it and the vanishing point. But sometimes the vanishing point is too far away, such that it is outside the paper/canvas. In this example, we have a point P and two perspective lines L1 and L2. The vanishing point VP is naturally the intersection of L1 and L2. The task is to draw a line through P and VP, without having VP on the paper. I am aware of a few traditional solutions: 1. Use extra pieces of paper such that we can extend L1 and L2 until we see VP. 2. Draw everything in a smaller scale, such that we can see both P and VP on the paper. Draw the line and scale everything back. 3. Draw a perspective grid using the Brewer Method. #1 and #2 might be quite practical. #3 may not guarantee a solution, unless we can measure distances/p...