Solaris / OpenSolaris Add Swap File

www.l‮.iruttua‬com
Solaris / OpenSolaris Add Swap File

To add a swap file on Solaris or OpenSolaris, you will need to create a file with the desired size and then use the swap command to enable it as swap space.

  1. Create a file: Use the dd command to create a file with the desired size for the swap file. For example:
dd if=/dev/zero of=/path/to/swapfile bs=1M count=2048

This will create a 2 GB file at /path/to/swapfile. You can adjust the count parameter to change the size of the file.

  1. Set the permissions on the file: Set the permissions on the file so that only the root user can read and write to it. Run the following command:
chmod 600 /path/to/swapfile
  1. Enable the file as swap space: Use the swap command to enable the file as swap space. For example:
swap -a /path/to/swapfile

This will add the file as swap space to the system.

To make the swap file persistent across reboots, you will need to add an entry for it to the /etc/vfstab file. For example:

/path/to/swapfile - - swap - no -

Save the file and the swap file should be enabled automatically on future reboots.

Note: These commands require root privileges to execute.

Created Time:2017-10-30 14:27:19  Author:lautturi