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 swapoff flag #454

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,6 @@ Options:
build the closure on the remote machine instead of locally and copy-closuring it
* --vm-test
build the system and test the disk configuration inside a VM without installing it to the target.
* --swapoff
turn off swap devices during reboot phase. Enable this if creating a ZFS swap device so it is exported.
```
10 changes: 9 additions & 1 deletion src/nixos-anywhere.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ diskoMode="disko"
nixosSystem=""
extraFiles=""
vmTest="n"
swapoff="n"
nixOptions=(
--extra-experimental-features 'nix-command flakes'
"--no-write-lock-file"
Expand Down Expand Up @@ -117,6 +118,8 @@ Options:
* --generate-hardware-config nixos-facter|nixos-generate-config <path>
generate a hardware-configuration.nix file using the specified backend and write it to the specified path.
The backend can be either 'nixos-facter' or 'nixos-generate-config'.
* --swapoff
turn off swap devices during reboot phase. Enable this if creating a ZFS swap device so it is exported.
* --phases
comma separated list of phases to run. Default is: kexec,disko,install,reboot
kexec: kexec into the nixos installer
Expand Down Expand Up @@ -289,6 +292,9 @@ parseArgs() {
--vm-test)
vmTest=y
;;
--swapoff)
swapoff=y
;;
*)
if [[ -z ${sshConnection} ]]; then
sshConnection="$1"
Expand Down Expand Up @@ -619,7 +625,9 @@ if [[ ${phases[reboot]} == 1 ]]; then
if command -v zpool >/dev/null && [ "\$(zpool list)" != "no pools available" ]; then
# we always want to export the zfs pools so people can boot from it without force import
umount -Rv /mnt/
swapoff -a
if [[ ${swapoff} == "y" ]]; then
swapoff -a
fi
zpool export -a || true
fi
nohup sh -c 'sleep 6 && reboot' >/dev/null &
Expand Down
Loading