Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stage2 - replace tmp.mount with tmpfs handling on bootup/activation #14778

Closed
wants to merge 1 commit into from

Conversation

sheenobu
Copy link
Contributor

@sheenobu sheenobu commented Apr 17, 2016

Things done
  • Tested using sandboxing (nix-build --option build-use-chroot true or nix.useChroot on NixOS)
  • Built on platform(s)
    • NixOS
    • OS X
    • Linux
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

Fixes #14777 and #10670

Haven't tested yet. would love some help on how to do that =)

Built an ova. testing now~

@mention-bot
Copy link

By analyzing the blame information on this pull request, we identified @ehmry, @edolstra and @peti to be potential reviewers

@lucabrunox
Copy link
Contributor

I wonder why /tmp can't be a reulgar filesystem under fileSystems ? It's like we're reinventing all the options for it that are already available with fileSystems.

@sheenobu
Copy link
Contributor Author

sheenobu commented Apr 17, 2016

@lethalman We do not want /tmp to be subject to changes to configuration unless it is during stage-2. There is an open issue for this, #10670, but it doesn't explain why. Changing how /tmp is mounted without a reboot will hose programs which have written to /tmp.

You can do it yourself, via tmpOnTmpfs = false and a custom fileSystem entry, but doing it by default would violate the principal of least surprise. Especially since current documentation on /tmp suggests changes to how /tmp is mounted only happens at boot.

@ehmry
Copy link
Contributor

ehmry commented Apr 17, 2016

It seems I was the one who originally created the tmpOnTmpfs option. I just wanted a convient boolean rather than having to consult the mount man page for tmpfs options and define a mount outside of hardware-configuration.nix.

I am totally ok with taking this out of systemd's hands.

@@ -158,8 +158,11 @@ in
${pkgs.utillinux}/bin/mount -o "remount,size=${config.boot.devSize}" none /dev
${pkgs.utillinux}/bin/mount -o "remount,size=${config.boot.devShmSize}" none /dev/shm
${pkgs.utillinux}/bin/mount -o "remount,size=${config.boot.runSize}" none /run
'';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A + optionalString config.boot.tmpOnTmpfs "blah blah"; would be better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taken care of, thanks.

@@ -158,8 +158,11 @@ in
${pkgs.utillinux}/bin/mount -o "remount,size=${config.boot.devSize}" none /dev
${pkgs.utillinux}/bin/mount -o "remount,size=${config.boot.devShmSize}" none /dev/shm
${pkgs.utillinux}/bin/mount -o "remount,size=${config.boot.runSize}" none /run
'' + optionalString config.boot.tmpOnTmpfs ''
if [ mountpoint -q /tmp ]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what happens if a user says boot.tmpOnTmpfs = true but /tmp is not a valid mount point? The current solution is to fail silently, but that doesn't seem ideal?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

boot.tmpOnTmpfs is only going to apply /on boot/. The activation-script shouldn't attempt to remount if you set boot.tmpOnTmpfs to true without rebooting.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That said... the stage-2-init.sh script doesn't seem to do much error handling of mount points fail during boot?

@edolstra
Copy link
Member

I agree with @lethalman that it would be nicer to handle this via fileSystems. The neededForBoot flag could be set automatically for /tmp to cause it to be mounted early (just as we do for /var, /nix etc.). Preventing /tmp from being mounted in a running system could probably be accomplished by dropping the dependency on tmp.mount in basic.target (I think that should be enough to stop switch-to-configuration starting it).

@sheenobu
Copy link
Contributor Author

I agree with @lethalman that it would be nicer to handle this via fileSystems

Still on the fence as fileSystem changes are applied during switch-to-configuration (correct me if I'm wrong, please) where /tmp is a place we don't want that to happen.

Preventing /tmp from being mounted in a running system could probably be accomplished by dropping the dependency on tmp.mount in basic.target (I think that should be enough to stop switch-to-configuration starting it).

Good point, though i'm wary about messing with basic.target (since it's core systemd and not a nixos provided unit). basic.target has a whole special case for tmp.mount

@NotaseCretagen
Copy link
Contributor

FYI, this is what happens if using systemd to mount /tmp as tmpfs in this way

@sheenobu
Copy link
Contributor Author

Any new thoughts on this? Possible candidate for inclusion in 16.09?

@joachifm joachifm added this to the 16.09 milestone Jul 28, 2016
@joachifm
Copy link
Contributor

I've added this to the 16.09 milestone in the hopes that the issue gets resolved one way or another.

@cmfwyp
Copy link
Member

cmfwyp commented Aug 4, 2016

@sheenobu

Still on the fence as fileSystem changes are applied during switch-to-configuration (correct me if I'm wrong, please) where /tmp is a place we don't want that to happen.

Applying the configuration directly is what nixos-rebuild switch is supposed to do, though. The nixos-rebuild boot command can be used to set it up now but only activate the configuration on next boot. I think that if configuration changes can break the system, the system administrator should simply not use nixos-rebuild switch and should instead set the configuration to be activated on next boot. One rationale for this is that there are already plenty of ways to break things on a running system with nixos-rebuild switch.

Removing tmp.mount from basic.target isn't an elegant solution, but it's still more elegant than duplicating the options specifically for tmp, and without removing tmp.mount from basic.target I would still prefer the fileSystems approach, which will work just fine as long as nixos-rebuild boot is used instead of nixos-rebuild switch.

@domenkozar
Copy link
Member

Note that this PR needs to be addressed in next days if it wants to reach 16.09

@domenkozar domenkozar removed this from the 16.09 milestone Aug 31, 2016
@sheenobu sheenobu closed this Oct 10, 2016
@sheenobu sheenobu deleted the bugfix/tmpfs_on_boot branch October 10, 2016 03:37
@sheenobu sheenobu restored the bugfix/tmpfs_on_boot branch October 10, 2016 03:37
@domenkozar
Copy link
Member

@sheenobu why was it closed?

@sheenobu sheenobu reopened this Oct 10, 2016
@sheenobu
Copy link
Contributor Author

@domenkozar it was an accident due to branch cleanup.

@mmahut
Copy link
Member

mmahut commented Aug 3, 2019

What is the status of this pull request?

@mmahut
Copy link
Member

mmahut commented Aug 19, 2019

Closing due to lack of activity, feel free to reopen this if needed.

@mmahut mmahut closed this Aug 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

/tmp tmpfs is using the systemd upstream mount.