Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add howto to repair nixos installations #395

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/howtos/INDEX.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

[Using your own kexec image](./custom-kexec.md)

[Repair installations without wiping data](./disko-modes.md)

[Secrets and full disk encryption](./secrets.md)

[Use without flakes](./use-without-flakes.md)
Expand Down
19 changes: 19 additions & 0 deletions docs/howtos/disko-modes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Repair installations without wiping data

By default, nixos-anywhere will reformat all configured disks before running the
installation. However it is also possible to mount the filesystems of an
existing installation and run `nixos-install`. This is useful to recover from a
mis-configured NixOS installation by first booting into a NixOS installer or
recovery system.

To only mount existing filesystems, add `--disko-mode mount` to
`nixos-anywhere`:

```
nix run github:nix-community/nixos-anywhere -- --disko-mode mount --flake <path to configuration>#<configuration name> root@<ip address>
```

1. This will first boot into a nixos-installer
2. Mounts disks with disko
3. Runs nixos-install based on the provided flake
4. Reboots the machine.
4 changes: 2 additions & 2 deletions docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,13 @@ If you also need to generate hardware configuration amend flags for
nixos-generate-config:

```
nix run --generate-hardware-config nixos-generate-config ./hardware-configuration.nix github:nix-community/nixos-anywhere -- --flake <path to configuration>#<configuration name> root@<ip address>
nix run github:nix-community/nixos-anywhere -- --generate-hardware-config nixos-generate-config ./hardware-configuration.nix --flake <path to configuration>#<configuration name> root@<ip address>
```

Or these flags if you are using nixos-facter instead:

```
nix run --generate-hardware-config nixos-facter ./facter.json github:nix-community/nixos-anywhere -- --flake <path to configuration>#<configuration name> root@<ip address>
nix run github:nix-community/nixos-anywhere -- --generate-hardware-config nixos-facter ./facter.json --flake <path to configuration>#<configuration name> root@<ip address>
```

Adjust the location of `./hardware-configuration.nix` and `./facter.json`
Expand Down
8 changes: 4 additions & 4 deletions docs/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ Options:
disko: first unmount and destroy all filesystems on the disks we want to format, then run the create and mount mode
install: install the system
reboot: reboot the machine
* --disko-mode create|mount|disko
set the disko mode to create, mount or destroy. Default is disko.
format: create partition tables, zpools, lvms, raids and filesystems (Experimental: Can be run increntally, but use with caution and good backups)
mount: mount the partition at the specified root-mountpoint
* --disko-mode disko|mount|format
set the disko mode to format, mount or destroy. Default is disko.
disko: first unmount and destroy all filesystems on the disks we want to format, then run the create and mount mode
mount: mount the partition at the specified root-mountpoint
format: create partition tables, zpools, lvms, raids and filesystems (Experimental: Can be run increntally, but use with caution and good backups)
```

## Explanation of known error messages
Expand Down
12 changes: 6 additions & 6 deletions src/nixos-anywhere.sh
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ Options:
disko: first unmount and destroy all filesystems on the disks we want to format, then run the create and mount mode
install: install the system
reboot: reboot the machine
* --disko-mode create|mount|disko
set the disko mode to create, mount or destroy. Default is disko.
format: create partition tables, zpools, lvms, raids and filesystems (Experimental: Can be run increntally, but use with caution and good backups)
mount: mount the partition at the specified root-mountpoint
* --disko-mode disko|mount|format
set the disko mode to format, mount or destroy. Default is disko.
disko: first unmount and destroy all filesystems on the disks we want to format, then run the create and mount mode
mount: mount the partition at the specified root-mountpoint
format: create partition tables, zpools, lvms, raids and filesystems (Experimental: Can be run increntally, but use with caution and good backups)
USAGE
}

Expand Down Expand Up @@ -209,11 +209,11 @@ parseArgs() {
;;
--disko-mode)
case "$2" in
create | mount | disko)
format | mount | disko)
diskoMode=$2
;;
*)
abort "Supported values for --disko-mode create, mount, disko. Unknown mode : $2"
abort "Supported values for --disko-mode are disko, mount and format. Unknown mode : $2"
;;
esac

Expand Down
Loading