On 13-10-11 04:25 PM, Jim Pingle wrote:
They are that small because ALIX is the usual NanoBSD target and it only
has 256MB of RAM so it's a safe low default. NanoBSD wasn't originally
intended to run on device with gobs of RAM, but times are a-changin' and
before long all of the viable new hardware will have >1GB of RAM.

On 2.1 you can adjust the /var and /tmp sizes under System > Advanced on
the Miscellaneous tab.

It might be possible to auto-scale the sizes with a bit of extra logic
in rc.embedded if someone wants to take a crack at it.

Challenge accepted.

I have no idea how to clone the repo and do a pull request, so I'm just attaching a simple diff instead.

I believe sysctl is available at this point in the boot process. If not, then the solution will be quite a bit more difficult...

I'm not sure what the point would be in continuing if sysctl *failed*, but what the heck, I just assume a 256MB machine.

Obviously a lot more special-casing could be done to ensure lower- and upper-bound cases function correctly; I only handled one simplistic case.

The invocation to get $physmem ensures we don't needlessly fork()/exec() on an embedded platform.

--
-Adam Thompson
 [email protected]

--- rc.embedded.orig	2013-10-11 16:35:10.691385354 -0500
+++ rc.embedded	2013-10-11 17:26:55.779500598 -0500
@@ -8,7 +8,12 @@
 if [ ! -z ${USE_MFS_TMP_SIZE} ] && [ ${USE_MFS_TMP_SIZE} -gt 0 ]; then
 	tmpsize="${USE_MFS_TMP_SIZE}m"
 else
-	tmpsize="40m"
+	physmem=${physmem:-$(/sbin/sysctl -n hw.physmem)}
+	# in case we can't execute /sbin/sysctl, assume 256MB machine
+	physmem=${physmem:-282563637}
+	tmpsize=$((physmem*15/104857600))
+	if [ $tmpsize -le 40 ]; then varsize=40; fi
+	tmpsize="${tmpsize}m"
 fi
 
 # Size of /var
@@ -16,7 +21,11 @@
 if [ ! -z ${USE_MFS_VAR_SIZE} ] && [ ${USE_MFS_VAR_SIZE} -gt 0 ]; then
 	varsize="${USE_MFS_VAR_SIZE}m"
 else
-	varsize="60m"
+	physmem=${physmem:-$(/sbin/sysctl -n hw.physmem)}
+	physmem=${physmem:-282563637}
+	varsize=$((physmem*25/104857600))
+	if [ $varsize -lt 60 ]; then varsize=60; fi
+	varsize="${varsize}m"
 fi
 
 # Run some initialization routines
_______________________________________________
List mailing list
[email protected]
http://lists.pfsense.org/mailman/listinfo/list

Reply via email to