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.
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.
chmod 600 /path/to/swapfile
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.