Setting SWAP Memory under Solaris

QCKVU Solaris can allocate up to 4GB of RAM. If you have less than 4GB RAM, it is important to set the SWAP size in a way that the sum of the swap and RAM will be around 4000MB to make full use of QCKVU. Failing to do so, will probably prevent QCKVU from loading files in the 4GB range and above.

These are the steps to add swap space to your Solaris system through the use of swap files.

  • Determine the amount of existing swap space
    Use the command top to find out how much swap and RAM you have on your system.

    top
    
    load averages:  0.00,  0.00,  0.01  15:32:26
    63 processes:  62 sleeping, 1 on cpu
    CPU states: 98.8% idle,  0.2% user,  1.0% kernel,  0.0% iowait,  0.0% swap
    Memory: 128M real, 61M free, 44M swap in use, 468M swap free
    
      PID USERNAME THR PRI NICE  SIZE   RES STATE   TIME    CPU COMMAND
    19005 hagai      1  33    0 1248K 1128K cpu     0:00  0.20% top.solaris
      320 root       1  34    0   16M 6024K sleep   1:47  0.19% Xsun
    
    
    

    The system has about 128MB RAM, and about 500MB swap.

    To configure 2GB of swap, we can make one 2GB swap file or two 1GB swap files. We'll do two 1GB swap files because one 2GB swap file might not work depending on Linux kernel support for large files (file over 2GB).

  • Make swap file named swapfile in /export/home

    You should check using the df -k command which partiotion you can use to create the swap file. Then become super user and use the vi text editor to modify the file /etc/vfstab. You will need to add a line that looks like the last line in the following example..
    more /etc/vfstab
    
    
    #device		device		mount		FS	fsck	mount	mount
    #to mount	to fsck		point		type	pass	at boot	options
    #
    #/dev/dsk/c1d0s2 /dev/rdsk/c1d0s2 /usr		ufs	1	yes	-
    fd	-	/dev/fd	fd	-	no	-
    /proc	-	/proc	proc	-	no	-
    /export/home/swapfile	-		-	swap	-	no	-
    
    

  • Turn swap file into a swap area

    Next you will need to create the file and give it a size using the mkfile command.
    mkfile -v 1000000000 swapfile
    

    This creates the file /export/home/swapfile, 1GB in size. It also checks the swap file for bad blocks, and then turns it into swap space.

    At this point you need to reboot the system so the changes will take effect.

  • Verify that the system is using the swap file

    Run the top command again to make sure the swap file is available.

    top
    
    
    CPU states: 98.8% idle,  0.2% user,  1.0% kernel,  0.0% iowait,  0.0% swap
    Memory: 128M real, 61M free, 29M swap in use, 1437M swap free
    
      PID USERNAME THR PRI NICE  SIZE   RES STATE   TIME    CPU COMMAND
      834 hagai      1  33    0 1280K 1064K cpu     0:00  0.03% top
    
    

    Now the swap size is around 1500MB. If you have enough disk space, you can create two swap files, each 1GB or 2GB.