rc.subr: mount_md autosize and auto-swapsence prooposal

Dmitry Morozovsky marck at rinet.ru
Sun Aug 13 16:43:27 UTC 2006


Dear colleagues,

several monthes ago there was some discussions about mdmfs file system flags.

What do you think about the patch attached?

Sincerely,
D.Marck                                     [DM5020, MCK-RIPE, DM3-RIPN]
------------------------------------------------------------------------
*** Dmitry Morozovsky --- D.Marck --- Wild Woozle --- marck at rinet.ru ***
------------------------------------------------------------------------
-------------- next part --------------
Index: etc/rc.subr
===================================================================
RCS file: /home/ncvs/src/etc/rc.subr,v
retrieving revision 1.64
diff -u -r1.64 rc.subr
--- etc/rc.subr	26 Jul 2006 08:03:24 -0000	1.64
+++ etc/rc.subr	13 Aug 2006 16:40:41 -0000
@@ -1351,10 +1351,30 @@
 #   $3 = (optional) extra mdmfs flags
 mount_md()
 {
+	case $1 in
+	[Aa][Uu][Tt][Oo])
+		# autosize memory disk to 1/8 of physical memory,
+		# but in range 8..128M
+		size=$((`${SYSCTL_N} hw.physmem` / 8388608))
+		if [ $size -lt 8 ]; then
+			size=8
+		fi
+		if [ $size -gt 128 ]; then
+			size=128
+		fi
+		size="${size}M"
+		;;
+	*)
+		size=$1
+	esac
 	if [ -n "$3" ]; then
 		flags="$3"
 	fi
-	/sbin/mdmfs $flags -s $1 md $2
+	# for swapless machines, add -M flag to fix md in memory
+	if [ `${SYSCTL_N} vm.nswapdev` = "0" ]; then
+		flags="-M $flags"
+	fi
+	/sbin/mdmfs $flags -s $size md $2
 }
 
 # Code common to scripts that need to load a kernel module
Index: etc/defaults/rc.conf
===================================================================
RCS file: /home/ncvs/src/etc/defaults/rc.conf,v
retrieving revision 1.291
diff -u -r1.291 rc.conf
--- etc/defaults/rc.conf	5 Aug 2006 20:28:50 -0000	1.291
+++ etc/defaults/rc.conf	13 Aug 2006 16:40:41 -0000
@@ -42,11 +42,11 @@
 powerd_flags=""		# Flags to powerd (if enabled).
 removable_route_flush="YES" # Flush routes when removing an interface
 tmpmfs="AUTO"		# Set to YES to always create an mfs /tmp, NO to never
-tmpsize="20m"		# Size of mfs /tmp if created
-tmpmfs_flags="-S -M"	# Extra mdmfs options for the mfs /tmp
+tmpsize="20m"		# Size of mfs /tmp if created, AUTO to 1/8 of memory
+tmpmfs_flags="-S"	# Extra mdmfs options for the mfs /tmp
 varmfs="AUTO"		# Set to YES to always create an mfs /var, NO to never
 varsize="32m"		# Size of mfs /var if created
-varmfs_flags="-S -M"	# Extra mount options for the mfs /var
+varmfs_flags="-S"	# Extra mount options for the mfs /var
 populate_var="AUTO"	# Set to YES to always (re)populate /var, NO to never
 cleanvar_enable="YES" 	# Clean the /var directory
 local_startup="/usr/local/etc/rc.d /usr/X11R6/etc/rc.d" # startup script dirs.


More information about the freebsd-current mailing list