|
5 | 5 |
|
6 | 6 | ## Setup
|
7 | 7 |
|
8 |
| -### matebook |
9 |
| - |
10 |
| -#### Partition layout |
11 |
| - |
12 |
| -| Partition | Type | Size | |
13 |
| -|-----------|-------|---------| |
14 |
| -| p1 | boot | 512 MiB | |
15 |
| -| p2 | SWAP | 16 GiB | |
16 |
| -| p3 | btrfs | - | |
17 |
| - |
18 |
| -#### Create encrypted partition and btrfs subvolumes |
19 |
| - |
20 |
| -```bash |
21 |
| -export DISK=/dev/nvme0n1 |
22 |
| - |
23 |
| -cryptsetup --verify-passphrase -v luksFormat "$DISK"p3 |
24 |
| -cryptsetup open "$DISK"p3 enc |
25 |
| - |
26 |
| -mkfs.vfat -n boot "$DISK"p1 |
27 |
| -mkswap "$DISK"p2 |
28 |
| -swapon "$DISK"p2 |
29 |
| -mkfs.btrfs /dev/mapper/enc |
30 |
| - |
31 |
| -mount -t btrfs /dev/mapper/enc /mnt |
32 |
| - |
33 |
| -btrfs subvolume create /mnt/home |
34 |
| -btrfs subvolume create /mnt/nix |
35 |
| -btrfs subvolume create /mnt/persist |
36 |
| - |
37 |
| -umount /mnt |
38 |
| -``` |
39 |
| - |
40 |
| -#### Mount tmpfs, partitions and subvolumes and generate config |
41 |
| - |
42 |
| ---- |
43 |
| -**FIXME:** Mounting a ramdisk as root may be a bad idea for installation since |
44 |
| -building the config needs a lot of disk space. Consider mounting some temporary |
45 |
| -folder and deleting it afterwards or giving the tmpfs more ram. |
46 |
| - |
47 |
| ---- |
48 |
| - |
49 |
| -```bash |
50 |
| -mount -t tmpfs none /mnt |
51 |
| - |
52 |
| -mkdir -p /mnt/{boot,home,nix,persist} |
53 |
| -mount "$DISK"p1 /mnt/boot |
54 |
| -mount -o subvol=home,compress=zstd,noatime /dev/mapper/enc /mnt/home |
55 |
| -mount -o subvol=nix,compress=zstd,noatime /dev/mapper/enc /mnt/nix |
56 |
| -mount -o subvol=persist,compress=zstd,noatime /dev/mapper/enc /mnt/persist |
57 |
| - |
58 |
| -nixos-generate-config --root /mnt |
59 |
| -``` |
60 |
| - |
61 |
| -Compare the generated hardware-configuration.nix with machines/matebook/hardware-configuration.nix, |
62 |
| -adjust and push to GitHub if needed. |
63 |
| - |
64 |
| -#### Copy matebook ssh key to home directory |
65 |
| - |
66 |
| -```bash |
67 |
| -mkdir -p /mnt/home/jakob/.ssh |
68 |
| -cp /path/to/.ssh/id_ed25519* /mnt/home/jakob/.ssh |
69 |
| -``` |
70 |
| - |
71 |
| -#### Install and reboot |
72 |
| - |
73 |
| -```bash |
74 |
| -nixos-install --flake github:jakobkukla/nixos-config#matebook |
75 |
| -reboot |
76 |
| -``` |
77 |
| - |
78 |
| -#### Switch to root user and update nix channels to fix the command-not-found script |
79 |
| - |
80 |
| ---- |
81 |
| -**TODO:** Replace command-not-found.pl with nix-index and find |
82 |
| -a way to circumvent building the index manually. |
83 |
| - |
84 |
| ---- |
85 |
| - |
86 |
| -```bash |
87 |
| -nix-channel --update |
88 |
| -``` |
89 |
| - |
90 |
| -### pc |
91 |
| - |
92 |
| -#### Partition layout |
93 |
| - |
94 |
| -| Partition | Type | Size | |
95 |
| -|-----------|-------|---------| |
96 |
| -| p1 | boot | 512 MiB | |
97 |
| -| p2 | zfs | - | |
98 |
| - |
99 |
| -#### Create encrypted zfs pool, system container and datasets |
100 |
| - |
101 |
| -Note the ashift value during zpool creation. From the Arch wiki: |
102 |
| - |
103 |
| -Use -o ashift=9 for disks with a 512 byte physical sector size or -o ashift=12 |
104 |
| -for disks with a 4096 byte physical sector size. See `lsblk -S -o NAME,PHY-SEC` |
105 |
| -to get the physical sector size of each SCSI/SATA disk. Remove -S if you want |
106 |
| -the same value from all devices. |
107 |
| -For NVMe drives, use `nvme id-ns /dev/nvmeXnY -H | grep "LBA Format"` |
108 |
| -to get which LBA format is in use. |
109 |
| - |
110 |
| -```bash |
111 |
| -export DISK=/dev/nvme0n1 |
112 |
| - |
113 |
| -mkfs.vfat -n boot "$DISK"p1 |
114 |
| - |
115 |
| -# Create ZFS root pool |
116 |
| -zpool create \ |
117 |
| - -o ashift=9 \ |
118 |
| - -o autotrim=on \ |
119 |
| - -R /mnt \ |
120 |
| - -O acltype=posixacl \ |
121 |
| - -O canmount=off \ |
122 |
| - -O compression=on \ |
123 |
| - -O dnodesize=auto \ |
124 |
| - -O relatime=on \ |
125 |
| - -O xattr=sa \ |
126 |
| - -O mountpoint=none \ |
127 |
| - rpool \ |
128 |
| - "$DISK"p2 |
129 |
| - |
130 |
| -# Create encrypted ZFS root system container |
131 |
| -zfs create \ |
132 |
| - -o canmount=off \ |
133 |
| - -o mountpoint=none \ |
134 |
| - -o encryption=on \ |
135 |
| - -o keylocation=prompt \ |
136 |
| - -o keyformat=passphrase \ |
137 |
| - rpool/nixos |
138 |
| - |
139 |
| -zfs create -o mountpoint=legacy rpool/nixos/root |
140 |
| -zfs snapshot rpool/nixos/root@blank |
141 |
| - |
142 |
| -zfs create -o mountpoint=legacy rpool/nixos/home |
143 |
| -zfs create -o mountpoint=legacy rpool/nixos/nix |
144 |
| -zfs create -o mountpoint=legacy rpool/nixos/persist |
145 |
| -``` |
146 |
| - |
147 |
| -#### Mount tmpfs, partitions and datasets and generate config |
148 |
| - |
149 |
| -```bash |
150 |
| -mount -t zfs rpool/nixos/root /mnt |
151 |
| - |
152 |
| -mkdir -p /mnt/{boot,home,nix,persist} |
153 |
| -mount "$DISK"p1 /mnt/boot |
154 |
| -mount -t zfs rpool/nixos/home /mnt/home |
155 |
| -mount -t zfs rpool/nixos/nix /mnt/nix |
156 |
| -mount -t zfs rpool/nixos/persist /mnt/persist |
157 |
| - |
158 |
| -nixos-generate-config --root /mnt |
159 |
| -``` |
160 |
| - |
161 |
| -Compare the generated hardware-configuration.nix with |
162 |
| -machines/pc/hardware-configuration.nix, adjust and push to GitHub if needed. |
163 |
| - |
164 |
| -#### Copy pc ssh key to home directory |
165 |
| - |
166 |
| -```bash |
167 |
| -mkdir -p /mnt/home/jakob/.ssh |
168 |
| -cp /path/to/.ssh/id_ed25519* /mnt/home/jakob/.ssh |
169 |
| -``` |
170 |
| - |
171 |
| -#### Install and reboot |
172 |
| - |
173 |
| -```bash |
174 |
| -nixos-install --no-root-password --flake github:jakobkukla/nixos-config#pc |
175 |
| -reboot |
176 |
| -``` |
177 |
| - |
178 |
| -#### Switch to root user and update nix channels to fix the command-not-found script |
179 |
| - |
180 |
| ---- |
181 |
| -**TODO:** Replace command-not-found.pl with nix-index |
182 |
| -and find a way to circumvent building the index manually. |
183 |
| - |
184 |
| ---- |
185 |
| - |
186 |
| -```bash |
187 |
| -nix-channel --update |
188 |
| -``` |
| 8 | +Setup instructions for specific machines can be found in `machines/<machine>`. |
| 9 | + |
| 10 | +| Machine | Setup Instructions | |
| 11 | +|-----------|------------------------------| |
| 12 | +| matebook | [README](machines/matebook) | |
| 13 | +| pc | [README](machines/pc) | |
| 14 | +| server | [README](machines/server) | |
| 15 | +| hifiberry | [README](machines/hifiberry) | |
189 | 16 |
|
190 | 17 | ## Test in VM
|
191 | 18 |
|
|
0 commit comments