···12 # Show each command.
13 set -x
14 ;;
15- resume=*)
16- set -- $(IFS==; echo $o)
17- resumeDevice=$2
18- ;;
19 esac
20done
21···72fi
737475-# Provide a /etc/mtab.
76-install -m 0755 -d /etc
77-test -e /etc/fstab || touch /etc/fstab # to shut up mount
78-rm -f /etc/mtab* # not that we care about stale locks
79-ln -s /proc/mounts /etc/mtab
80-81-82-# More special file systems, initialise required directories.
83-[ -e /proc/bus/usb ] && mount -t usbfs usbfs /proc/bus/usb # UML doesn't have USB by default
84-install -m 01777 -d /tmp
85-install -m 0755 -d /var/{log,lib,db} /nix/var /etc/nixos/ \
86- /run/lock /home /bin # for the /bin/sh symlink
87-88-89-# Miscellaneous boot time cleanup.
90-rm -rf /var/run /var/lock
91-rm -f /etc/{group,passwd,shadow}.lock
92-93-94-# Also get rid of temporary GC roots.
95-rm -rf /nix/var/nix/gcroots/tmp /nix/var/nix/temproots
96-97-98-# For backwards compatibility, symlink /var/run to /run, and /var/lock
99-# to /run/lock.
100-ln -s /run /var/run
101-ln -s /run/lock /var/lock
102-103-104-# Clear the resume device.
105-if test -n "$resumeDevice"; then
106- mkswap "$resumeDevice" || echo 'Failed to clear saved image.'
107-fi
108-109-110# Use /etc/resolv.conf supplied by systemd-nspawn, if applicable.
111if [ -n "@useHostResolvConf@" ] && [ -e /etc/resolv.conf ]; then
112 resolvconf -m 1000 -a host </etc/resolv.conf
113fi
0114115# Log the script output to /dev/kmsg or /run/log/stage-2-init.log.
116# Only at this point are all the necessary prerequisites ready for these commands.
···133$systemConfig/activate
134135136-# Restore the system time from the hardware clock. We do this after
137-# running the activation script to be sure that /etc/localtime points
138-# at the current time zone.
139-if [ -e /dev/rtc ]; then
140- hwclock --hctosys
141-fi
142-143-144# Record the boot configuration.
145ln -sfn "$systemConfig" /run/booted-system
146-147-# Prevent the booted system from being garbage-collected. If it weren't
148-# a gcroot, if we were running a different kernel, switched system,
149-# and garbage collected all, we could not load kernel modules anymore.
150-ln -sfn /run/booted-system /nix/var/nix/gcroots/booted-system
151152153# Run any user-specified commands.
···12 # Show each command.
13 set -x
14 ;;
000015 esac
16done
17···68fi
69700000000000000000000000000000000000071# Use /etc/resolv.conf supplied by systemd-nspawn, if applicable.
72if [ -n "@useHostResolvConf@" ] && [ -e /etc/resolv.conf ]; then
73 resolvconf -m 1000 -a host </etc/resolv.conf
74fi
75+7677# Log the script output to /dev/kmsg or /run/log/stage-2-init.log.
78# Only at this point are all the necessary prerequisites ready for these commands.
···95$systemConfig/activate
96970000000098# Record the boot configuration.
99ln -sfn "$systemConfig" /run/booted-system
00000100101102# Run any user-specified commands.
···117 resume = create_named_machine("resume")
118 resume.start()
119 resume.succeed("grep 'not persisted to disk' /run/test/suspended")
00000120 '';
121122}
···117 resume = create_named_machine("resume")
118 resume.start()
119 resume.succeed("grep 'not persisted to disk' /run/test/suspended")
120+121+ # Ensure we don't restore from hibernation when booting again
122+ resume.crash()
123+ resume.wait_for_unit("default.target")
124+ resume.fail("grep 'not persisted to disk' /run/test/suspended")
125 '';
126127}