aboutsummaryrefslogtreecommitdiff
path: root/src/property/installer.lisp
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2021-07-10 18:54:25 -0700
committerSean Whitton <spwhitton@spwhitton.name>2021-07-10 21:49:23 -0700
commita02892983cd88a0f4e9b451d0765f6e279fabab1 (patch)
tree6db78c85e167b605c756ae41f31a21eb66151a93 /src/property/installer.lisp
parentb658d3b6087770aacc89d10d9ed464c2e9bf31a4 (diff)
downloadconsfigurator-a02892983cd88a0f4e9b451d0765f6e279fabab1.tar.gz
INSTALLER:CLEANLY-INSTALLED-ONCE: handle /run using 'mount --move'
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src/property/installer.lisp')
-rw-r--r--src/property/installer.lisp27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/property/installer.lisp b/src/property/installer.lisp
index ba2e21f..097caef 100644
--- a/src/property/installer.lisp
+++ b/src/property/installer.lisp
@@ -174,19 +174,23 @@ using a combinator like ON-CHANGE, or applied manually with DEPLOY-THESE."
(old-os
(ensure-directories-exist (ensure-directory-pathname old-os)))
(preserved-directories
- '(;; These dirs can contain sockets, remote Lisp image output,
- ;; etc.; avoid upsetting those.
- #P"/run/" #P"/tmp/"
+ '(;; This can contain sockets, remote Lisp image output, etc.;
+ ;; avoid upsetting any of those.
+ #P"/tmp/"
;; Makes sense to keep /proc until we replace the running init,
;; and we want to retain all the systemd virtual filesystems
;; under /sys to avoid problems applying other properties. Both
;; are empty directories right after debootstrap, so nothing to
;; copy out.
- #P"/proc/" #P"/sys/"))
+ #P"/proc/" #P"/sys/"
+ ;; This we make use of below.
+ #P"/old-run/"))
efi-system-partition-mount-args)
(flet ((preservedp (pathname)
(member pathname preserved-directories :test #'pathname-equal)))
(mount:assert-devtmpfs-udev-/dev)
+ (unless (zerop (mrun :for-exit "mountpoint" "-q" "/run"))
+ (failed-change "/run is not a mount point; don't know what to do."))
;; If there's an EFI system partition, we need to store knowledge of
;; how to mount it so that we can restore the mount after doing the
@@ -201,6 +205,17 @@ using a combinator like ON-CHANGE, or applied manually with DEPLOY-THESE."
(setq efi-system-partition-mount-args
`("-t" ,type "-o" ,options ,source "/boot/efi"))))
+ ;; /run is tricky because we want to retain the contents of the tmpfs
+ ;; mounted there until reboot, for similar reasons to wanting to retain
+ ;; /tmp, but unlike /tmp, /proc and /sys, a freshly debootstrapped
+ ;; system contains a few things under /run and we would like to move
+ ;; these out of /new-os. So we temporarily relocate the /run mount.
+ ;;
+ ;; If this causes problems we could reconsider -- there's usually a
+ ;; tmpfs mounted at /run, so those files underneath might not matter.
+ (mrun "mount" "--make-private" "/")
+ (system "mount" "--move" "/run" (ensure-directories-exist "/old-run/"))
+
;; We are not killing any processes, so lazily unmount everything
;; before trying to perform any renames. (Present structure of this
;; loop assumes that each member of PRESERVED-DIRECTORIES is directly
@@ -240,6 +255,10 @@ using a combinator like ON-CHANGE, or applied manually with DEPLOY-THESE."
(signal c))))
(delete-directory-tree new-os :validate t)
+ ;; Restore /run and any submounts, like /run/lock.
+ (system "mount" "--move" "/old-run" "/run")
+ (delete-empty-directory "/old-run")
+
;; For the freshly bootstrapped OS let's assume that HOME is /root and
;; XDG_CACHE_HOME is /root/.cache; we do want to try to read the old
;; OS's actual XDG_CACHE_HOME. Move cache & update environment.