Skip to content

Commit b6168ba

Browse files
Enzimemergify[bot]
authored andcommitted
nixos-anywhere: move unmount into reboot phase
This means that users can now access the mounted filesystems by omitting the `reboot` phase. You can combine this with `--disko-mode mount` to mount and upgrade an existing system before running `nixos-enter` to run commands on it. $ nixos-anywhere --disko-mode mount --phases kexec,disko,install
1 parent 63eae64 commit b6168ba

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

docs/reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Options:
7373
kexec: kexec into the nixos installer
7474
disko: first unmount and destroy all filesystems on the disks we want to format, then run the create and mount mode
7575
install: install the system
76-
reboot: reboot the machine
76+
reboot: unmount the filesystems, export any ZFS pools and reboot the machine
7777
* --disko-mode disko|mount|format
7878
set the disko mode to format, mount or destroy. Default is disko.
7979
disko: first unmount and destroy all filesystems on the disks we want to format, then run the create and mount mode

src/nixos-anywhere.sh

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ Options:
116116
kexec: kexec into the nixos installer
117117
disko: first unmount and destroy all filesystems on the disks we want to format, then run the create and mount mode
118118
install: install the system
119-
reboot: reboot the machine
119+
reboot: unmount the filesystems, export any ZFS pools and reboot the machine
120120
* --disko-mode disko|mount|format
121121
set the disko mode to format, mount or destroy. Default is disko.
122122
disko: first unmount and destroy all filesystems on the disks we want to format, then run the create and mount mode
@@ -574,10 +574,6 @@ nixosInstall() {
574574
fi
575575

576576
step Installing NixOS
577-
maybeReboot=""
578-
if [[ ${phases[reboot]} == 1 ]]; then
579-
maybeReboot="nohup sh -c 'sleep 6 && reboot' >/dev/null &"
580-
fi
581577
runSsh sh <<SSH
582578
set -eu ${enableDebug}
583579
# when running not in nixos we might miss this directory, but it's needed in the nixos chroot during installation
@@ -599,12 +595,14 @@ if [ ${copyHostKeys-n} = "y" ]; then
599595
done
600596
fi
601597
nixos-install --no-root-passwd --no-channel-copy --system "$nixosSystem"
602-
if command -v zpool >/dev/null && [ "\$(zpool list)" != "no pools available" ]; then
603-
# we always want to export the zfs pools so people can boot from it without force import
604-
umount -Rv /mnt/
605-
zpool export -a || true
598+
if [[ ${phases[reboot]} == 1 ]]; then
599+
if command -v zpool >/dev/null && [ "\$(zpool list)" != "no pools available" ]; then
600+
# we always want to export the zfs pools so people can boot from it without force import
601+
umount -Rv /mnt/
602+
zpool export -a || true
603+
fi
604+
nohup sh -c 'sleep 6 && reboot' >/dev/null &
606605
fi
607-
${maybeReboot}
608606
SSH
609607

610608
}

0 commit comments

Comments
 (0)