Summary: Quick plug in swap space? - PART 2 of 4

From: Daniel_V._D'
Date: Mon Jul 17 1995 - 11:34:22 CDT

From: (Andy Feldt)
 See the man pages for: (SunOS 4.x) mkfile, fstab, swapon
                                (SunOS 5.x) mkfile, vfstab, swap

In short,

   (SunOS 4.x)
                mkfile 100m /some/file
                edit /etc/fstab adding: /some/file swap swap rw 0 0
                swapon -a

   (SunOS 5.x)
                mkfile 100m /some/file
                swap -a /some/file # for use just til next reboot
        or edit /etc/vfstab adding:
/some/file - - swap - no -
                to make it survive upon reboot...
From: (David Gunn)
Try something like

        mkfile 20m /wherever/more_swap

where 'm' means 'megabytes' (you can also use 'k').

Then, add to your /etc/fstab (/etc/vfstab with different syntax for Solaris):

        /wherever/more_swap swap swap rw 0 0

Finally, turn on the swap space:

        /usr/etc/swapon /wherever/more_swap
From: (Gary Richardson)
Yo Dan,

Here's what I do to increase swap on a system w/o having to reload the
whole thing:

- Find a local filesystem that has enough space (duh :-)

- make a file using mkfile (here's my example):

                        mkfile 100m system.add_swap

- Then in /etc/fstab, add an entry like this (your filesystem may vary):

                /usr/system.add_swap swap swap rw 0 0

- Issue the command:

                swapon -a

  That'll read the fstab to see if there are any swapfiles to add.

Viola! You're done.
From: Stephen P Richardson <>
        as root:
        mkfile <filename> <nnn>m eg mkfile /swapfile 64m
        add a line to /etc/vfstab:

#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot options
/swapfile - - swap - no -

        swap -a /swapfile
        swap -l (to verify)
From: Terry Snyder <>
Yes you can.

Read mkfile, then after you made you "swap" file
drop kick it with swapon or put it in fstab

#/usr302/SWAP_208 swap swap rw 0 0
--------------------------------------------------------------From: (Pierre-Yves Bonnetain)
 It seems to me you should use the 'swap' command (section 1M) if you are
on Solaris 2.X (swapon if SunOS), and mkfile something on your disk.
--------------------------------------------------------------From: (Brett Lymn)
It can be done. If Crazy has local disk then you can:

cd /humungous/partition
mkfile 100m a_swapfile

Which will create a 100Meg swap file. Add a line like:

/humungous/partition/a_swapfile swap swap rw 0 0

into /etc/fstab. Run the command "swapon -a" to add all swap devices
- blammo instant vistas of swap previously not seen.

For NFS mounted swap the procedure is the same but you must ensure
that the swap file is exported with root access to Crazy Steve
otherwise he will not be able to write to it.
From: The Wizard <>
Check the man pages for "mkfile" and "swapon" -- there is a few short
examples of how to create a swapfile, and then add it to the swap area
while the system is running. You will also need to make an entry in the
fstab (this only works if you are 4.1.x SunOS; I haven't tried to do it
on Solaris 2.x)

From: Claus Assmann <>
On SunOS 4.x you can just create a file as additional
swap space (as listed in your fine manual :-).

without explanation and warranty:

#! /bin/sh
# add swap space
if test $# -ge 1
if test $# -ge 2
# !!!! where ???
rsh $H df -t 4.2
rsh $H ls -CF $SWAP
echo "rsh $H if \( ! -f $SWAP/swap \) mkfile $SIZE $SWAP/swap"
rsh $H if \( ! -f $SWAP/swap \) mkfile $SIZE $SWAP/swap
rsh $H df -t 4.2
rsh $H ls -CFs $SWAP
# !!!! new fstab !!!
echo rcp fstab.swap $H:/etc/fstab
rsh $H swapon -a
echo "$0: missing host"
From: (Chris Habasinski)
You don't mention the OS you are running.

For SunOS:

mkfile 50M /home/swapfile # Creates 50M file called swapfile in /home

swapon /home/swapfile # Starts using /home/swapfile as additional
                                # swap space.

Thats all you need to do.
--------------------------------------------------------------From: James
Gilliland <>
One thing you don't mention is the OS you are running so I'll answer
only what I know -- Solaris 2.4 (and 2.3 I think).

In Solaris 2.4 swap can be added either by adding another partition to
swap space (provided you have one free and unused or can add another
disk without pain, trial, and tribulation) . . or! . . you can add swap
via a file (created via command mkfile). This file may even reside on
an NFS file system (!!) -- just don't expect memory performance to be
too swift if it actually uses this!

In Solaris 2.4, look at the man pages for "swap" and "mkfile".
--------------------------------------------------------------From: (Karen Lythgoe - UNIX Sys Admin)
Here's something that you might find easier.... I got this from SunSolve awhile
back when I ran into a similar problem.


----- Begin Included Message -----

SRDB ID: 6189

SYNOPSIS: What's the Best Way to Increase Swap Space?


If you run a lot of applications at the same time, you may occasionally see
messages such as the following:
        out of memory
        Not enough memory
        swap space exhausted

Despite their implication, these messages don't mean that your system is
strapped formemory. Instead, they indicate that your applications are asking
SunOS for more swap space in which to mange memory. Swap space is a file or
area of the disk set aside so that SunOS can store parts of programs and data
that aren't immediately required in memory. By adding sufficient swap space,
you can eliminate out of memory and related messages that may appear on
your system.

Following are instructions for increasing your swap space.


Using a Regular File for Swap Space

The easiest way to add swap space to a system is to set up a "swap file" using
mkfile(8) and the swapon(8) command. Here are the steps:

        1. Become superuser.
Use the su command or log in as root to become superuser on your system.
        % su

        2. Find a disk partition with sufficient space.
For instance, if you want to add 16 megabytes of swap space, choose a
partition with around 24 MB so that you'll have 8 MB left over for other
uses. Use the following command to see what partitions and related
directories on your system have the most space:
        # df -type 4.2

        3. Create a swap file with mkfile(8).
Assuming you want to create a 16MB file in a /files directory on your
system, the command is:
        # mkfile 16m /files/swap

        4. Update your /etc/fstab file.
Add a line to /etc/fstab listing the name of the swap file. For example:

        /files/swap swap swap rw 0 0

        5. Run swapon(8).
Enter the following command to add the file to the system's list of files and
partitions to be used as swap space:
        # swapon -a

Note that at boot-up, swapon is automatically started from an entry in the
/etc/rc file, so it is not necessary to restart the command when you

Additional Information on Adding Swap Space

For cautions and additional information on adding swap space, including
instructions for diskless clients, see System and Network Administration and
SunOS 4.1.1 Release Manual.

Useful terms to search for in AnswerBook include:

extra swap swapon

This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:10:29 CDT