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
This commit is contained in:
parent
1c9eb048c9
commit
33ed225a84
|
@ -82,9 +82,9 @@ done
|
||||||
mkdir -m 0755 -p /sys
|
mkdir -m 0755 -p /sys
|
||||||
mount -t sysfs none /sys
|
mount -t sysfs none /sys
|
||||||
mkdir -m 0755 -p /dev
|
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
|
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
|
mkdir -m 0755 -p /dev/pts
|
||||||
mount -t devpts -o mode=0600,gid=@ttyGid@ none /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
|
[ -e /proc/bus/usb ] && mount -t usbfs none /proc/bus/usb # uml doesn't have usb by default
|
||||||
|
|
|
@ -4,7 +4,8 @@ let
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
|
|
||||||
boot.postBootCommands = pkgs.lib.mkOption {
|
boot = {
|
||||||
|
postBootCommands = pkgs.lib.mkOption {
|
||||||
default = "";
|
default = "";
|
||||||
example = "rm -f /var/log/messages";
|
example = "rm -f /var/log/messages";
|
||||||
merge = pkgs.lib.mergeStringOption;
|
merge = pkgs.lib.mergeStringOption;
|
||||||
|
@ -13,6 +14,26 @@ let
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inherit (pkgs) substituteAll writeText coreutils utillinux udev;
|
inherit (pkgs) substituteAll writeText coreutils utillinux udev;
|
||||||
|
@ -23,6 +44,7 @@ let
|
||||||
src = ./stage-2-init.sh;
|
src = ./stage-2-init.sh;
|
||||||
isExecutable = true;
|
isExecutable = true;
|
||||||
inherit kernel activateConfiguration;
|
inherit kernel activateConfiguration;
|
||||||
|
inherit (config.boot) devSize devShmSize;
|
||||||
ttyGid = config.ids.gids.tty;
|
ttyGid = config.ids.gids.tty;
|
||||||
upstart = config.system.build.upstart;
|
upstart = config.system.build.upstart;
|
||||||
path =
|
path =
|
||||||
|
|
Loading…
Reference in New Issue