How to install Qubes OS when your motherboard hates it
It seems like some motherboards, MSI ones particularly, hate Qubes OS and won’t be able to find it after you’ve installed it, or generally have other problems booting.
Credits goes to
51lieal: UEFI boot: no Qubes OS option - #3 by 51lieal
maxi: Qubes R4.1 no proper boot device - #16 by maxi
Qubes OS Team:
UEFI troubleshooting | Qubes OS
UEFI troubleshooting | Qubes OS
Instructions
-
Make absolutely sure the hard drive you’re installing Qubes on it completely wiped first. In my experience R4.1.1 cannot install templates if you only cleaned out previous installations using its default provided tools. If you’re on a newer MSI board you can use “Secure Erase+” from the MSI bios to completely wipe the drive.
-
If you’re particularly paranoid and don’t trust your USB input devices unplug them first (IDK what I’m talking about here tbh. I just vaguely recall reading this somewhere.)
-
Follow the documented install approach (Install Qubes OS R4.1.1 from the GNU grub menu). Installer should proceed normally, though at the time of writing it won’t match the official installation instructions exactly simply because those instructions were not written for R4.1.1
-
The installer might hang at “running post-installation scripts” near the end. If this happens it’ll stay there ages and you might not even notice any busy light flickering from your motherboard. Its not dead! Go make a snack or something and come back, it will, (eventually,) finish.
-
The installer should claim its complete, select the reboot system button. Your restart might end up hanging indefinitely or otherwise taking a long time, just turn the computer off if this is happening.
-
Remove your installation medium.
-
Turning you’re computer back on you’ll find the OS won’t actually boot, you’ll just cut straight to the UEFI bios. The bios will have no indication of a bootable medium on your hard drive. If the OS DOES boot then congratulations, enjoy your Qubes OS! (You lucky sod… Wait, why are you even reading this?)
-
Shutdown and reattach your installation medium.
-
Boot into qubes rescue mode using your installation medium (The last option on the grub menu: “Rescue a Qubes OS system”)
-
Type 1 and press enter (for continue), then enter your password.
-
It’ll probably complain that you don’t have any linux partitions, press enter and let it move on to the shell.
-
Type
fdisk -l
and examine the output. You want to find the device/addresses of your boot and efi partitions. EFI should be labelled under “type” and be obvious, boot will probably be the smaller of the two remaining Linux filesystem partitions. -
Mount those two partitions with
mount <BOOT PARTITION DEVICE/ADDRESS> /mnt
mount <EFI PARTITION DEVICE/ADDRESS> /mnt/efi
-
Examine the contents of /mnt/efi/EFI/qubes.
cd /mnt/efi/EFI/qubes
ls
You’ll probably be missing several key files, namely xen.cfg, vmlinuz- and initramfs-.img. If they exist, Congratulations, the installer hates you less then me! you can skip to step 17. -
The latter two of these missing files can be copied from mnt using:
cd /mnt
ls
cp /mnt/vmlinuz-<KERNEL VERSION> /mnt/efi/EFI/qubes/
cp /mnt/initramfs-<KERNEL-VERSION>.img /mnt/efi/EFI/qubes/
-
The missing .cfg you’ll have to make yourself.
1. Note down your kernel version from the previous two files, or usename -r
to get it. (You’ll need to be able to type it out in a moment without seeing it in the console)
2. return to the qubes folder.
cd /mnt/efi/EFI/qubes
3. make an empty xen.cfg file
echo > xen.cfg
4. use vim to begin editing the file.
vi xen.cfg
5. You need to make it look like this:[global] default=<KERNEL-VERSION> [<KERNEL-VERSION>] options=loglvl=all dom0_men=min:1024M dom0_mem=max:4096M kernel=vmlinuz-<KERNEL-VERSION> root=/dev/mapper/qubes_dom0-root rd.lvm.lv=qubes_dom0/root rd.lvm.lv=qubes_dom0/swap i915.preliminary_hw_support=1 rhgb quiet ramdisk=initramfs-<KERNEL-VERSION>.img
- When you’re done press ESC, this will change you from insert mode to normal mode.
- Type :wq! to save your changes (or :q! to not save them if something went wrong)
-
Now copy your newly repaired qubes folder to /mnt/efi/EFI/BOOT
cp -r /mnt/efi/EFI/qubes/. /mnt/efi/EFI/BOOT
-
Rename the xen.cfg in BOOT to BOOTX64.cfg
mv /mnt/efi/EFI/BOOT/xen.cfg /mnt/efi/EFI/BOOT/BOOTX64.cfg
-
Override quebes/xen.efi with its neighbouring versioned xen efi file (xen-[XEN VERSION].efi). You can use the usual combinations of cd and ls to inspect its folder and find out what its currently named.
cp /mnt/efi/EFI/qubes/xen-<XEN VERSION>.efi /mnt/efi/EFI/qubes/xen.efi
-
copy the versioned xen efi file over to /mnt/efi/EFI/BOOT, renaming it in the process
cp /mnt/efi/EFI/qubes/xen-<XEN VERSION>.efi /mnt/efi/EFI/BOOT/BOOTX64.efi
-
Now use cd to move back to root (just incase you were in a folder we’re about to unmount)
cd
-
Then unmount everything we mounted earlier
umount <EFI PARTITION ADDRESS>
umount <BOOT PARTITION ADDRESS
> -
And shutdown. (Much like 51lieal, I’ve found restarting quebes seems to hang)
shutdown now
-
Remove your installation medium
-
After rebooting your pc you should now, finally, see the post installation configuration. If this completes fine you’re done and can stop following these steps, hooray! However if you’ve got an intel ethernet port you’ll probably encounter the following error message at the very end:
[‘/usr/bin/qvm-start’, ‘sys-firewall’] failed:
stout: “”
stderr “start failed: internal error: unable to reset PCI device 0000:00:1f.6: no FLR, PM reset or bus reset available, see varlog/libvirt/libxl/libxl-driver.log for details
“
-
I’ve found in the past that sys-usb won’t be running yet, so I tend to shutdown here and turn my computer back on rather then plugging in any USB input devices I inexplicably don’t trust.
-
Plug back in any USB devices you removed earlier then turn back on your computer. (sys-usb should run this time.)
-
sys-net and system-firewall will fail to start due to the earlier error. In my case this was due to the PCI device: intel corporation Ethernet connection (7) I219-V.
-
If like me MSI blessed you with a second ethernet port you can simply go into the qubes manager, then sys-net’s settings and remove the intel Ethernet using the devices tab and click apply. (If you attempt to manually start it before doing this you’ll end up stuck until you reboot.). If not you’ll need follow the instructions here: PCI troubleshooting | Qubes OS (I haven’t followed them yet so can’t be much help, sorry)
-
Shut your computer down and turn it back on again. Congratulations, you’ve reached basic functionality, wasn’t that fun?