diff options
author | Maciej Krüger <mkg20001@gmail.com> | 2020-04-01 03:54:21 +0200 |
---|---|---|
committer | Maciej Krüger <mkg20001@gmail.com> | 2020-04-01 03:56:32 +0200 |
commit | 948de104de09cc27184d97aed2fe3b758133cc8e (patch) | |
tree | be753b1addf94b2de7b01508cb1bc25b7b130935 /nixos/modules/system/boot/stage-1-init.sh | |
parent | 4c23f686990b22d1df931e9fa3ee6d58964fefa6 (diff) |
stage-1-init: add boot.persistence option
This option allows replacing the tmpfs mounted on / by the live CD's init script with a physical device Since nixOS symlinks everything there's no trouble at all. That enables the user to easily use a nixOS live CD as a portable installation. Note that due to some limitations in how the store is mounted currently only the non-store things are persisted.
Diffstat (limited to 'nixos/modules/system/boot/stage-1-init.sh')
-rw-r--r-- | nixos/modules/system/boot/stage-1-init.sh | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/nixos/modules/system/boot/stage-1-init.sh b/nixos/modules/system/boot/stage-1-init.sh index 607aec87f01e5..54e3a691b2f83 100644 --- a/nixos/modules/system/boot/stage-1-init.sh +++ b/nixos/modules/system/boot/stage-1-init.sh @@ -144,6 +144,14 @@ for o in $(cat /proc/cmdline); do set -- $(IFS==; echo $o) stage2Init=$2 ;; + boot.persistence=*) + set -- $(IFS==; echo $o) + persistence=$2 + ;; + boot.persistence.opt=*) + set -- $(IFS==; echo $o) + persistence_opt=$2 + ;; boot.trace|debugtrace) # Show each command. set -x @@ -534,6 +542,14 @@ while read -u 3 mountPoint; do continue fi + if [ "$mountPoint" = / ] && [ "$device" = tmpfs ] && [ ! -z "$persistence" ]; then + echo persistence... + waitDevice "$persistence" + echo enabling persistence... + mountFS "$persistence" "$mountPoint" "$persistence_opt" "auto" + continue + fi + mountFS "$device" "$mountPoint" "$options" "$fsType" done |