Open davidak opened 5 years ago
I have this in configuration.nix
:
{
boot = {
tmpOnTmpfs = true;
tmpOnTmpfsSize = "10G";
};
}
Then,
$ systemctl cat tmp.mount
# /etc/systemd/system/tmp.mount
[Unit]
[Mount]
Options=mode=1777,strictatime,rw,nosuid,nodev,size=10G
Type=tmpfs
What=tmpfs
Where=/tmp
$ df -h /tmp
Filesystem Size Used Avail Use% Mounted on
tmpfs 10G 36M 10G 1% /tmp
The value of size
is an option that's interpreted by the tmpfs
filesystem driver and documented in the tmpfs
man page. Percentage values are relative to available RAM, so 50%
allows /tmp
to use up to 50% of your RAM.
@neilmayhew
I have this in
configuration.nix
:{ boot = { tmpOnTmpfs = true; tmpOnTmpfsSize = "10G"; }; }
...
The value of
size
is an option that's interpreted by thetmpfs
filesystem driver and documented in thetmpfs
man page. Percentage values are relative to available RAM, so50%
allows/tmp
to use up to 50% of your RAM.
This works for me indeed. Thanks :+1:. I was confused by the docs for the option tmpOnTmpfsSize
. I think they are incomplete/incorrect. It is unclear what 100% means, and the option to specify size directly (as you did) is omitted. Do you agree? Should we submit a pull request for the change?
@MikiVanousek what's the content of
/etc/fstab
and the output ofmount
? Alsoboot.tmpOnTmpfs
,boot.tmpOnTmpfsSize
override this via a different mechanism and will probably conflict if bothfileSystems."/tmp"
andboot.tmpOnTmpfs
is used. Output ofls /etc/systemd/system/*.mount
would also be useful.
@zseri It indeed conflicted with tmpOnTmpfsSize
. Thanks for your help :+1:!
I was confused by the docs for the option
tmpOnTmpfsSize
. I think they are incomplete/incorrect. It is unclear what 100% means, and the option to specify size directly (as you did) is omitted. Do you agree? Should we submit a pull request for the change?
I don't agree, actually. The docs say,
Percentage is defined by systemd.
which is correct. The value is put straight into tmp.mount
and not interpreted by NixOS at all, so it would be inappropriate to duplicate systemd's documentation here as it may not stay up to date.
Systemd's documentation for Options
says,
Mount options to use when mounting
so these values aren't interpreted by systemd either. They're given to mount
and finally interpreted by the tmpfs
driver. The documentation for that says,
The tmpfs filesystem supports the following mount options:
size=bytes Specify an upper limit on the size of the filesystem. [etc.]
I don't think the trail to that is particularly hard to follow, but perhaps it would save some inconvenience if the documentation was changed to say:
Size of the tmpfs mounted on
/tmp
. Given tosystemd.mount(5)
as-is and ultimately passed totmpfs(5)
.
An optional attribute buildSpaceRequired with an example value of "16G" (compatible with GNU dd units) for packages that require a lot of space to build would help save wasted builds in the future.
At least it would be great if we could establish some good upper bounds for memory required the few massive builds (chromium, firefox, what else?).
The default 50%
on my 16GB laptop results in an 8GB
/tmp
, which isn't enough for chromiumDev. @cole-h said 16GB was sufficient. Trying with
> sudo mount -o remount,size=80% /tmp
> mount|grep /tmp
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,size=12888740k)
Issue description
I'm trying to rebuild with staging branch.
But the rebuild fails:
Steps to reproduce
boot.tmpOnTmpfs = true;
rebuild on staging, building all the things
Workaround
mount -o remount,size=15G /tmp
Technical details
"x86_64-linux"
Linux 4.19.16, NixOS, 19.03.git.8291376 (Koi)
yes
yes
nix-env (Nix) 2.2
"nixos-18.09.1829.0396345b794, nixos-hardware, nixos-unstable-19.03pre164715.201d739b0ff"
/nix/var/nix/profiles/per-user/root/channels/nixos