Solaris add a new swap file for database

I am running out of swap space due to the Oracle database. It is a production server. How do I add a new swap file or area that doesn’t demand a reboot system?

Sun Solaris UNIX offers a straightforward way to add a swap file/partition on the fly without rebooting the Solaris system.

Solaris add a new swap file for database

First, login as the root user. For example:
$ su -
Type the following command to create swap file. It creates file that are suitable for use as NFS- mounted swap areas.
# mkfile -v 2g tmp-swap.file

  • -v : Report the names and sizes of created files (verbose)
  • 2g : 2Gbyte file size.

Now turn on or add the new swap file to the Solaris UNIX swap area:
# swap -a tmp-swap.file
The swap command provides a method of adding, deleting, and monitoring the system swap areas used by the memory manager. This will do the job. Verify it:
# swap -l
# swap -s
Please note that this swap file is slow as compare to your regular raw swap device.

Solaris add swap space in ZFS root setup

List all swap spaces:
# swap -l
# swap -s

Create a new swap space with 4GiB size:
# zfs create -V 4G tank/myswap2
Let us activate it:
# swap -a /dev/zvol/dsk/tank/myswap2
# swap -l
# swap -s

Finally, add an entry for swap volume in the /etc/vfstab file as follows:
# vi /etc/vfstab
Append/edit as follows:

/dev/zvol/dsk/tank/myswap2    -        -       swap    -       no      -

Save and close the file.


You learned how to add a new swap file for a database server or any other purpose on Oracle/Sun Solaris Unix operating system using the command-line options. For futher information refer to man pages of swap and mkfile command.
$ man mkfile
$ man swap

This entry is 7 of 7 in the Linux and UNIX Swap File Management Tutorial series. Keep reading the rest of the series:
  1. Linux Add a Swap File
  2. FreeBSD Add a Swap File
  3. Ubuntu Create and add a swap file
  4. Check Swap Usage Size and Utilization in Linux
  5. Linux Find Out What Process Are Using Swap Space
  6. Move swap space from one location to another location
  7. Solaris add a new swap file for database

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 0 comments... add one

CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
0 comments… add one

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum