Merge pull request #165684 from helsinki-systems/clean/stage-2-init

nixos/stage-2-init: Clean up legacy commands

authored by Lassulus and committed by GitHub e65b8256 1865515d

+23 -52
+1 -52
nixos/modules/system/boot/stage-2-init.sh
··· 12 12 # Show each command. 13 13 set -x 14 14 ;; 15 - resume=*) 16 - set -- $(IFS==; echo $o) 17 - resumeDevice=$2 18 - ;; 19 15 esac 20 16 done 21 17 ··· 72 68 fi 73 69 74 70 75 - # 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 71 # Use /etc/resolv.conf supplied by systemd-nspawn, if applicable. 111 72 if [ -n "@useHostResolvConf@" ] && [ -e /etc/resolv.conf ]; then 112 73 resolvconf -m 1000 -a host </etc/resolv.conf 113 74 fi 75 + 114 76 115 77 # Log the script output to /dev/kmsg or /run/log/stage-2-init.log. 116 78 # Only at this point are all the necessary prerequisites ready for these commands. ··· 133 95 $systemConfig/activate 134 96 135 97 136 - # 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 98 # Record the boot configuration. 145 99 ln -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 151 100 152 101 153 102 # Run any user-specified commands.
+17
nixos/modules/system/boot/systemd/tmpfiles.nix
··· 100 100 ''; 101 101 }) 102 102 ]; 103 + 104 + systemd.tmpfiles.rules = [ 105 + "d /etc/nixos 0755 root root - -" 106 + "d /nix/var 0755 root root - -" 107 + "L+ /nix/var/nix/gcroots/booted-system 0755 root root - /run/booted-system" 108 + "d /run/lock 0755 root root - -" 109 + "d /var/db 0755 root root - -" 110 + "L /etc/mtab - - - - ../proc/mounts" 111 + "L /var/lock - - - - ../run/lock" 112 + # Boot-time cleanup 113 + "R! /etc/group.lock - - - - -" 114 + "R! /etc/passwd.lock - - - - -" 115 + "R! /etc/shadow.lock - - - - -" 116 + "R! /etc/mtab* - - - - -" 117 + "R! /nix/var/nix/gcroots/tmp - - - - -" 118 + "R! /nix/var/nix/temproots - - - - -" 119 + ]; 103 120 }; 104 121 }
+5
nixos/tests/hibernate.nix
··· 117 117 resume = create_named_machine("resume") 118 118 resume.start() 119 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") 120 125 ''; 121 126 122 127 }