diff options
author | Lluís Batlle i Rossell <viric@vicerveza.homeunix.net> | 2010-04-17 15:20:13 +0000 |
---|---|---|
committer | Lluís Batlle i Rossell <viric@vicerveza.homeunix.net> | 2010-04-17 15:20:13 +0000 |
commit | 33ed225a84d2ce053f1acb0a0f4517a04a64dcc9 (patch) | |
tree | 78ddb7d6f980e7c791e7b526db84d5d9e38c80c5 | |
parent | 1c9eb048c960a1864682526284e034b0bfde8445 (diff) | |
download | nixpkgs-33ed225a84d2ce053f1acb0a0f4517a04a64dcc9.tar nixpkgs-33ed225a84d2ce053f1acb0a0f4517a04a64dcc9.tar.gz nixpkgs-33ed225a84d2ce053f1acb0a0f4517a04a64dcc9.tar.bz2 nixpkgs-33ed225a84d2ce053f1acb0a0f4517a04a64dcc9.tar.lz nixpkgs-33ed225a84d2ce053f1acb0a0f4517a04a64dcc9.tar.xz nixpkgs-33ed225a84d2ce053f1acb0a0f4517a04a64dcc9.tar.zst nixpkgs-33ed225a84d2ce053f1acb0a0f4517a04a64dcc9.zip |
Making the /dev and /dev/shm tmpfs sizes configurable.
By default, they take the usual value of "50% of physical RAM". As /dev/shm can be filled by anyone, and tmpfs does not trigger the OOM killer (and can hang the machine due to a lack of RAM), I need to configure that down in order to avoid crashes. There is still left the /var/run/nscd tmpfs filesystem, also created with 50% of the RAM, but at least not writeable by anyone. We could find a reasonable low value for that, or allow configuration. svn path=/nixos/trunk/; revision=21140
-rw-r--r-- | modules/system/boot/stage-2-init.sh | 4 | ||||
-rw-r--r-- | modules/system/boot/stage-2.nix | 36 |
2 files changed, 31 insertions, 9 deletions
diff --git a/modules/system/boot/stage-2-init.sh b/modules/system/boot/stage-2-init.sh index 79836b7d9a8..6035f43d3ad 100644 --- a/modules/system/boot/stage-2-init.sh +++ b/modules/system/boot/stage-2-init.sh @@ -82,9 +82,9 @@ done mkdir -m 0755 -p /sys mount -t sysfs none /sys mkdir -m 0755 -p /dev -mount -t tmpfs -o "mode=0755" none /dev +mount -t tmpfs -o "mode=0755,size=@devSize@" none /dev mkdir -m 0777 /dev/shm -mount -t tmpfs -o "rw,nosuid,nodev" tmpfs /dev/shm +mount -t tmpfs -o "rw,nosuid,nodev,size=@devShmSize@" tmpfs /dev/shm mkdir -m 0755 -p /dev/pts mount -t devpts -o mode=0600,gid=@ttyGid@ none /dev/pts [ -e /proc/bus/usb ] && mount -t usbfs none /proc/bus/usb # uml doesn't have usb by default diff --git a/modules/system/boot/stage-2.nix b/modules/system/boot/stage-2.nix index 2e5e2e524dd..fc510dcbaea 100644 --- a/modules/system/boot/stage-2.nix +++ b/modules/system/boot/stage-2.nix @@ -4,13 +4,34 @@ let options = { - boot.postBootCommands = pkgs.lib.mkOption { - default = ""; - example = "rm -f /var/log/messages"; - merge = pkgs.lib.mergeStringOption; - description = '' - Shell commands to be executed just before Upstart is started. - ''; + boot = { + postBootCommands = pkgs.lib.mkOption { + default = ""; + example = "rm -f /var/log/messages"; + merge = pkgs.lib.mergeStringOption; + description = '' + Shell commands to be executed just before Upstart is started. + ''; + }; + + devSize = pkgs.lib.mkOption { + default = "50%"; + example = "32m"; + description = '' + Size limit for the /dev tmpfs. Look at mount(8), tmpfs size option, + for the accepted syntax. + ''; + }; + + devShmSize = pkgs.lib.mkOption { + default = "50%"; + example = "256m"; + description = '' + Size limit for the /dev/shm tmpfs. Look at mount(8), tmpfs size option, + for the accepted syntax. + ''; + }; + }; }; @@ -23,6 +44,7 @@ let src = ./stage-2-init.sh; isExecutable = true; inherit kernel activateConfiguration; + inherit (config.boot) devSize devShmSize; ttyGid = config.ids.gids.tty; upstart = config.system.build.upstart; path = |