This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
manuals:distributions:nixos:impermanence [2024/10/15 19:42] – created aither | manuals:distributions:nixos:impermanence [2024/10/29 17:03] (current) – aither | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | < | ||
====== NixOS Impermanence ====== | ====== NixOS Impermanence ====== | ||
- | <note warning> | + | This page describes usage of [[https:// |
- | This is a work in progress | + | at vpsFree.cz. We support impermanence with root filesystem in a temporary ZFS dataset that is |
- | </note> | + | provided by our platform. It is necessary to move the Nix store to a subdataset, which can be |
+ | done automatically [[# | ||
+ | set it up [[# | ||
+ | |||
+ | Please | ||
+ | and its data reset on each VPS start. The temporary dataset also isn't backed up. Be mindful | ||
+ | of where you store your data. If it isn't in a persistent location, it will be lost. | ||
+ | |||
+ | ===== Using OS template ===== | ||
+ | vpsAdmin contains OS templates where the impermanence module | ||
+ | When creating | ||
+ | The new VPS will have ''/ | ||
+ | to ''/ | ||
+ | See ''/ | ||
+ | ''/ | ||
+ | the git repository to the same path: | ||
+ | |||
+ | <code> | ||
+ | cd /etc/nixos | ||
+ | rm -rf impermanence | ||
+ | git clone https:// | ||
+ | </code> | ||
+ | |||
+ | Note that reinstalling the VPS will be ineffective, | ||
+ | It will not touch the Nix store when it is moved to a subdataset. For the same reason, you | ||
+ | cannot convert an existing VPS to impermanence using reinstall. The OS template will | ||
+ | auto-configure the VPS only on creation. See [[# | ||
+ | enable impermanence on an existing VPS. | ||
+ | |||
+ | ===== Manual configuration ===== | ||
+ | |||
+ | ==== 1. Create a NixOS VPS ==== | ||
+ | Create a new VPS and let it start. You can also reuse your existing NixOS VPS. | ||
+ | |||
+ | ==== 2. Start the VPS in rescue mode ==== | ||
+ | In VPS details, use form **Boot VPS from template (rescue mode)**. It's best | ||
+ | to choose a different distribution than NixOS, so that there' | ||
+ | Use e.g. Alpine or Debian. | ||
+ | |||
+ | ==== 3. Create VPS subdataset for the Nix store ==== | ||
+ | In VPS details, create subdataset '' | ||
+ | want to boot into NixOS in the previous step). You might have to free some diskspace in order to be | ||
+ | able to create the dataset, you can do that by shrinking the root dataset. | ||
+ | |||
+ | ==== 4. Move the Nix store to the subdataset ==== | ||
+ | Login to the VPS while in rescue mode, either over SSH or use the remote console. | ||
+ | The root dataset is mounted at ''/ | ||
+ | ''/ | ||
- | ===== 1. Create a NixOS VPS ===== | ||
- | ===== 2. Start the VPS in rescue mode ===== | ||
- | ===== 3. Create VPS subdataset for the Nix store ===== | ||
- | ===== 4. Move the Nix store to the subdataset ===== | ||
<code bash> | <code bash> | ||
mv / | mv / | ||
</ | </ | ||
- | ===== 5. Mount root file system | + | ==== 5. Mount root dataset |
- | ===== 6. Restart the VPS ===== | + | In the impermanence mode, your root file system will be temporary and cleared on |
- | ===== 7. Edit your configuration and add the impermanence module | + | every start. We must mount our persistent storage to ''/ |
+ | the root dataset, or you can create another subdataset for that purpose. We'll use the root | ||
+ | dataset. In VPS details, click on **Mount** link of the first listed dataset | ||
+ | (its name is the VPS ID) and mount it to ''/ | ||
+ | |||
+ | ==== 6. Restart the VPS ==== | ||
+ | Now restart the VPS, you will leave the rescue mode. | ||
+ | |||
+ | ==== 7. Edit your configuration and add the impermanence module ==== | ||
Clone the impermanence module repository into ''/ | Clone the impermanence module repository into ''/ | ||
- | don't have it in your system, you can use '' | + | don't have it in your system, you can use e.g. '' |
<code bash> | <code bash> | ||
Line 23: | Line 75: | ||
git clone https:// | git clone https:// | ||
</ | </ | ||
+ | |||
+ | Extend your configuration and add the impermanence module: | ||
<file nix / | <file nix / | ||
Line 44: | Line 98: | ||
} | } | ||
</ | </ | ||
- | ===== 8. Turn on impermanence feature ===== | + | |
+ | Note that ''/ | ||
+ | if you like. The datasets will be mounted by vpsAdminOS, so you don't have to configure '' | ||
+ | entries yourself. | ||
+ | |||
+ | When you're done, deploy the new configuration for the next restart: | ||
+ | |||
+ | <code bash> | ||
+ | nixos-rebuild boot | ||
+ | </ | ||
+ | |||
+ | ==== 8. Turn on impermanence feature ==== | ||
+ | In VPS details, enable the **NixOS Impermanence** feature. This will configure your VPS so that it | ||
+ | is started with a clean, temporary dataset. Its contents will be lost on every reboot and it's not | ||
+ | backed up. Turning on the feature will cause the VPS to restart into the configuration we've prepared | ||
+ | in step **7**. | ||
+ | |||
+ | Inside the VPS, you can check the mounted filesystems: | ||
+ | |||
+ | < | ||
+ | root@nixos:/# | ||
+ | tank/ | ||
+ | tank/ | ||
+ | tank/ | ||
+ | </ | ||
+ | |||
+ | ''/'' | ||
+ | contains the Nix store. | ||