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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • 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. Beginners Guide to Solaris 11 Network Administration
  2. Solaris : How to capture failed login attempts from tty logins (telnet, rlogin, and terminal)
  3. How to set up cron for automatic data collection from the system activity reporter (SAR) in Solaris 10 and 11
  4. How to mount the zfs rpool while booted from CD [SPARC]
  5. Solaris 11 : Setting user and group quota for ZFS datasets
  6. Solaris 11 : Increasing the size of a vdisk in LDom ( with backend device as ZFS volume )
  7. How to find Number of Physical/Logical CPUs, cores and memory in Solaris
  8. How to Collect a Forced Crash Dump of a Hanging Solaris Guest LDom
  9. Solaris 10 (x86/x64) : How to boot into single user mode from the Grub boot loader
  10. The ultimate Solaris CRON troubleshooting guide

You May Also Like

Primary Sidebar

Recent Posts

  • protonvpn-cli Command Examples in Linux
  • protonvpn-cli connect Command Examples
  • procs Command Examples in Linux
  • prlimit: command not found

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright