GNOME Bugzilla – Bug 743891
prepare-root: avoid double-stacked /sysroot mount
Last modified: 2015-03-04 21:02:09 UTC
Created attachment 295980 [details] [review] patch prepare-root works with the mount that has been set up at /sysroot. It creates a bind-mount within /sysroot (the deployment) and then moves that mount to /sysroot. Now we have 2 mounts both at /sysroot, and once we do switch_root, we will never be able to unmount both of them. I'm not sure if this is ultimately a kernel bug, but either way, ostree could do a bit more tidying up after itself. http://thread.gmane.org/gmane.linux.file-systems/92411 Easy way to reproduce: 1. Boot with rd.break param 2. At initramfs shell, run: ostree-prepare-root /sysroot 3. Observe two /sysroot mounts in /proc/mounts Fix this by setting up the mounts at /sysroot.tmp, and unmounting the original /sysroot before our new mount is MS_MOVEd on top of it.
Hmm...but this will cause us to hold a reference to a directory on the initramfs, right? Which isn't the end of the world, but not doing so helps shave real memory. Can we instead do something like this?
Created attachment 296051 [details] [review] prepare-root: Unmount old /sysroot mount point We were previously overmounting it, which meant it was hard to clean up on shutdown.
I don't quite follow, what does "hold a reference to a directory" mean and which directory is the one you are concerned about?
Ah, I just read your patch again and I see you're making sysroot.tmp on the "physical /", so indeed it wouldn't hold a reference to the initramfs. But then the issues I see are: - Leaves a tempdir around - Breaks booting from readonly media (See https://git.gnome.org/browse/ostree/commit/?id=ff6883ca0655ac8844cd783caf6a7d8815515ba3 ) What do you think about my patch? (I didn't test it yet)
umount2() is the function you want there, but it doesn't quite work - both /sysroot mounts get unmounted.
Can you clarify your concerns about the readonly media issue? I tested as follows: - boot into initramfs with rd.break - mount -o remount,ro /sysroot - ostree-prepare-root /sysroot # my version - switch_root /sysroot /bin/bash Then I ran a trivial C app that does statvfs on /var and it showed the readonly flag, as is the case with the unmodified ostree-prepare-root.
I made this to play around, still debugging a few things: https://gist.github.com/cgwalters/f5869dddaa2236f13671
Ah, right, you're making it in the initramfs, then we move the mount. That makes sense. I'll test.
Review of attachment 295980 [details] [review]: Works for me. I also pushed a followup commit which added a few more comments. Thanks for the patch and pushing back on my overly hasty initial review =)
I tested this patch against a Fedora Atomic system, and it worked. But it definitely broke gnome-continuous; the system root doesn't have /sysroot mounted. What do you think about the following patch? I am not sure offhand why it breaks Continuous but not Fedora.
Created attachment 296735 [details] [review] 0001-prepare-root-Move-sysroot-instead-of-unmounting-it.patch
Looks reasonable, although I'm a bit uneasy not understanding what went wrong.
This turned out to be an issue with systemd git master, I see: systemd[1]: Unit sysroot.mount is bound to inactive service. Stopping, too. I think we may just need a RemainAfterExit= in ostree-remount.service. Testing...
This was all pushed. The bug is being addressed in systemd.