From 0451a762d2ced82b15e56c9e36a7596a94b7c75d Mon Sep 17 00:00:00 2001 From: An-Cheng Huang Date: Sat, 14 May 2011 00:07:45 +0800 Subject: raise max number of inodes for config tmpfs mount --- etc/init.d/vyatta-router | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'etc/init.d/vyatta-router') diff --git a/etc/init.d/vyatta-router b/etc/init.d/vyatta-router index c9b9786..87e96f7 100755 --- a/etc/init.d/vyatta-router +++ b/etc/init.d/vyatta-router @@ -188,8 +188,22 @@ mount_slash_config () start () { log_action_begin_msg "Mounting Vyatta Config" - mount -o nosuid,nodev,mode=775 -t tmpfs none ${vyatta_configdir} && \ - chgrp ${GROUP} ${vyatta_configdir} + # ensure the vyatta_configdir supports a large number of inodes since + # the config hierarchy is often inode-bound (instead of size). + # impose a minimum and then scale up dynamically with the actual size + # of the system memory. + local tmem=$(sed -n 's/^MemTotal: \+\([0-9]\+\) kB$/\1/p' /proc/meminfo) + local tpages + local max_inodes=300000 + if [ -n "$tmem" ]; then + (( tpages = tmem / 4 )) + if (( tpages > max_inodes )); then + (( max_inodes = tpages )) + fi + fi + local tmpfs_opts="nosuid,nodev,mode=775,nr_inodes=$max_inodes" + mount -o $tmpfs_opts -t tmpfs none ${vyatta_configdir} \ + && chgrp ${GROUP} ${vyatta_configdir} log_action_end_msg $? disabled bootfile || init_bootfile -- cgit v1.2.3