AIXAddSwap

== How to add swap under AIX ==

There are several commands that can be helpful to check the swap space available and add some more. I'll try to be as detailed as possible here, but you should also check the AIXSwapInformation page on this wiki.

Consider this a brief primer, and not a complete documentation on the intricacies of AIX swap management.

==== 1. A few helpful commands: ====

{{{ lspv -t lv }}}

{{{ lspv }}}

{{{ lspv -p disk }}}

(You should replace {{{disk}}} in the example above by the correct disk number)

==== 2. A quick HOW-TO to adding swap: ====

# Begin by listing the disk, swap configuration, free space on each disk with the commands shown above. # Then, calculate the size of the swap that can be added //**in terms of PP**// # Add the swap using the {{{smitty mkps}}} command or the {{{mkps}}}. I prefer going through {{{smitty}}} since it's a bit more simple...

==== 3. A short example: adding swap to a production server ====

Swap configuration before changes:

{{{ # topas

Topas Monitor for host: galactus EVENTS/QUEUES FILE/TTY Fri Nov 7 11:17:50 2008 Interval: 2 Cswitch 962 Readch 18607 Syscall 807 Writech 33332 Kernel 4.9 |## | Reads 6 Rawin 0 User 3.1 |## | Writes 5 Ttyout 201 Wait 0.1 |# | Forks 0 Igets 0 Idle 91.9 |########################## | Execs 0 Namei 4 Physc = 0.02 %Entc= 11.0 Runqueue 1.5 Dirblk 0 Waitqueue 0.0 Network KBPS I-Pack O-Pack KB-In KB-Out en0 0.6 3.5 1.5 0.2 0.3 PAGING MEMORY lo0 0.0 0.0 0.0 0.0 0.0 Faults 0 Real,MB 3072 Steals 0 % Comp 98.9 Disk Busy% KBPS TPS KB-Read KB-Writ PgspIn? 0 % Noncomp 1.6 hdisk1 0.5 24.0 1.5 0.0 24.0 PgspOut? 0 % Client 1.6 hdisk2 0.0 0.0 0.0 0.0 0.0 PageIn? 0 hdisk0 0.0 0.0 0.0 0.0 0.0 PageOut? 8 PAGING SPACE Sios 6 Size,MB 5120 Name PID CPU% PgSp? Owner % Used 45.5 topas 1487070 0.2 1.9 teamsys NFS (calls/sec) % Free 54.4 emisrv_s 286962 0.1 9.7 sp1cod ServerV?2 0 emisrv_s 1523746 0.1 9.7 oracod ClientV?2 0 Press: java 1155178 0.0 78.5 prd400 ServerV?3 0 "h" for help java 962678 0.0 79.6 oracod ClientV?3 0 "q" to quit }}}

In the example above, I have chosen to go through the {{{topas}}} utility to check the current configuration.

The relevant information is in the {{{PAGING SPACE}}} column: 5GB of swap are currently configured on {{{galactus}}}, while the RAM is configured at 3GB.

Now, what disks are available on this machine?

{{{ $ lspv hdisk0 0001650f5d5e45b3 rootvg active hdisk1 0001650f6272e930 datavg active hdisk2 0001650f6272ea97 datavg active }}}

Three physical disks are configured on this machine (hdisk0, hdisk1 and hdisk2) and the swap space is probably installed on hdisk0, since it contains the "rootvg".

We can check the configuration of hdisk0 with the following command:

{{{ $ lspv -p hdisk0 hdisk0: PP RANGE STATE REGION LV NAME TYPE MOUNT POINT 1-1 used outer edge hd5 boot N/A 2-15 free outer edge 16-19 used outer edge lg_dumplv sysdump N/A 20-24 used outer edge hd3 jfs2 /tmp 25-31 used outer middle hd3 jfs2 /tmp 32-35 used outer middle hd9var jfs2 /var 36-44 used outer middle hd2 jfs2 /usr 45-48 used outer middle hd4 jfs2 / 49-68 used center hd6 paging N/A 69-69 used center hd8 jfs2log N/A 70-71 used center hd1 jfs2 /home 72-73 used inner middle hd1 jfs2 /home 74-85 used inner middle hd10opt jfs2 /opt 86-95 free inner middle 96-119 free inner edge }}}

And check the swap configuration itself with:

{{{ $ lsps -t lv Page Space Physical Volume Volume Group Size %Used Active Auto Type hd6 hdisk0 rootvg 5120MB 46 yes yes lv }}}

Now, let's check hdisk1 in the same manner:

{{{ $ lspv -p hdisk1 hdisk1: PP RANGE STATE REGION LV NAME TYPE MOUNT POINT 1-3 used outer edge apsyslv jfs2 /accounting 4-160 used outer edge dev_codelv jfs2 /devel 161-161 used outer middle loglv00 jfs2log N/A 162-209 used outer middle fslv00 jfs2 /mktemp 210-320 used outer middle apsyslv jfs2 /accounting 321-366 used center apsyslv jfs2 /accounting 367-479 used center tierslv jfs2 /telecom 480-601 used inner middle tierslv jfs2 /telecom 602-639 used inner middle apsyslv jfs2 /accounting 640-678 used inner edge apsyslv jfs2 /accounting }}}

Is there any free space on hdisk1?

{{{ $ lspv hdisk1 PHYSICAL VOLUME: hdisk1 VOLUME GROUP: datavg PV IDENTIFIER: 0001650f6272e930 VG IDENTIFIER 0001650f0000d6000000011662730419 PV STATE: active STALE PARTITIONS: 0 ALLOCATABLE: yes PP SIZE: 64 megabyte(s) LOGICAL VOLUMES: 5 TOTAL PPs: 799 (51136 megabytes) VG DESCRIPTORS: 2 FREE PPs: 121 (7744 megabytes) HOT SPARE: no USED PPs: 678 (43392 megabytes) MAX REQUEST: 128 kilobytes FREE DISTRIBUTION: 00..00..00..00..121 USED DISTRIBUTION: 160..160..159..160..39 }}}

As can seen above (in the {{{FREE PPs}}} line, there is only 7.7GB of free space on hdisk1.

Now, let's check hdisk2 in the same manner, first the configuration:

{{{ $ lspv -p hdisk2 hdisk2: PP RANGE STATE REGION LV NAME TYPE MOUNT POINT 1-160 used outer edge production_lv jfs2 /production 161-208 used outer middle fslv00 jfs2 /mktemp 209-209 used outer middle loglv00 jfs2log N/A 210-320 used outer middle xy_prod_lv jfs2 /xy_production 321-354 used center yz_prod_lv jfs2 /yz_production 355-479 free center 480-639 free inner middle 640-799 free inner edge }}}

Now the free space on hdisk2:

{{{ $ lspv hdisk2 PHYSICAL VOLUME: hdisk2 VOLUME GROUP: datavg PV IDENTIFIER: 0001650f6272ea97 VG IDENTIFIER 0001650f0000d6000000011662730419 PV STATE: active STALE PARTITIONS: 0 ALLOCATABLE: yes PP SIZE: 64 megabyte(s) LOGICAL VOLUMES: 4 TOTAL PPs: 799 (51136 megabytes) VG DESCRIPTORS: 1 FREE PPs: 445 (28480 megabytes) HOT SPARE: no USED PPs: 354 (22656 megabytes) MAX REQUEST: 128 kilobytes FREE DISTRIBUTION: 00..00..125..160..160 USED DISTRIBUTION: 160..160..34..00..00 }}}

We have (again, {{{FREE PPs}}} line) 28.4GB of free space on hdisk2, and this makes it an ideal candidate to add some swap.

Now, we would like to add about 8GB of swap on this machine.

The magical formula is:

Now, let's create the swap:

{{{ # smitty mkps +--------------------------------------------------------------------------+ | VOLUME GROUP name | | | | Move cursor to desired item and press Enter. | | | | rootvg | | datavg | | | | F1=Help F2=Refresh F3=Cancel | | F8=Image F10=Exit Enter=Do | | /=Find n=Find Next | +--------------------------------------------------------------------------+ }}}

In the screen above, the {{{datavg}}} option has been selected, followed by the ENTER key.

We now find ourselves with the screen shown here:

{{{ Add Another Paging Space

Type or select values in entry fields. Press Enter AFTER making all desired changes.

[Entry Fields] Volume group name datavg SIZE of paging space (in logical partitions) [125] # PHYSICAL VOLUME name hdisk2 + Start using this paging space NOW? yes + Use this paging space each time the system is yes + RESTARTED?

+--------------------------------------------------------------------------+ | SHOW COMMAND STRING | | | | Press Enter or Cancel to return to the | | application. | | | | mkps -s'125' -n'' -a'' datavg hdisk2 | | | | F1=Help F2=Refresh F3=Cancel | | F8=Image F10=Exit Enter=Do | +--------------------------------------------------------------------------+ }}}

As you can see above:

To provide a slightly different example, the {{{mkps}}} command line has been displayed.

Once the parameters have been correctly set, press ENTER, and the following screen should be displayed:

{{{ COMMAND STATUS

Command: OK stdout: yes stderr: no

Before command completion, additional instructions may appear below.

paging00 }}}

Of course, this is not very detailed (smitty can be really terse!), so here are several ways to check the swap space has been added correctly:

First with the {{{lspv}}} command:

{{{ # lsps -t lv Page Space Physical Volume Volume Group Size %Used Active Auto Type paging00 hdisk2 datavg 8000MB 1 yes yes lv hd6 hdisk0 rootvg 5120MB 46 yes yes lv }}}

Here, we see {{{paging00}}} has been added to the list of active swaps.

Now through the {{{/etc/swapspaces}}} configuration file, which is automatically updated by {{{mkps}}} command:

{{{ # cat /etc/swapspaces

hd6: dev = /dev/hd6

paging00: dev = /dev/paging00 }}}

And, finally, you can also check the result of the {{{topas}}} command:

{{{ Topas Monitor for host: galactus EVENTS/QUEUES FILE/TTY Fri Nov 7 11:50:21 2008 Interval: 2 Cswitch 984 Readch 59135 Syscall 1157 Writech 459 Kernel 7.7 |### | Reads 8 Rawin 0 User 23.5 |####### | Writes 1 Ttyout 217 Wait 0.0 | | Forks 0 Igets 0 Idle 68.9 |#################### | Execs 0 Namei 4 Physc = 0.08 %Entc= 37.5 Runqueue 1.0 Dirblk 0 Waitqueue 0.0 Network KBPS I-Pack O-Pack KB-In KB-Out lo0 16.2 33.0 33.0 8.1 8.1 PAGING MEMORY en0 0.5 2.5 1.5 0.2 0.4 Faults 2 Real,MB 3072 Steals 0 % Comp 97.9 Disk Busy% KBPS TPS KB-Read KB-Writ PgspIn? 0 % Noncomp 2.0 hdisk2 0.0 0.0 0.0 0.0 0.0 PgspOut? 0 % Client 2.0 hdisk1 0.0 0.0 0.0 0.0 0.0 PageIn? 0 hdisk0 0.0 0.0 0.0 0.0 0.0 PageOut? 0 PAGING SPACE Sios 0 Size,MB 13120 Name PID CPU% PgSp? Owner % Used 18.2 java 1683668 0.9 137.9 prd400 NFS (calls/sec) % Free 81.7 java 1638590 0.9 165.4 sp1cod ServerV?2 0 xmwlm 188546 0.4 0.8 root ClientV?2 0 Press: topas 1093710 0.2 1.9 root ServerV?3 0 "h" for help java 1847396 0.2 73.9 sp1cod ClientV?3 0 "q" to quit }}}

You can see above that the swap space is now 13GB (instead of 5GB previously).

== See Also: ==

AIXSwapInformation