From 6469447c54fc4c4a0133d3d0529182c03ac32b88 Mon Sep 17 00:00:00 2001 From: Christoph Heiss Date: Sun, 5 Nov 2023 23:23:21 +0100 Subject: [PATCH] content: nixos-btrfs: Add section about UEFI (+ LUKS) installation Signed-off-by: Christoph Heiss --- content/nixos-btrfs.md | 53 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/content/nixos-btrfs.md b/content/nixos-btrfs.md index 4764696..c5306db 100644 --- a/content/nixos-btrfs.md +++ b/content/nixos-btrfs.md @@ -11,7 +11,7 @@ date: 2023-10-14T00:15:29+02:00 $ fdisk /dev/vdX fdisk> o fdisk> n -# enter, enter, enter, enter +# , , # primary partition, number 1, from sector 2048 to end fdisk> w ``` @@ -45,6 +45,57 @@ $ mount -o noatime,compress=zstd,subvol=@nix /dev/disk/by-uuid/ /mnt/nix $ mount -o noatime,compress=zstd,subvol=@log /dev/disk/by-uuid/ /mnt/var/log ``` +## UEFI, ESP + single partition + +### first, create a new GPT partition table and two partitions + +```shell {lineanchors=list} +$ fdisk /dev/sdX +fdisk> g +fdisk> n +# , , +512M +# primary partition, number 1, from sector 2048 with size 512MiB +fdisk> w +``` + +### if the root partition should be encrypted + +don't forget proper [drive preparation](https://wiki.archlinux.org/title/Dm-crypt/Drive_preparation)! + +```shell {lineanchors=list} +$ cryptsetup -y -v luksFormat /dev/sdX2 +$ cryptsetup open /dev/sdX2 nixos-root +``` + +### create the filesystems + +```shell {lineanchors=list} +$ mkfs.vfat -F32 -n nixos-boot /dev/sdX1 +$ mkfs.btrfs -L nixos /dev/sdX2 # or /dev/mapper/nixos-root if encrypted +``` + +### create all the subvolumes + +```shell {lineanchors=list} +$ mount /dev/sdX2 /mnt # or /dev/mapper/nixos-root +$ btrfs subvolume create /mnt/@ +$ btrfs subv cr /mnt/@home +$ btrfs subv cr /mnt/@nix +$ btrfs subv cr /mnt/@log +$ umount /mnt +``` + +### Mount Btrfs again, now properly with the subvolumes + +```shell {lineanchors=list} +$ mount -o noatime,subvol=@ /dev/disk/by-uuid/ /mnt # or /dev/mapper/nixos-root +$ mkdir -p /mnt/{boot,home,nix,var/log} +$ mount /dev/disk/by-uuid/ /mnt/boot +$ mount -o subvol=@home /dev/disk/by-uuid/ /mnt/home +$ mount -o noatime,compress=zstd,subvol=@nix /dev/disk/by-uuid/ /mnt/nix +$ mount -o noatime,compress=zstd,subvol=@log /dev/disk/by-uuid/ /mnt/var/log +``` + ## rest of the installation ### generate the initial NixOS system config