1<section xmlns="http://docbook.org/ns/docbook"
2 xmlns:xlink="http://www.w3.org/1999/xlink"
3 xmlns:xi="http://www.w3.org/2001/XInclude"
4 version="5.0"
5 xml:id="sec-rollback">
6 <title>Rolling Back Configuration Changes</title>
7
8 <para>
9 After running <command>nixos-rebuild</command> to switch to a new
10 configuration, you may find that the new configuration doesn’t work very
11 well. In that case, there are several ways to return to a previous
12 configuration.
13 </para>
14
15 <para>
16 First, the GRUB boot manager allows you to boot into any previous
17 configuration that hasn’t been garbage-collected. These configurations can
18 be found under the GRUB submenu “NixOS - All configurations”. This is
19 especially useful if the new configuration fails to boot. After the system
20 has booted, you can make the selected configuration the default for
21 subsequent boots:
22<screen>
23# /run/current-system/bin/switch-to-configuration boot</screen>
24 </para>
25
26 <para>
27 Second, you can switch to the previous configuration in a running system:
28<screen>
29# nixos-rebuild switch --rollback</screen>
30 This is equivalent to running:
31<screen>
32# /nix/var/nix/profiles/system-<replaceable>N</replaceable>-link/bin/switch-to-configuration switch</screen>
33 where <replaceable>N</replaceable> is the number of the NixOS system
34 configuration. To get a list of the available configurations, do:
35<screen>
36$ ls -l /nix/var/nix/profiles/system-*-link
37<replaceable>...</replaceable>
38lrwxrwxrwx 1 root root 78 Aug 12 13:54 /nix/var/nix/profiles/system-268-link -> /nix/store/202b...-nixos-13.07pre4932_5a676e4-4be1055
39</screen>
40 </para>
41</section>