UNIX Hints & Hacks

ContentsIndex

Chapter 1: Topics in Administration

 

Previous ChapterNext Chapter

Sections in this Chapter:

1.1 Collecting System Information

 

1.7 Swap on-the-Fly

 

1.13 Remove the ---- Dashes ----

1.2 Backup Key Files!

 

1.8 Keep It Up with nohup

 

1.14 echo Does ls

1.3 Execution on the Last Day of a Month

 

1.9 Redirecting Output to Null

 

1.15 Building Large Dummy Files

1.4 Dealing with Unwanted Daemons

 

1.10 Keeping Remote Users Out

 

1.16 Burning-in Disk Drives

1.5 Keep Those Daemons Running

 

1.11 Rewinding Tapes Fast

 

1.17 Bringing a System Down

1.6 fuser Instead of ps

1.12 Generating a Range of Numbers

 

 

1.7 Swap on-the-Fly

1.7.1 Description

1.7.1 Description

If you find that, after you have installed UNIX on your system, you still need more swap space, it is an easy thing to accomplish. Create a swap file and make it active.

Example

Flavors: AT&T, some BSD

Syntax:

mkfile size[m] filename

The main command for adding swap on the fly is mkfile. This command is simple to use, so adding swap on the fly is easy. After you determine that you need more swap and you have found an underutilized disk that can help balance the disk I/O, you're ready.

# mkfile 200m /disk2/swap_200MB

This mkfile command creates a 200MB swap file in the /disk2 partition. The only step left is to turn the swap file into active swap for the system. Depending on your flavor of UNIX, this is achieved in the following ways:

Flavors: Irix and Solaris

# swap -a /disk2/swap_200MB

Flavors: HP-UX, SunOS

# swapon -a /disk2/swap_200MB

This uses the swap only for the length of time that the system is up. If you reboot or shut down the system for any reason, the swap file is still there, but it is no longer active. The swap or swapon command must be executed again.

To hardcode the swap file into the system so that it is always activated when the system comes up, place an entry in the filesystem table by editing the filesystem table on your system. This file will be called /etc/fstab or /etc/vfstab.

Add the following line to the filesystem table:

/disk2/swap_200M    swap    swap   rw 0   0

Reason

It used to be that the fastest disk I/O was only on the system drive. With the speed of today's SCSI buses and fiber channels, creating the device swap only on the system disk is not really necessary anymore. It is now easy to put swap anywhere on a system, but with that comes the necessity to balance the disk I/O to get the maximum amount of performance out of the system.

Real World Experience

Sometimes a user calls complaining that the applications they are running take up too much of the system's resources. If this happens and you determine that lack of swap space is the problem, let the user know how concerned you are and that you want to fix it on the spot. By adding more swap on-the-fly for the user while you have him on the phone, it looks like you're pulling some kind usable space out of thin air. This simple feat can make you look pretty good in the user's eyes.

Other Resources

Man pages:

fstab, mkfile, swap, swapon, vfstab,

UNIX Hints & Hacks

ContentsIndex

Chapter 1: Topics in Administration

 

Previous ChapterNext Chapter

Sections in this Chapter:

1.1 Collecting System Information

 

1.7 Swap on-the-Fly

 

1.13 Remove the ---- Dashes ----

1.2 Backup Key Files!

 

1.8 Keep It Up with nohup

 

1.14 echo Does ls

1.3 Execution on the Last Day of a Month

 

1.9 Redirecting Output to Null

 

1.15 Building Large Dummy Files

1.4 Dealing with Unwanted Daemons

 

1.10 Keeping Remote Users Out

 

1.16 Burning-in Disk Drives

1.5 Keep Those Daemons Running

 

1.11 Rewinding Tapes Fast

 

1.17 Bringing a System Down

1.6 fuser Instead of ps

1.12 Generating a Range of Numbers

 

 

© Copyright Macmillan USA. All rights reserved.