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