How to add a swap drive to Solaris 10

So I needed more swap space, but didn’t have any more space on the current disk. What to do? Add another drive and set it up as swap space. The only caveat is that I am running the 32 bit version of Solaris 10, which has a limitation on maximum swap size of 2 GB. So if you have a hard drive that is larger then 2 GB, you need to partition the drive into multiple 2 GB slices.

First, check what your swap space is already set to:

# swap -l
swapfile dev swaplo blocks free
/dev/dsk/c1t0d0s1 61,1 8 4194288 4194288

In this case, it is set to 2 GB (4194288 x 512 bytes = 1.99999237 gigabytes) and is set to partition 1 on the first drive.

So in this example, I added a 4 GB drive and ran devfsadm. Format shows the second drive available:

# format
Searching for disks…done

AVAILABLE DISK SELECTIONS:
0. c1t0d0
/pci@0,0/pci1000,30@10/sd@0,0
1. c1t1d0
/pci@0,0/pci1000,30@10/sd@1,0

Next, the drive needs some partitions, so we use fdisk (after choosing 1, the new drive):

format> fdisk
No fdisk table exists. The default partition for the disk is:

a 100% “SOLARIS System” partition

Type “y” to accept the default partition, otherwise type “n” to edit the
partition table.
y

format> part

PARTITION MENU:
….

partition> print
Current partition table (original):
Total disk cylinders available: 2044 + 2 (reserved cylinders)

Part Tag Flag Cylinders Size Blocks
0 unassigned wm 0 0 (0/0/0) 0
1 unassigned wm 0 0 (0/0/0) 0
2 backup wu 0 – 2044 3.99GB (2045/0/0) 8376320
3 unassigned wm 0 0 (0/0/0) 0
4 unassigned wm 0 0 (0/0/0) 0
5 unassigned wm 0 0 (0/0/0) 0
6 unassigned wm 0 0 (0/0/0) 0
7 unassigned wm 0 0 (0/0/0) 0
8 boot wu 0 – 0 2.00MB (1/0/0) 4096
9 unassigned wm 0 0 (0/0/0) 0

partition> 0
Part Tag Flag Cylinders Size Blocks
0 unassigned wm 0 0 (0/0/0) 0

Enter partition id tag[unassigned]: swap
Enter partition permission flags[wm]:
Enter new starting cyl[1]:
Enter partition size[0b, 0c, 1e, 0.00mb, 0.00gb]: 1021c

partition> 1
Part Tag Flag Cylinders Size Blocks
1 unassigned wm 0 0 (0/0/0) 0

Enter partition id tag[unassigned]: swap
Enter partition permission flags[wm]:
Enter new starting cyl[1]: 1022
Enter partition size[0b, 0c, 1025e, 0.00mb, 0.00gb]: 1021c

partition> print
Volume: swap
Current partition table (unnamed):
Total disk cylinders available: 2044 + 2 (reserved cylinders)

Part Tag Flag Cylinders Size Blocks
0 swap wm 1 – 1021 1.99GB (1021/0/0) 4182016
1 swap wm 1022 – 2042 1.99GB (1021/0/0) 4182016
2 backup wu 0 – 2043 3.99GB (2044/0/0) 8372224
3 unassigned wm 0 0 (0/0/0) 0
4 unassigned wm 0 0 (0/0/0) 0
5 unassigned wm 0 0 (0/0/0) 0
6 unassigned wm 0 0 (0/0/0) 0
7 unassigned wm 0 0 (0/0/0) 0
8 boot wu 0 – 0 2.00MB (1/0/0) 4096
9 unassigned wm 0 0 (0/0/0) 0
partition> label
Ready to label disk, continue? y
partition> quit
format> label
Ready to label disk, continue? y
format> quit

Now to add the partitions as swap space:

swap -a /dev/dsk/c1t1d0s0
swap -a /dev/dsk/c1t1d0s1

And check that it is now available:

swap -l
swapfile dev swaplo blocks free
/dev/dsk/c1t0d0s1 61,1 8 4194288 4194288
/dev/dsk/c1t1d0s0 61,64 8 4182008 4182008
/dev/dsk/c1t1d0s1 61,65 8 4182008 4182008

Now we need to add them to /etc/vfstab so that they are used after a reboot by /sbin/swapadd. This one was already in there:

/dev/dsk/c1t0d0s1 – – swap – no -

So then we add the additional partitions:

/dev/dsk/c1t1d0s0 – – swap – no -
/dev/dsk/c1t1d0s1 – – swap – no -

If you decide to delete your old swap swap, use the `swap -d` command and don’t forget to change your dump space with `dumpadm -d`.





Please VOTE for this page at: ADD TO DEL.ICIO.US | ADD TO DIGG | ADD TO FURL | ADD TO NEWSVINE | ADD TO NETSCAPE | ADD TO REDDIT | ADD TO STUMBLEUPON | ADD TO TECHNORATI FAVORITES | ADD TO SQUIDOO | ADD TO WINDOWS LIVE | ADD TO YAHOO MYWEB | ADD TO ASK | ADD TO GOOGLE


2 Comments


  1. [...] posted a while back how to modify your swap space in Solaris 10, now I will show you how to do it in Linux.  This example is from a Red Hat Enterprise (RHEL5) [...]

    Posted October 5, 2008, 11:31 am

  2. [...] to accept the default cylinder “1″. The info for this post was taken very directly from UtahSysAdmin.com. Huge thank you to Kevin for his post, which I needed to modify slightly to get my VM running. [...]

    Posted May 15, 2012, 10:41 pm

Leave a reply