about summary refs log tree commit diff
path: root/docs/install.org
blob: 386ebc0be2397036586a065a4d3efd89ce2e392a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#+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
btrfs subvolume create /mnt/home/fcuny/media

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}
mkdir -p /mnt/home/fcuny/media

mount -o subvol=home,compress=zstd,noatime,autodefrag /dev/mapper/system /mnt/home
mount -o subvol=media,compress=zstd,noatime,autodefrag /dev/mapper/system /mnt/home/fcuny/media
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.