• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Geek Diary

CONCEPTS | BASICS | HOWTO

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • Linux Services
    • VCS
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Interview Questions
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to add swap file in Solaris

By admin

Swap space is used as virtual memory storage areas when the system does not have enough physical memory to handle current processes. You might have to add swap space to your system if it does not have enough swap space or if recommended by your software application vendor. Follow the steps below to add swap space to a Solaris system, this example is taken from a Solaris 10 system.

Step 1

While logged into the system as root, the ‘swap -s‘ command provides summary information of swap resources. The output displays the total number of allocated bytes currently in use, the number of bytes currently reserved, the total amount of swap space, both reserved and allocated, and the total amount of swap space available for future reservation and allocation.

# swap -s
total: 44750504k bytes allocated + 3550360k reserved = 48300864k used, 143647648k available

Step 2

The status of the swap areas on disk are examined using the ‘swap -l‘ command. The output lists the physical swap area configured on your system, the total swap space, and the amount of available swap space in this device.

# swap -l
swapfile             dev  swaplo blocks   free
/dev/zvol/dsk/swappool/swap 256,1      16 268435440 211978800

Step 3

It is determined by using the df -k command that the system has sufficient space to add a 20-Mbyte swap file for demonstration purposes. The output shows there is enough space available to add the swap space.

# df -k /
Filesystem                kbytes     used       avail       capacity  Mounted on
rpool/ROOT/10u9S_144534   70189056   11505600   22912949    34%       /

Step 4

For demonstration purposes, a 20-Mbyte swap file is added to the system. The /usr/local/swap directory is created with the mkdir -p command. Within this directory, a 20 Mbytes swap file is created with the mkfile command and it is added to the system’s swap space with the ‘swap -a‘ command.

# mkdir -p /usr/local/swap
# mkfile 20m /usr/local/swap/newswap
# swap -a /usr/local/swap/newswap

Verify

Afterwards, the new swap file availability is verified with the ‘swap -l’ command. Note the cumulative report of the ‘swap -s’ command is changed.

# swap -l
# swap -s

Removing the swap file

1. If the swap resources are no longer in use, the swap file just created is removed with the ‘swap -d‘ and rm commands. Note that the swap -l command output shows the swap space is no longer available.

# swap -d /usr/local/swap/newswap

2. After displaying the cumulative report of swap with the swap -s command to verify available space, a disk partition is added as a swap slice to the existing swap space with the swap -a command.

# swap -l
# swap -s

Filed Under: Solaris

Some more articles you might also be interested in …

  1. Solaris : How to find number of open files by a process
  2. How to find the space consumed by ZFS snapshots
  3. How to update the boot_archive for ZFS root in Solaris
  4. Solaris : How To Create and Mount NFS share that is Restricted to Certain Hosts
  5. Managing network resources in Solaris 11 using “dlstat” and “flowstat”
  6. How to Disable IPv6 in solaris 8,9,10
  7. How to determine link status (up/down) of network interfaces in Solaris
  8. How to configure additional IP address on the same interface in solaris zones
  9. How to setup a chroot ssh/sftp in Solaris 10
  10. GUDS – A Script for Gathering Solaris Performance Data

You May Also Like

Primary Sidebar

Recent Posts

  • Failed to start LSB: Bring up/down networking – On restarting network service CentOS/RHEL (DHCP client)
  • How To Add Timestamps To dmesg Kernel Boot Log in CentOS/RHEL
  • How to disable ICMP redirects on CentOS/RHEL
  • What are Oracle Key Vault Roles
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary