swapfile

Daniel Bye freebsd-questions at slightlystrange.org
Tue Dec 14 04:15:26 PST 2004


On Tue, Dec 14, 2004 at 10:35:49AM +0200, Nelis Lamprecht wrote:
> Hi,
> 
> Checked the manual but couldn't find anything regarding this. If you
> have created more than one swap file how do you specify them in your
> rc.conf file ? Manually it works fine but obviously when the machine
> boots I want them both to be used again.
> 
> swapfile="/mailstore/swap1"
> swapfile="/mailstore/swap2"
> 
> The above doesn't work, only the first one is used.

The rc script seems to be written to only allow for one additional
swapfile.  It should be trivial to rewrite to handle multiple files

This diff should apply to /etc/rc.d/addswap to make your setup work.

--- /etc/rc.d/addswap   Tue Dec 14 12:08:41 2004
+++ addswap     Tue Dec 14 12:06:42 2004
@@ -22,10 +22,13 @@
        [Nn][Oo] | '')
                ;;
        *)
-               if [ -w "${swapfile}" -a -c /dev/mdctl ]; then
-                       echo "Adding ${swapfile} as additional swap"
-                       mdev=`mdconfig -a -t vnode -f ${swapfile}` && swapon /dev/${mdev}
+            for sfile in ${swapfile} ]
+            do
+               if [ -w "${sfile}" -a -c /dev/mdctl ]; then
+                       echo "Adding ${sfile} as additional swap"
+                       mdev=`mdconfig -a -t vnode -f ${sfile}` && swapon /dev/${mdev}
                fi
+            done
                ;;
        esac
 }


Keep a copy of the original addswap somewhere!  You will need to specify
both swapfiles in the same declaration:

swapfile="/mailstore/swap1 /mailstore/swap2"

I have only done very basic testing, but it seems to work as you'd
expect.  However, I hereby disclaim any liability...  ;-)

HTH

Dan

-- 
Daniel Bye

PGP Key: ftp://ftp.slightlystrange.org/pgpkey/dan.asc
PGP Key fingerprint: 3B9D 8BBB EB03 BA83 5DB4 3B88 86FC F03A 90A1 BE8F
                                                                     _
                                              ASCII ribbon campaign ( )
                                         - against HTML, vCards and  X
                                - proprietary attachments in e-mail / \
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20041214/2a73cf35/attachment.bin


More information about the freebsd-questions mailing list