Mounting root...
Paul Mather
paul at gromit.dlib.vt.edu
Sat Sep 11 16:53:47 PDT 2004
On Sat, 2004-09-11 at 17:38, George Hartzell wrote:
> Sorry to follow up my own posting, but I have something that works.
>
> Two changes to /etc/rc.d/swap1
>
> change stop_cmd from ':' to 'swap1_stop'
>
> and change the line in swap1_stop from
>
> swapctl -U -t blk
>
> to
>
> swapoff -a
The /etc/rc.d/swap1 on FreeBSD-CURRENT is very close to that on my
NetBSD-CURRENT box. Here are the diffs:
--- freebsd_swap1 2004-09-11 19:19:18.000000000 -0400
+++ netbsd_swap1 2004-09-11 19:25:03.000000000 -0400
@@ -1,18 +1,17 @@
#!/bin/sh
#
# $NetBSD: swap1,v 1.8 2002/03/24 15:52:41 lukem Exp $
-# $FreeBSD: src/etc/rc.d/swap1,v 1.6 2004/03/08 12:25:05 pjd Exp $
#
# PROVIDE: localswap
# REQUIRE: disks
-# KEYWORD: FreeBSD nojail shutdown
+# KEYWORD: shutdown
. /etc/rc.subr
name="swap1"
-start_cmd='swapon -a'
-stop_cmd=':'
+start_cmd="swap1_start"
+stop_cmd="swap1_stop"
# Add all block-type swap devices; these might be necessary
# during disk checks.
So, although both have swap1_start and swap1_stop functions, under
FreeBSD they're ignored. (I'm presuming when the script was imported
from NetBSD it was left intact and the {start,stop}_cmd definitions
amended to suit the FreeBSD case.)
> To be consistent, one should probably also change the start_cmd to
> swap1_start, and fix that function to use swapon -a since its usage of
> swapctl is also broken. Then, no_swap and swapoff need to be
> defaulted in /etc/defaults/rc.conf.
>
> Or, one could delete the swap1_{start,stop} functions, and just make
> start_cmd be 'swapon -a' and stop_cmd be 'swapoff -a'.
>
> I don't know which is more better, clearly there's some history here
> that's unfinished, or a cross-BSD compatibility thing, or???
Here's my proposed patch:
--- netbsd_swap1 2004-09-11 19:25:03.000000000 -0400
+++ freebsd_swap1 2004-09-11 19:34:24.000000000 -0400
@@ -1,17 +1,18 @@
#!/bin/sh
#
# $NetBSD: swap1,v 1.8 2002/03/24 15:52:41 lukem Exp $
+# $FreeBSD: src/etc/rc.d/swap1,v 1.6 2004/03/08 12:25:05 pjd Exp $
#
# PROVIDE: localswap
# REQUIRE: disks
-# KEYWORD: shutdown
+# KEYWORD: FreeBSD nojail shutdown
. /etc/rc.subr
name="swap1"
-start_cmd="swap1_start"
-stop_cmd="swap1_stop"
+start_cmd='swapon -a'
+stop_cmd='swap1_stop'
# Add all block-type swap devices; these might be
necessary
# during disk checks.
@@ -29,7 +30,7 @@
{
if checkyesno swapoff || [ -n "$rc_force" ]; then
echo "Removing block-type swap devices"
- swapctl -U -t blk
+ swapoff -a
fi
}
This leaves the start_cmd the same, rather than using the swap1_start
function, because swap1_start checks a "no_swap" setting that doesn't
seem to be present on FreeBSD but is on NetBSD. (I don't know if a
missing setting defaults to "NO," making this moot.) Changing stop_cmd
to use the swap1_stop function makes turning off swap conditional on the
"swapoff" setting, instead of unconditional, in the case of setting
"stop_cmd='swapoff -a'". So, I think the above patch preserves the
current behaviour, unless you set 'swapoff="YES"' in /etc/rc.conf, in
which case all swap partitions will be unmounted during shutdown.
Cheers,
Paul.
--
e-mail: paul at gromit.dlib.vt.edu
"Without music to decorate it, time is just a bunch of boring production
deadlines or dates by which bills must be paid."
--- Frank Vincent Zappa
More information about the freebsd-geom
mailing list