Playing with qubes part 2

Original forum link
https://forum.qubes-os.org/t/12102
Original poster
51lieal
Editors
deeplow, system
Created at
2022-06-19 21:57:44
Last wiki edit
2023-09-07 05:24:04
Revisions
2 revisions
Posts count
49
Likes count
21

Part 2 of Playing with qubes

Is a rewrite of my old notes, Qubes OS Installation - Detached encrypted boot and header

Thank you @kaizer and @dum0 for donating to qubes so that I could rewrite this guide.

I'd recommend that you try in VM first, before doing it on your machine, so that you can also learn and understand too.

This is UEFI based only.

Boot Partition * > sgdisk -n 0:0:+200MiB -t 0:ef02 /dev/sda

EFI Partition * > sgdisk -n 0:0:+200MiB -t 0:ef00 /dev/sda

Root Header Partition * > sgdisk -n 0:0:+16MiB -t 0:8309 /dev/sda

If you want to use BTRFS also add swap header, another FS is not needed.

Swap Header Partition * > sgdisk -n 0:0:+16MiB -t 0:8309 /dev/sda

XFS / EXT4

You may want to use -i 1 (iterations 1ms) to speed up decrypting process for practice.

Of course you can choose another -c (chiper) -h (hash size) -s (key size) * > cryptsetup luksOpen /dev/nvme0n1 luks-root * > pvcreate /dev/mapper/luks-root * > vgcreate qubes_dom0 /dev/mapper/luks-root * > lvcreate -L 8G -n swap qubes_dom0

You might want to read 8.2. Recommended system swap space if you're not sure about swap space * > lvcreate -T -L 40G qubes_dom0/root-pool * > lvcreate -T -l +90%FREE qubes_dom0/vm-pool

SSD would perform badly if all of the space is used, so we leave 10% of the total to maintain the best performance. * > lvcreate -V30G -T qubes_dom0/root-pool -n root-pool

You should leave at least 10% in total of Thin Pool space so it could tell you if your drive will out of space. * > lvs

To see how much space you have in the VM pool, and use it to create VM lv. * > lvcreate -V800G -T qubes_dom0/vm-pool -n vm

XFS * > mkfs.xfs /dev/qubes_dom0/vm * > mkswap /dev/qubes_dom0/swap

EXT4 * > mkfs.ext4 /dev/qubes_dom0/vm * > mkswap /dev/qubes_dom0/swap

BTRFS

Swap Partition * > sgdisk -n 0:0:+8GiB -t 0:8200 /dev/nvme0n1

Root Partition * > sgdisk -n 0:0:0 -t 0:8304 /dev/nvme0n1

You can use another -csum (checksum) and may want to read this if you want to learn another Checksum Algorithms * > mkswap /dev/mapper/swap

Proceed GUI Installation

qubes

Begin installation.

uuidB = /boot partition

uuidR = /root partition

uuidS = swap partition

XFS / EXT4 * > uuidR="$(blkid -o value -s UUID /dev/nvme0n1)"

BTRFS * > uuidS="$(blkid -o value -s UUID /dev/nvme0n1p1) * > uuidR="$(blkid -o value -s UUID /dev/nvme0n1p2)"

XFS * > mkfs.xfs /dev/mapper/luks-$uuidB * > xfs_admin -U $uuidB /dev/mapper/luks-$uuidB

EXT4 / BTRFS * > mkfs.ext2 -m0 -U $uuidB /dev/mapper/luks-$uuidB

Replace QUBE with the First 4 UUID Numbers of /dev/sda1

XFS / EXT4 * > sed -i 's?/dev/qubes-dom0-root?/dev/mapper/luks-'$uuidR'?g' /etc/fstab

BTRFS * > sed -i 's?UUID=QUBE[^ ]*?/dev/mapper/luks-'$uuidR'?g' /etc/fstab * > echo -e "/dev/mapper/luks-$uuidS none swap defaults 0 0" >> /etc/fstab

Remount Boot and EFI partition * > mount -v /boot * > tar -C /boot --acls --xattrs -xf /tmp/boot.tar * > mount /dev/sda1 /boot/efi

BTRFS also create swap key * > ( umask 0077 && dd if=/dev/urandom bs=1 count=64 of=/etc/keys/swap.key conv=excl,fsync )

XFS / EXT4 * > echo -e “luks-$uuidR /dev/nvme0n1 /etc/keys/root.key luks,discard,key-slot=1,header=/dev/sda3\nluks-$uuidB UUID=$uuidB /etc/keys/boot.key luks,key-slot=1” > /etc/crypttab

BTRFS * > echo -e “luks-$uuidR /dev/nvme0n1p2 /etc/keys/root.key luks,discard,key-slot=1,header=/dev/sda3\nluks-$uuidS /dev/nvme0n1p1 /etc/keys/swap.key luks,key-slot=1,header=/dev/sda4\nluks-$uuidB UUID=$uuidB /etc/keys/boot.key luks,key-slot=1” > /etc/crypttab

XFS / EXT4 * > sed -i 's?block_uuid.map"?block_uuid.map"\necho “/dev/nvme0n1 '$uuidR'\n/dev/disk/by-uuid/'$uuidB' '$uuidB'" > “${initdir}/etc/block_uuid.map”?g' /usr/lib/dracut/modules.d/90crypt/module-setup.sh * > sed -i 's?$initdir/etc/crypttab?$initdir/etc/crypttab\necho “luks-'$uuidR' /dev/nvme0n1 /etc/keys/root.key luks,discard,key-slot=1,header=/dev/sda3\nluks-'$uuidB' UUID='$uuidB' /etc/keys/boot.key luks,key-slot=1” > $initdir/etc/crypttab?g' /usr/lib/dracut/modules.d/90crypt/module-setup.sh

BTRFS * > sed -i 's?block_uuid.map"?block_uuid.map"\necho “/dev/nvme0n1p2 '$uuidR'\n/dev/nvme0n1p1 '$uuidS'\n/dev/disk/by-uuid/'$uuidB' '$uuidB'" > “${initdir}/etc/block_uuid.map”?g' /usr/lib/dracut/modules.d/90crypt/module-setup.sh * > sed -i 's?$initdir/etc/crypttab?$initdir/etc/crypttab\necho “luks-'$uuidR' /dev/nvme0n1p2 /etc/keys/root.key luks,discard,key-slot=1,header=/dev/sda3\nluks-'$uuidS' /dev/nvme0n1p1 /etc/keys/swap.key luks,discard,key-slot=1,header=/dev/sda4\nluks-'$uuidB' UUID='$uuidB' /etc/keys/boot.key luks,key-slot=1” > $initdir/etc/crypttab?g' /usr/lib/dracut/modules.d/90crypt/module-setup.sh

XFS / EXT4 * > swapoff /dev/qubes_dom0/swap * > vgchange -a n qubes_dom0 * > cryptsetup luksClose /dev/mapper/luks-root * > cryptsetup luksClose /dev/mapper/luks-* * > wipefs -a /dev/nvme0n1 * > reboot

BTRFS * > swapoff /dev/mapper/luks-swap * > cryptsetup luksClose /dev/mapper/luks-root * > cryptsetup luksClose /dev/mapper/luks-swap * > cryptsetup luksClose /dev/mapper/luks-* * > wipefs -a /dev/nvme0n1p1 * > wipefs -a /dev/nvme0n1p2 * > reboot

Please remember that we do Detached Boot, so if you plan to use sys-usb (well you should), don't forget to edit the kernel parameter in the grub menu if you want to update kernel, and add qubes_skip.autostart to prevent sys-usb starting and detaching our /boot partition.