···1212 # Show each command.
1313 set -x
1414 ;;
1515- resume=*)
1616- set -- $(IFS==; echo $o)
1717- resumeDevice=$2
1818- ;;
1915 esac
2016done
2117···7268fi
736974707575-# Provide a /etc/mtab.
7676-install -m 0755 -d /etc
7777-test -e /etc/fstab || touch /etc/fstab # to shut up mount
7878-rm -f /etc/mtab* # not that we care about stale locks
7979-ln -s /proc/mounts /etc/mtab
8080-8181-8282-# More special file systems, initialise required directories.
8383-[ -e /proc/bus/usb ] && mount -t usbfs usbfs /proc/bus/usb # UML doesn't have USB by default
8484-install -m 01777 -d /tmp
8585-install -m 0755 -d /var/{log,lib,db} /nix/var /etc/nixos/ \
8686- /run/lock /home /bin # for the /bin/sh symlink
8787-8888-8989-# Miscellaneous boot time cleanup.
9090-rm -rf /var/run /var/lock
9191-rm -f /etc/{group,passwd,shadow}.lock
9292-9393-9494-# Also get rid of temporary GC roots.
9595-rm -rf /nix/var/nix/gcroots/tmp /nix/var/nix/temproots
9696-9797-9898-# For backwards compatibility, symlink /var/run to /run, and /var/lock
9999-# to /run/lock.
100100-ln -s /run /var/run
101101-ln -s /run/lock /var/lock
102102-103103-104104-# Clear the resume device.
105105-if test -n "$resumeDevice"; then
106106- mkswap "$resumeDevice" || echo 'Failed to clear saved image.'
107107-fi
108108-109109-11071# Use /etc/resolv.conf supplied by systemd-nspawn, if applicable.
11172if [ -n "@useHostResolvConf@" ] && [ -e /etc/resolv.conf ]; then
11273 resolvconf -m 1000 -a host </etc/resolv.conf
11374fi
7575+1147611577# Log the script output to /dev/kmsg or /run/log/stage-2-init.log.
11678# Only at this point are all the necessary prerequisites ready for these commands.
···13395$systemConfig/activate
1349613597136136-# Restore the system time from the hardware clock. We do this after
137137-# running the activation script to be sure that /etc/localtime points
138138-# at the current time zone.
139139-if [ -e /dev/rtc ]; then
140140- hwclock --hctosys
141141-fi
142142-143143-14498# Record the boot configuration.
14599ln -sfn "$systemConfig" /run/booted-system
146146-147147-# Prevent the booted system from being garbage-collected. If it weren't
148148-# a gcroot, if we were running a different kernel, switched system,
149149-# and garbage collected all, we could not load kernel modules anymore.
150150-ln -sfn /run/booted-system /nix/var/nix/gcroots/booted-system
151100152101153102# Run any user-specified commands.
···117117 resume = create_named_machine("resume")
118118 resume.start()
119119 resume.succeed("grep 'not persisted to disk' /run/test/suspended")
120120+121121+ # Ensure we don't restore from hibernation when booting again
122122+ resume.crash()
123123+ resume.wait_for_unit("default.target")
124124+ resume.fail("grep 'not persisted to disk' /run/test/suspended")
120125 '';
121126122127}