| | @@ -1,68 +1,111 @@ |
| 1 | 1 | # Moving from CachyOS to NixOS |
| 2 | 2 | |
| 3 | | -The plan keeps your disk as it is. NixOS goes into new btrfs subvolumes next |
| 4 | | -to CachyOS's, and `/home` stays the same `@home` subvolume. Your files, game |
| 5 | | -libraries, app data, `~/.ssh`, Firefox profile and Steam settings never move, |
| 6 | | -and CachyOS stays bootable until you remove it. |
| 3 | +The install wipes the whole NVMe drive (`nvme0n1`, the 980 PRO) and lays it out |
| 4 | +again with disko, as `hosts/desktop/disko.nix` describes. CachyOS and everything |
| 5 | +in it are gone afterwards, so your home folder goes to the Kingston SATA SSD |
| 6 | +(`sda`) first and comes back after the install. Game installs aren't backed up |
| 7 | +(see `backup-filter`): Steam games and WoW download again. WoW's settings and |
| 8 | +addons are kept. |
| 9 | + |
| 10 | +The other SATA SSD (`sdb`) isn't touched at any point. disko only knows the |
| 11 | +NVMe drive, by its serial number. |
| 12 | + |
| 13 | +## 1. Before you start (on CachyOS) |
| 14 | + |
| 15 | +- [ ] Push this repo and the latest `Eiziv/philly`. |
| 16 | +- [ ] Get the NixOS installer (26.05, minimal is enough) on a USB stick, and |
| 17 | + make sure Secure Boot is off in the firmware, as it is for Limine now. |
| 18 | +- [ ] Optional, but this is the last chance: record WoW's performance on |
| 19 | + CachyOS, to compare with NixOS later. In Faugus, edit Battle.net, turn |
| 20 | + on MangoHud and add this line to the launch arguments: |
| 21 | + `MANGOHUD_CONFIG=read_cfg,output_folder=/home/vizie/benchmarks,log_duration=60`. |
| 22 | + In game, stand somewhere you can return to (a busy city), keep the camera |
| 23 | + still and press Left Shift+F2. Do it three times. The logs land in |
| 24 | + `~/benchmarks`, which the backup includes. |
| 25 | + |
| 26 | +**Prepare the backup drive.** This erases `sda`, the 112 GB Kingston, which |
| 27 | +is empty now. Check that the name points at `sda` first: |
| 28 | + |
| 29 | +```bash |
| 30 | +ls -l /dev/disk/by-id/ata-KINGSTON_SA400S37120G_50026B76820FD3CE |
| 31 | +sudo mkfs.btrfs -L backup /dev/disk/by-id/ata-KINGSTON_SA400S37120G_50026B76820FD3CE |
| 32 | +sudo mkdir -p /mnt/backup |
| 33 | +sudo mount -o compress=zstd /dev/disk/by-label/backup /mnt/backup |
| 34 | +sudo install -d -o vizie /mnt/backup/nix-cache /mnt/backup/wow |
| 35 | +``` |
| 36 | + |
| 37 | +**Save the built system.** The finished system and the disko script go onto |
| 38 | +the backup drive, so the installer doesn't have to build anything (or compile |
| 39 | +the CachyOS kernel, if its binary cache is still down): |
| 40 | + |
| 41 | +```bash |
| 42 | +cd ~/git/dot |
| 43 | +sys=$(nix build --no-link --print-out-paths .#nixosConfigurations.desktop.config.system.build.toplevel) |
| 44 | +disko=$(nix build --no-link --print-out-paths .#nixosConfigurations.desktop.config.system.build.diskoScript) |
| 45 | +nix copy --to 'file:///mnt/backup/nix-cache?compression=zstd' "$sys" "$disko" |
| 46 | +echo "$sys" > /mnt/backup/nix-cache/system |
| 47 | +echo "$disko" > /mnt/backup/nix-cache/disko |
| 48 | +``` |
| 49 | + |
| 50 | +**Back up WoW's settings and addons** (`WTF` is keybinds, macros and addon |
| 51 | +settings, `Interface` is the addons): |
| 52 | + |
| 53 | +```bash |
| 54 | +cp -a ~/Games/battlenet/drive_c/'Program Files (x86)'/'World of Warcraft'/_retail_/{WTF,Interface} /mnt/backup/wow/ |
| 55 | +``` |
| 56 | + |
| 57 | +**Back up your home folder.** Quit Signal, Discord, Firefox, Claude and the |
| 58 | +games first, so their databases aren't copied halfway through a write. About |
| 59 | +83 GB before compression, and the saved system adds roughly 10 GB, so it fits |
| 60 | +the 112 GB drive with some room. If it runs out of space, leave out repos that |
| 61 | +are pushed to GitHub (the biggest are `git/skate3`, 23 GB, and `git/philly`, |
| 62 | +16 GB) with an extra `--exclude=/git/skate3/`: |
| 7 | 63 | |
| 8 | | -## 1. Before you start |
| 64 | +```bash |
| 65 | +sudo rsync -aHAXx --info=progress2 --filter='merge /home/vizie/git/dot/backup-filter' /home/vizie/ /mnt/backup/vizie/ |
| 66 | +``` |
| 9 | 67 | |
| 10 | | -- [ ] Push this repo (`git push`) and the latest `Eiziv/philly`. The install |
| 11 | | - fetches philly from GitHub. |
| 12 | | -- [ ] Back up what you can't get back to another disk or machine, in case |
| 13 | | - something goes wrong with the partition: `~/.ssh`, `~/.config/keys` |
| 14 | | - (the imsh upload key), `~/.config/Signal` (including `config.json`, which |
| 15 | | - holds the key to Signal's database), `~/.config/mozilla`, game saves that |
| 16 | | - aren't in a cloud. |
| 17 | | -- [ ] Optional: a read-only snapshot of /home to roll back to: |
| 18 | | - `sudo btrfs subvolume snapshot -r /home /home/.snapshot-pre-nixos` |
| 19 | | -- [ ] Get the NixOS installer (26.05, graphical or minimal) on a USB stick. |
| 68 | +Check that it looks complete (`ls -a /mnt/backup/vizie`, `du -sh /mnt/backup/*`), |
| 69 | +then `sudo umount /mnt/backup`. |
| 20 | 70 | |
| 21 | 71 | ## 2. Install |
| 22 | 72 | |
| 23 | | -Boot the installer. Wired network works out of the box. |
| 73 | +Boot the installer. Wired network works out of the box; the install itself |
| 74 | +doesn't need it. |
| 24 | 75 | |
| 25 | 76 | ```bash |
| 26 | 77 | sudo -i |
| 27 | 78 | |
| 28 | | -# The btrfs partition's top level, to make NixOS's subvolumes. |
| 29 | | -mkdir -p /mnt/top |
| 30 | | -mount -o subvolid=5 /dev/nvme0n1p2 /mnt/top |
| 31 | | -btrfs subvolume create /mnt/top/@nixos |
| 32 | | -btrfs subvolume create /mnt/top/@nix |
| 33 | | -btrfs subvolume create /mnt/top/@nixos-log |
| 34 | | -umount /mnt/top |
| 79 | +# The backup drive, read-only. Not under /mnt: disko unmounts everything there. |
| 80 | +mkdir /backup |
| 81 | +mount -o ro /dev/disk/by-label/backup /backup |
| 82 | +sys=$(cat /backup/nix-cache/system) |
| 83 | +disko=$(cat /backup/nix-cache/disko) |
| 35 | 84 | |
| 36 | | -# Mount the new system the way hosts/desktop/hardware-configuration.nix does. |
| 37 | | -o=noatime,compress=zstd |
| 38 | | -mount -o subvol=@nixos,$o /dev/nvme0n1p2 /mnt |
| 39 | | -mkdir -p /mnt/{nix,var/log,home,boot} |
| 40 | | -mount -o subvol=@nix,$o /dev/nvme0n1p2 /mnt/nix |
| 41 | | -mount -o subvol=@nixos-log,$o /dev/nvme0n1p2 /mnt/var/log |
| 42 | | -mount -o subvol=@home,$o /dev/nvme0n1p2 /mnt/home |
| 43 | | -mount /dev/nvme0n1p1 /mnt/boot |
| 85 | +# The disko script. It doesn't ask before it wipes, so check that the drive it |
| 86 | +# names is the 980 PRO (nvme0n1) one last time. |
| 87 | +ls -l /dev/disk/by-id/nvme-Samsung_SSD_980_PRO_1TB_S5GXNF1R877751D |
| 88 | +nix --extra-experimental-features nix-command copy --no-check-sigs --from file:///backup/nix-cache "$disko" |
| 44 | 89 | |
| 45 | | -# Compare the generated hardware config with the one in the repo; if the |
| 46 | | -# kernel modules or anything else differ, keep the generated lines. |
| 47 | | -nixos-generate-config --root /mnt --show-hardware-config > /tmp/hw.nix |
| 48 | | -diff /tmp/hw.nix /mnt/home/vizie/git/dot/hosts/desktop/hardware-configuration.nix |
| 49 | | - |
| 50 | | -# philly is a private repo: sign in to GitHub for this root shell. |
| 51 | | -nix --extra-experimental-features 'nix-command flakes' shell nixpkgs#gh -c gh auth login |
| 52 | | -git config --global credential.helper '!gh auth git-credential' |
| 90 | +# Wipe, partition, format and mount the NVMe drive at /mnt. |
| 91 | +"$disko" |
| 53 | 92 | |
| 54 | | -# Install. The extra cache is where the CachyOS kernel comes from. |
| 55 | | -nixos-install --flake /mnt/home/vizie/git/dot#desktop \ |
| 56 | | - --option extra-substituters https://attic.xuyh0120.win/lantian \ |
| 57 | | - --option extra-trusted-public-keys lantian:EeAUQ+W+6r7EtwnmYjeVwx5kOGEBpjlBfPlzGlTNvHc= |
| 93 | +# Copy the system onto it and install it, with the boot loader. |
| 94 | +nix --extra-experimental-features nix-command copy --no-check-sigs \ |
| 95 | + --from file:///backup/nix-cache --to 'local?root=/mnt' "$sys" |
| 96 | +nixos-install --system "$sys" --no-channel-copy |
| 97 | +# It asks for a root password at the end. |
| 58 | 98 | |
| 59 | | -# It asks for a root password at the end. Then set yours: |
| 99 | +# Your home folder back, owned by you (uid 1000, group users). |
| 100 | +rsync -aHAX --info=progress2 --chown=1000:100 /backup/vizie/ /mnt/home/vizie/ |
| 60 | 101 | nixos-enter --root /mnt -c 'passwd vizie' |
| 61 | 102 | reboot |
| 62 | 103 | ``` |
| 63 | 104 | |
| 64 | | -The NixOS boot menu (systemd-boot) becomes the default. CachyOS's Limine stays |
| 65 | | -in the firmware boot menu (F8 at the ASUS logo), and also on the ESP, next to it. |
| 105 | +If something in `/backup/nix-cache` is missing, install from the flake instead |
| 106 | +(this needs the network, and compiles the kernel if its cache is down): |
| 107 | +`nixos-install --flake /backup/vizie/git/dot#desktop` after |
| 108 | +`nix run github:nix-community/disko/latest -- --mode destroy,format,mount /backup/vizie/git/dot/hosts/desktop/disko.nix`. |
| 66 | 109 | |
| 67 | 110 | ## 3. First boot |
| 68 | 111 | |
| | @@ -112,16 +155,30 @@ |
| 112 | 155 | - **sched-ext** schedulers stay off, as before. See the comment in |
| 113 | 156 | `modules/nixos/cachyos.nix` to try one. |
| 114 | 157 | |
| 115 | | -## 5. Going back to CachyOS |
| 158 | +## 5. Games |
| 116 | 159 | |
| 117 | | -It still boots (firmware boot menu). Its `~/.config` links now point into |
| 118 | | -NixOS's store, which CachyOS doesn't have, so rerun the old repo's script there: |
| 119 | | -`~/git/dotfiles/symlink.sh`. |
| 160 | +- **Steam**: your settings, Proton versions and game saves (`compatdata`) are |
| 161 | + back. The games in `~/Games/SteamLibrary` and Steam's own library show as |
| 162 | + not installed; install them again. Steam may need the library folder |
| 163 | + re-added (Settings → Storage). |
| 164 | +- **WoW**: in Faugus, remove the old Battle.net entry and add Battle.net again |
| 165 | + (Faugus installs it into a new prefix at `~/Games/battlenet`). Pick the same |
| 166 | + runner, `Proton-CachyOS Latest` (it's back in |
| 167 | + `~/.local/share/Steam/compatibilitytools.d`), and the same launch arguments: |
| 168 | + `WINE_SIMULATE_WRITECOPY=1` and `PROTON_ENABLE_WAYLAND=0`. Install WoW, then |
| 169 | + copy your settings and addons back before you start it: |
| 170 | + |
| 171 | + ```bash |
| 172 | + sudo mount -o ro /dev/disk/by-label/backup /mnt |
| 173 | + cp -a /mnt/wow/{WTF,Interface} ~/Games/battlenet/drive_c/'Program Files (x86)'/'World of Warcraft'/_retail_/ |
| 174 | + sudo umount /mnt |
| 175 | + ``` |
| 176 | + |
| 177 | +- **OSRS**: Bolt installs itself again (see First boot); its data in |
| 178 | + `~/.var/app/com.adamcake.Bolt` came back with your home folder, so you |
| 179 | + stay signed in. |
| 120 | 180 | |
| 121 | 181 | ## 6. Once you're happy |
| 122 | 182 | |
| 123 | | -Remove CachyOS: boot NixOS, mount the top level, delete its subvolumes |
| 124 | | -(`@`, `@root`, `@srv`, `@cache`, `@tmp`, `@log`), then its kernels and Limine |
| 125 | | -files from the ESP (look first: `sudo ls -R /boot`; NixOS's own files are |
| 126 | | -`/boot/EFI/nixos`, `/boot/EFI/systemd`, `/boot/EFI/BOOT` and `/boot/loader`), |
| 127 | | -and its firmware boot entry (`efibootmgr`). |
| 183 | +The backup on `sda` stays until you need the drive for something else. NixOS |
| 184 | +doesn't mount it; `sudo mount /dev/disk/by-label/backup /mnt` gets you into it. |