Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 11 Mar 2001 13:17:58 -0800 (PST)
From:      David Wolfskill <david@catwhisker.org>
To:        current@freebsd.org
Subject:   swap-backed md-based /tmp to replace mfs-based one
Message-ID:  <200103112117.f2BLHw561727@bunrab.catwhisker.org>

next in thread | raw e-mail | index | archive | help
During the past week, I've been tracking -STABLE (daily) & -CURRENT (about
2 days out of 3) on a new laptop.  (More stuff about that in the recent
-mobile archives, for folks who might have an interest.)

Although I realize that there are significant differences between the
FreeBSD mfs vs. the Sun tmpfs, using an mfs-based, swap-backed /tmp has
generally been working well for me over the last 3 years of using FreeBSD.
(I tend to be generous with swap diskspace allocations, which helps.)

And on this laptop, I have 3 different bootable "root" (& associated /usr)
partitions, so I can run -CURRENT, as well as run either of a couple of
-STABLEs.  But since I'm running no more than one at a time, it made sense
to me to have the swap space be common to all three environments, and to
make /tmp be swap-backed.

In -STABLE, I merely stuffed an appropriate entry in /etc/fstab, and It
Just Worked.  However, based on the example in the mdconfig man page on
-CURRENT, I get the impression that the process is a little more
involved.

Accordingly, I created the following shell script to accomplish a
similar objective, based upon the above-mentioned example in the
mdconfig man page.  At present, I have it sitting in
/usr/local/etc/rc.d, which isn't ideal, but I wanted to find out if
anyone had better approaches for doing this, suggestions for
improvement, or arguments that what I'm trying to do is misguided and
shouldn't be done:

#!/bin/sh

size=512M       # Plugged directly in to the mdconfig command,
		# so use an expression that's compatible with that.

case "$1" in
start)
	# Taken from the mdconfig man page, then lightly hacked:
	#     To create and mount a 128MByte swap backed filesystem on /tmp:
	if [ -x /sbin/mdconfig ]; then
		/sbin/mdconfig -a -t swap -s $size -u 10 && \
		/sbin/disklabel -r -w md10 auto && \
		/sbin/newfs /dev/md10c && \
		/sbin/tunefs -n enable /dev/md10c && \
		/sbin/mount /dev/md10c /tmp && \
		/bin/chmod 1777 /tmp && \
		exit 0
	fi
	;;
stop)
	dev=`/sbin/mount | /usr/bin/awk '/ \/tmp / {print $1}'` || exit 1
	/sbin/umount /tmp && [ -c $dev ] && /sbin/mdconfig -d -u $dev
	exit 0
	;;
*)
	echo "Usage: `basename $0` {start|stop}" >&2
	;;
esac

exit 2



Thanks,
david
-- 
David H. Wolfskill				david@catwhisker.org
As a computing professional, I believe it would be unethical for me to
advise, recommend, or support the use (save possibly for personal
amusement) of any product that is or depends on any Microsoft product.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200103112117.f2BLHw561727>