summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorhrs <hrs@FreeBSD.org>2013-06-27 18:28:45 +0000
committerhrs <hrs@FreeBSD.org>2013-06-27 18:28:45 +0000
commit8a3748f531c8740f607c4699474b610e9fd67f6c (patch)
tree7de5a51b2bb632b781318a008e0d7c347c3065e4 /etc
parent7f729239c4bb884a13e00c42f6ad2bf2068059d0 (diff)
downloadFreeBSD-src-8a3748f531c8740f607c4699474b610e9fd67f6c.zip
FreeBSD-src-8a3748f531c8740f607c4699474b610e9fd67f6c.tar.gz
- Add vnode-backed swap space specification support. This is enabled when
device names "md" or "md[0-9]*" and a "file" option are specified in /etc/fstab like this: md none swap sw,file=/swap.bin 0 0 - Add GBDE/GELI encrypted swap space specification support, which rc.d/encswap supported. The /etc/fstab lines are like the following: /dev/ada1p1.bde none swap sw 0 0 /dev/ada1p2.eli none swap sw 0 0 .eli devices accepts aalgo, ealgo, keylen, and sectorsize as options. swapctl(8) can understand an encrypted device in the command line like this: # swapctl -a /dev/ada2p1.bde - "-L" flag is added to support "late" option to defer swapon until rc.d/mountlate runs. - rc.d script change: rc.d/encswap -> removed rc.d/addswap -> just display a warning message if $swapfile is defined rc.d/swap1 -> renamed to rc.d/swap rc.d/swaplate -> newly added to support "late" option These changes alleviate a race condition between device creation/removal and swapon/swapoff. MFC after: 1 week Reviewed by: wblock (manual page)
Diffstat (limited to 'etc')
-rw-r--r--etc/defaults/rc.conf5
-rw-r--r--etc/rc.d/Makefile4
-rwxr-xr-xetc/rc.d/addswap55
-rwxr-xr-xetc/rc.d/encswap57
-rwxr-xr-xetc/rc.d/fsck2
-rwxr-xr-xetc/rc.d/mdconfig2
-rwxr-xr-xetc/rc.d/swap (renamed from etc/rc.d/swap1)8
-rwxr-xr-xetc/rc.d/swaplate17
8 files changed, 30 insertions, 120 deletions
diff --git a/etc/defaults/rc.conf b/etc/defaults/rc.conf
index 687b092..dda1855 100644
--- a/etc/defaults/rc.conf
+++ b/etc/defaults/rc.conf
@@ -32,8 +32,6 @@ early_late_divider="FILESYSTEMS" # Script that separates early/late
always_force_depends="NO" # Set to check that indicated dependencies are
# running during boot (can increase boot time).
-swapfile="NO" # Set to name of swapfile if aux swapfile desired.
-swapfile_mdunit="99" # Swapfile md(4) unit number created by mdconfig(8).
apm_enable="NO" # Set to YES to enable APM BIOS functions (or NO).
apmd_enable="NO" # Run apmd to handle APM event from userland.
apmd_flags="" # Flags to apmd (if enabled).
@@ -85,9 +83,6 @@ geli_autodetach="YES" # Automatically detach on last close.
#geli_da1_autodetach="NO"
#geli_mirror_home_flags="-k /etc/geli/home.keys"
-geli_swap_flags="-e aes -l 256 -s 4096 -d" # Options for GELI-encrypted
- # swap partitions.
-
root_rw_mount="YES" # Set to NO to inhibit remounting root read-write.
fsck_y_enable="NO" # Set to YES to do fsck -y if the initial preen fails.
fsck_y_flags="" # Additional flags for fsck -y
diff --git a/etc/rc.d/Makefile b/etc/rc.d/Makefile
index aace4b1..3defd97 100644
--- a/etc/rc.d/Makefile
+++ b/etc/rc.d/Makefile
@@ -37,7 +37,6 @@ FILES= DAEMON \
dhclient \
dmesg \
dumpon \
- encswap \
faith \
fsck \
ftp-proxy \
@@ -139,7 +138,8 @@ FILES= DAEMON \
static_arp \
static_ndp \
stf \
- swap1 \
+ swap \
+ swaplate \
syscons \
sysctl \
syslogd \
diff --git a/etc/rc.d/addswap b/etc/rc.d/addswap
index a6ff187..1758df8 100755
--- a/etc/rc.d/addswap
+++ b/etc/rc.d/addswap
@@ -13,57 +13,12 @@
. /etc/rc.subr
name="addswap"
-start_cmd="addswap_start"
-stop_cmd="addswap_stop"
+start_cmd=":"
+stop_cmd=":"
+rcvar=
-addswap_start()
-{
- case ${swapfile} in
- [Nn][Oo] | '')
- ;;
- *)
- if [ -w "${swapfile}" ]; then
- check_startmsgs && echo "Adding ${swapfile} as additional swap"
-
- if [ -n "${swapfile_mdunit}" ]; then
- mdev="/dev/md${swapfile_mdunit#md}"
- mdconfig -a -t vnode -f "${swapfile}" -u ${swapfile_mdunit}
- else
- mdev="/dev/`mdconfig -a -t vnode -f "${swapfile}"`"
- fi
-
- if [ $? -eq 0 ]; then
- swapon ${mdev}
- else
- echo "error creating swapfile device"
- fi
- fi
- ;;
- esac
-}
-
-addswap_stop()
-{
- case ${swapfile} in
- [Nn][Oo] | '')
- ;;
- *)
- if [ -n "${swapfile_mdunit}" ]; then
- mdev="/dev/md${swapfile_mdunit#md}"
- else
- mdev="/dev/`mdconfig -lv | grep "${swapfile}" | cut -f1`"
- swapfile_mdunit=${mdev#md}
- fi
- if [ -n "${swapfile_mdunit}" ]; then
- swapctl -l | grep -q ${mdev}
- if [ $? -eq 0 ]; then
- echo "Dismounting swapfile ${swapfile}"
- swapoff ${mdev} && mdconfig -d -u ${swapfile_mdunit}
- fi
- fi
- ;;
- esac
-}
+set_rcvar_obsolete swapfile
+set_rcvar_obsolete geli_swap_flags
load_rc_config $name
run_rc_command "$1"
diff --git a/etc/rc.d/encswap b/etc/rc.d/encswap
deleted file mode 100755
index 6221998..0000000
--- a/etc/rc.d/encswap
+++ /dev/null
@@ -1,57 +0,0 @@
-#!/bin/sh
-#
-# $FreeBSD$
-#
-
-# PROVIDE: disks
-# REQUIRE: initrandom
-# KEYWORD: nojail
-
-. /etc/rc.subr
-
-name="encswap"
-start_cmd="encswap_attach"
-stop_cmd="encswap_detach"
-
-encswap_attach()
-{
- while read device mountpoint type options rest ; do
- case ":${device}:${type}:${options}" in
- :#*)
- continue
- ;;
- *.bde:swap:sw)
- passphrase=`dd if=/dev/random count=1 2>/dev/null | md5 -q`
- device="${device%.bde}"
- gbde init "${device}" -P "${passphrase}" || return 1
- gbde attach "${device}" -p "${passphrase}" || return 1
- ;;
- *.eli:swap:sw)
- device="${device%.eli}"
- geli onetime ${geli_swap_flags} "${device}" || return 1
- ;;
- esac
- done < /etc/fstab
-}
-
-encswap_detach()
-{
- while read device mountpoint type options rest ; do
- case ":${device}:${type}:${options}" in
- :#*)
- continue
- ;;
- *.bde:swap:sw)
- device="${device%.bde}"
- gbde detach "${device}"
- ;;
- *.eli:swap:sw)
- # Nothing here, because geli swap devices should be
- # created with the auto-detach-on-last-close option.
- ;;
- esac
- done < /etc/fstab
-}
-
-load_rc_config $name
-run_rc_command "$1"
diff --git a/etc/rc.d/fsck b/etc/rc.d/fsck
index c1fe155..ad06106 100755
--- a/etc/rc.d/fsck
+++ b/etc/rc.d/fsck
@@ -4,7 +4,7 @@
#
# PROVIDE: fsck
-# REQUIRE: localswap
+# REQUIRE: swap
# KEYWORD: nojail
. /etc/rc.subr
diff --git a/etc/rc.d/mdconfig b/etc/rc.d/mdconfig
index c697c35..7b9ddf8 100755
--- a/etc/rc.d/mdconfig
+++ b/etc/rc.d/mdconfig
@@ -28,7 +28,7 @@
#
# PROVIDE: mdconfig
-# REQUIRE: localswap root
+# REQUIRE: swap root
. /etc/rc.subr
diff --git a/etc/rc.d/swap1 b/etc/rc.d/swap
index 71a1908..4122e61 100755
--- a/etc/rc.d/swap1
+++ b/etc/rc.d/swap
@@ -3,15 +3,15 @@
# $FreeBSD$
#
-# PROVIDE: localswap
+# PROVIDE: swap
# REQUIRE: disks
# KEYWORD: nojail shutdown
. /etc/rc.subr
-name="swap1"
-start_cmd='swapon -aq'
+name="swap"
+start_cmd='/sbin/swapon -aq'
stop_cmd=':'
-load_rc_config swap
+load_rc_config $name
run_rc_command "$1"
diff --git a/etc/rc.d/swaplate b/etc/rc.d/swaplate
new file mode 100755
index 0000000..64fa989
--- /dev/null
+++ b/etc/rc.d/swaplate
@@ -0,0 +1,17 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+
+# PROVIDE: swaplate
+# REQUIRE: mountlate
+# KEYWORD: nojail shutdown
+
+. /etc/rc.subr
+
+name="swaplate"
+start_cmd='/sbin/swapon -aLq'
+stop_cmd='/sbin/swapoff -aq'
+
+load_rc_config swap
+run_rc_command "$1"
OpenPOWER on IntegriCloud