SUMMARY: SunOS swap space REPOST

From: Systems Administrator (
Date: Fri Jan 12 1996 - 10:29:07 CST

For some reason I have been having a hard time posting summaries to this

Hello again and thanks for the quick response!

I did receive a huge amount of responses and I think I understand it all
quite a bit better.

I will give a general summary and then include some of the responses at
the end of this post. Some good info!

Original Question:

I was recently asked to add some swap space to a sparc running SunOS
4.1.3. I checked the /etc/fstab and there is no entry with the keyword
swap. I have types of 4.2 and nfs but no swap. I was told that tere is
already 50 megs available on this machine so I dug a little more. pstat
-s returned :
23960k allocated + 7600k reserved = 31560k used, 33956k available

A df shows:

/dev/sd0a 15487 7635 6304 55% /
/dev/sd0g 169439 147904 4592 97% /usr
/dev/sd0h 142039 87809 40027 69% /home
/dev/sd2g 1275338 1001209 146596 87% /home/ishtar

Where is the swap space located and how do I add to it? From what I
thought I understood about SunOS swap space, I would have to use the
mkfile command and then add that to the /etc/fstab entry and then use
the swapon -a command. Is my info wrong? What am I missing.
The info I included about using the mkfile and swapon was correct,
however, this is only one type of swap space (namely a file swap space
as opposed to a partition swap space [my own words, not offical techie
SunOS automatically takes partition b on the root disk (whichever disk
has / mounted on it [use df]) and uses whatever space is allocated to
that partition (thru the format command) and uses it as swap space.
It seems that for efficiency sake it would be best to have made the swap
partition (b) as large as I would have needed it initially. This still
can be increased although it included repartitioning the disk and I
would rather keep what litle sanity I have left! Ther are breif
explainations below.
If I need more swap space and I don't want to repartition my disk (and I
still have the space) I can add a swap file that will be added to the
total swap space available to the system.
One way to see info about the swap space and disk in particular is to
use the dkinfo <disk> <partition> command although it gives you info in
sectors and cilinders and I hate math!
An easy way is to use dmesg | grep swap. This will show you where and
what swap was set to at bootup.
Good luck!
Following are the responses and credits. Thanks again!

 From: Jerome Alphonse <>
We increase swap on the fly like this:
mkfile 40m /home/swapfile
swapon /home/swapfile
and add the entry
/usr/etc/swapon /home/swapfile
in /etc/rc.local
this is for 40 MB swapspace.
From: wbbart! (Chuck Uretzky)
   To: wbbart!
Your swap space should be allocated on partition B. You can see this
with the format command. As far as adding it to that partition, you
would have to reconfigure the disk. I don't think you want to do that.
There is another way, the only problem I see with your system is you
don't have much space. To do that you wold use mkfile (see manpage)
and swapon. What it looks like you are going to have to do is add
another drive and usr partition B as your swap area. Then place the
following in your fstab:
/dev/<disk_abbrev>b /dev/<disk_abbrev> swap 0 0 0
Where <disk_abbrev>b coud be sd1b. All of this info is in the Sun
Administration manual under increasing swap space.
      Jason Blackburn <>
      Systems Administrator <>
Well, you've got it right about the "mkfile" and "swapon", and you know
how to check your swap usage with "pstat". If you want to physically
check your swap partition, guess you'll just have to use "format" and
check /dev/sd0b. You can just add a swap file with the above commands,
or you can do it the hard way and add some swap to your /dev/sd2 by
adding a line similar to the following in your /etc/fstab:
/dev/sd2b swap swap rw 0 0
From: (Amy Hollander)
Your swap is on /dev/sd0b
Use the mkfile command and put in /etc/fstab and do a swapon
like it says. It will be a separate file. Your swap will now be in
two pieces instead of one and pstat will show more swap size after you
do this. It will be better if you can put your additional swap on
another hard drive for performance.
From: (Mark R. Lemoine (508)-440-2317)

You may want to try "pstat -T"
This gives you your TOTAL swap, used & available.
Usually, your swap is on your "b" partition of your disk, but
in this case, your disk is already loaded with data, so . . .
A "quick & dirty" way to "add" swap, would be to do the following steps
(It works for me anyway :)
 1. Log in as superuser.
 2. TYPE IN: pstat -T
        a. Write down "swap" stats.
        b. I.e. 4724/414640 swap
                 | |
                 | |
                 | ----Amount available
                 ----Amount used
 3. TYPE IN: shutdown -h now
 4. Power down SPARCstation.
 5. Open the base of the SPARC and hook up an internal drive.
 6. Button the SPARC back up.
 7. Power the SPARCstation back up, but don't let it boot.
 8. At the "ok" prompt, do a "probe scsi" to make sure the internal
    is seen by the bus as device "0" (zero).
    (This may be different, depending on what devices you already have
 9. Boot up.
10. Log in as superuser and do the following :
        a. TYPE IN: format
        b. Pick drive sd0 (again, this may be different)
        c. TYPE IN: partition
        ( partition "g" should be equal to partition "c" )
        e. TYPE IN: label
        g. TYPE IN: newfs /dev/rsd0g (again, this may be different)
        h. TYPE IN: mkdir /usr5
        i. TYPE IN: mount /dev/sd0g /usr5 (if /usr5 is not allready in
        j. TYPE IN: fsck /dev/sd0g (ditto)
        k. TYPE IN: vi /etc/fstab
           /dev/sd0g /usr5 swap 0 0 0
11. TYPE IN: grep swapon /etc/rc

        a. Make sure the response is: swapon -a
        b. If the response is other than "swapon -a" add it into
           the /etc/rc file.
12. Re-boot the station.
13. TYPE IN: pstat -T
        a. Compare to the results in STEP 1.
      jgotobed@LPL.Arizona.EDU (Joe Gotobed)
That swap space is probably on the second slice (partition ) of the disk
which Solaris 1 (BSA in general) needs. Additional swap can be added
by swapping on files.
Run ;
dmesg | grep swap
& you should see either sd0b or sd2b and the kilobyte count pop out.
If the system has been up along time you'll have to grep the
/var/adm/mesag* files for it.
Making additioon al swaop is a mkfile followed by a swap (or swapon)
command, I've forgotten where to look in the manual.
From: (Martin Achilli)
By default the "b" partition of your boot drive is used as swap, in your
case it is /dev/sd0b.
To get partition information type
dkinfo sd0
and multiply the number of blocks by 512 to know how much swap is
currently defined.
To add swap space you can then either repartition the drive and increase
the "b" partition size or define a new partition for swap. This approach
means you will have to back up partitions d to h and boot from a
Otherwise you can create a swap file with mkfile, or add a new disk and
use a partition on it for swap.
In all cases except for the first you must add an entry to /etc/fstab
following the guidelines in the "mount" man page.
From: (Bob Blumling)
The default location for swap space on SunOS would
be at /dev/sd0b, no entry in fstab is required.
However, in order to add additional swap (other than

/dev/sd0b) you can either create a swap partition
and make the appropriate fstab entry or use the
mkfile command to create a swapfile.
Swapfiles are inherently inefficient, so if the space
is to be permanent swap, it would be preferable to
allocate a partitioned chunk of disk to swap.
From: (S. D. Raffensberger 500622500 (RD))
The method you describe is probably how you will accomplish
your task. The 50Meg that is already available is the default
swap space.
If you run "format", select sd0, select partition, select print,
you should see that partition "b" is your 50Meg. By default,
SUNOS will use partition "b" of the boot disk for swap. This
can be dynamically expanded using swapon.
      Systems Administrator <>
     Go into format for sd0 and look at the size assigned to partition
     This is the swap for a 4.1.x system. To add additional swap,
     (if using an additional spare disk partition):
     1. modify /etc/fstab to add the line
        /dev/sdxb swap swap rw 0 0
     (note first "swap" is mount point, the other tells what type of fs
     2. swapon -a
     3. verify swapon is run in /etc/rc for bootup.
     (if using a swap file):
     1. create file to be used for swapping:
        mkfile 20m /home/swapfile
        (specify whatever size it is you want for the swap file)
     2. modify /etc/fstab to add the line
        /home/swapfile swap swap rw 0 0
     3. swapon -a
     4. verify swapon is run in /etc/rc for bootup.

      Peter Hesse <>
Default swap is the /dev/sd0b partition.
Your understanding of 4.1.3.swap is correct:
   swapon -a adds /etc/fstab swap entries.
   You do need to mkfile them.
Youcan also use the tmpfs file system to swap into /tmp as well; the
disadvantage is that your available swap space varies with the
quantitiy of junk in /tmp. It only takes one large file written to
/tmp to blow your machine out of the water if your swap space is near
      tperkins@khis.Kodak.COM (Terry L. Perkins)
You are exactly correct with the mkfile and swapon -a and adding the
to the fstab but you will not see it in the output of df. Read the man
page for
swapon and there should be an option to display swap.
      "Michael (M.A.) Meystel" <MEYSTMA@DUVM.OCS.DREXEL.EDU>
      Systems Administrator <sysadmin@ASTROSUN.TN.CORNELL.EDU>
Swap is located on a raw partition. To add swap space, format the
partition table on an additional disk such that one of the partitions
is raw (does not have a filesystem on it). Say, for instance, that
you've added a disk, /dev/rsd2, and that you have partition 'd'
configured for 100MB, and you intend to use it as swap space.
Do the following:
- add the following line to your /etc/fstab file:
/dev/sd2d swap swap rw 0 0
- make sure that the /etc/rc file has
swapon -a
right after the line that says
sh /etc/rc.local
and reboot the machine.

The system should automagically recognize the new swap area and add it
to the total size of swap space that is available on that machine.
      "Christopher L. Barnard" <>
      Systems Administrator <>
Your swap space is /dev/sd0b, which isn't mentioned in /etc/fstab.
SunOS just takes whatever is in partition b as its swap. You are
that to add to this, you would use mkfile to create a big file and then
add to your existing swap by putting it in /etc/fstab.
      Claus Assmann <>
It's just one way to do it.
The other is to have a special partition, which of course
doesn't show up in /etc/fstab
It is /dev/sd0b by default.
Use dkinfo to find its size:
% dkinfo sd0
sd0: SCSI CCS controller at addr f0800000, unit # 24
1151 cylinders 9 heads 80 sectors/track
a: 33120 sectors (46 cyls)
   starting cylinder 0
b: 262080 sectors (364 cyls)
   starting cylinder 46
c: 828720 sectors (1151 cyls)
   starting cylinder 0
d: No such device or address
e: No such device or address
f: No such device or address
g: 361440 sectors (502 cyls)
   starting cylinder 410
h: 172080 sectors (239 cyls)
   starting cylinder 912
      Margaret Shinkle <>
Swap space, by default is /dev/sd0b. If you run format, go to
the partition menu, and use print, it will display the portion
of the drive dedicated to the b partition.
The b partition is only used by default on the root disk,
meaning the disk that has / on it. You don't have a choice
in making the b partition to be size 0 on an install. I think
with 4.1.2 and higher versions of the OS, you *need* it to
be 16 MB mininum (older versions could be as small as 8MB).
It can be as large as you want it to be. It doesn't have
to be in the fstab file to be included, since it is a default.

and thanks to anyone else who mailed before they saw the summary

                      Systems Administrator
                   Space Sciences Building CRSR
   Mail all system related problems to one of the following: 
                              or see 
Vic Germani in room 402

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