-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbtrfs-part-directions
62 lines (59 loc) · 2.45 KB
/
btrfs-part-directions
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
Here are the steps to set up, configure, and install NixOS to use btrfs with root and home and Nix subvolumes, and to change the 8GB swap to be 32GB swap:
1. Partition the disk using the following scheme:
- For MBR:
```
# parted /dev/sda -- mklabel msdos
# parted /dev/sda -- mkpart primary 1MB -32GB
# parted /dev/sda -- mkpart primary linux-swap -32GB 100%
```
- For UEFI:
```
# parted /dev/sda -- mklabel gpt
# parted /dev/sda -- mkpart primary 512MB -32GB
# parted /dev/sda -- mkpart primary linux-swap -32GB 100%
# parted /dev/sda -- mkpart ESP fat32 1MB 512MB
# parted /dev/sda -- set 3 esp on
```
2. Format the partitions:
```
# mkfs.btrfs -L nixos /dev/sda1
# mkswap -L swap /dev/sda2
# swapon /dev/sda2
# mkfs.fat -F 32 -n boot /dev/sda3 # (for UEFI systems only)
```
3. Mount the partitions:
```
# mount -o subvol=@ /dev/disk/by-label/nixos /mnt
# mkdir -p /mnt/boot # (for UEFI systems only)
# mount /dev/disk/by-label/boot /mnt/boot # (for UEFI systems only)
```
4. Generate the NixOS configuration:
```
# nixos-generate-config --root /mnt
```
5. Edit the configuration file `/mnt/etc/nixos/configuration.nix` to include the following:
```
boot.loader.grub.device = "/dev/sda";
boot.loader.grub.useBtrfs = true;
boot.loader.grub.btrfsUseSubvol = "@";
boot.initrd.availableKernelModules = [ "btrfs" ];
boot.initrd.kernelModules = [ "btrfs" ];
boot.kernelParams = [ "rootflags=subvol=@" ];
swapDevices = [ { device = "/dev/sda2"; size = "32G"; } ];
```
6. Install NixOS:
```
# nixos-install
```
7. Reboot the system:
```
# reboot
```
These steps assume that you have a running Linux system with GRUB on your primary partition and a spare partition where you want to install NixOS. The steps also assume that you want to use btrfs with root and home and Nix subvolumes, and that you want to change the swap size to 32GB. The steps are based on the information from several sources[1][3][4][5][6].
Citations:
[1] https://nixos.wiki/wiki/Installing_from_Linux
[2] https://discourse.nixos.org/t/nixos-20-09-fresh-vanilla-install-this-gpt-partition-label-contains-no-bios-boot-partition/9903
[3] https://gist.github.com/Vincibean/baf1b76ca5147449a1a479b5fcc9a222
[4] https://earldouglas.com/posts/nix/nixos/installation.html
[5] https://codeberg.org/RobWalt/nixos-installation
[6] https://mgdm.net/weblog/installing-nixos/