diff options
Diffstat (limited to 'docs')
-rw-r--r-- | docs/install.org | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/docs/install.org b/docs/install.org new file mode 100644 index 0000000..86f255d --- /dev/null +++ b/docs/install.org @@ -0,0 +1,87 @@ +#+TITLE: Installation +#+AUTHOR: Franck Cuny +#+EMAIL: franck@fcuny.net + +* Partitioning +All hosts have the same partitioning for the boot drive: +- /boot partition for UEFI +- / encrypted with btrfs +- a 8GB swap + +If we assume the boot drive to be =nvme0n1=, we will do the following: +#+begin_src sh +parted /dev/nvme0n1 -- mklabel gpt +parted /dev/nvme0n1 -- mkpart primary 512MiB -8GiB +parted /dev/nvme0n1 -- mkpart primary linux-swap -8GiB 100% +parted /dev/nvme0n1 -- mkpart ESP fat32 1MiB 512MiB +parted /dev/nvme0n1 -- set 3 esp on +#+end_src + +Running =lsbkl= should give the following output: +#+begin_src sh +[root@nixos:~]# lsblk +NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS +loop0 7:0 0 709M 1 loop /nix/.ro-store +sda 8:0 1 29.9G 0 disk +├─sda1 8:1 1 784M 0 part /iso +└─sda2 8:2 1 37M 0 part +nvme0n1 259:0 0 465.8G 0 disk +├─nvme0n1p1 259:1 0 457.3G 0 part +├─nvme0n1p2 259:2 0 8G 0 part +└─nvme0n1p3 259:3 0 511M 0 part +#+end_src + +Then we create the LUKS device: +#+begin_src sh +cryptsetup --verify-passphrase -v luksFormat /dev/nvme0n1p1 +cryptsetup open /dev/nvme0n1p1 system +#+end_src + +We can create the partition for the boot drive and activate the swap: +#+begin_src sh +mkswap -L swap /dev/nvme0n1p2 +swapon /dev/nvme0n1p2 +mkfs.fat -F 32 -n nixos-boot /dev/nvme0n1p3 +#+end_src +** BTRFS +#+begin_src sh +mkfs.btrfs /dev/mapper/system + +mount -t btrfs /dev/mapper/system /mnt + +btrfs subvolume create /mnt/nixos +btrfs subvolume create /mnt/home +btrfs subvolume create /mnt/snapshots + +umount /mnt +#+end_src + +Now we can re-mount the partitions with the proper options: +#+begin_src sh +mount -o subvol=nixos,compress=zstd,noatime,autodefrag /dev/mapper/system /mnt + +mkdir /mnt/{home,boot,.snapshots} + +mount -o subvol=home,compress=zstd,noatime,autodefrag /dev/mapper/system /mnt/home +mount -o subvol=snapshots,compress=zstd,noatime /dev/mapper/system /mnt/.snapshots +mount /dev/nvme0n1p3 /mnt/boot +#+end_src + +Once the installation is completed: +#+begin_src sh +CUSTOMIZE_TIMESTAMP=$(date -u +%Y%m%dT%H%M%S) +btrfs subvolume snapshot /mnt /mnt/.snapshots/$CUSTOMIZE_TIMESTAMP +#+end_src +** Installing the system +#+begin_src sh +nixos-generate-config --root /mnt +nixos-install --root /mnt +#+end_src + +Create another snapshot +#+begin_src sh +CUSTOMIZE_TIMESTAMP=$(date -u +%Y%m%dT%H%M%S) +btrfs subvolume snapshot /mnt /mnt/.snapshots/$CUSTOMIZE_TIMESTAMP +#+end_src + +And a =reboot= should be enough. |