To add more swap space, perform. the following steps:
Become superuser.
Create a directory for the swap file, if needed—for example:
mkdir /moreswap
Create the swap file by using the mkfile command, which has the following syntax:
mkfile[k|b|m]
The
mkfile 500m /moreswap/swapFile
Activate the swap file by carrying on the same example:
# /usr/sbin/swap -a /moreswap/swapFile
You must use the absolute path name to specify the swap file. The swap file is now added, and activated. It is available until the file system is unmounted, the system is rebooted, or the swap file is removed. The swap file will be automatically activated each time the system is booted, if you perform. the next step.
Add the following entry for the swap file to the /etc/vfstab file, again using the running example:
/moreswap/swapFile—- swap—no -
Issue the following command to verify that the swap file has actually been added:
/usr/sbin/swap -lYou can create a swap file without root permissions. However, if root is not the owner of the swap file, it could be easily overwritten by accident. You can remove a swap file by issuing the following command:
swap -dThis will not remove the file, but it will make it unavailable for swapping. However, if you want the space occupied by the file, you can remove it by using the good old rm command:
rmYou should also remove the entry for the removed swap file from the /etc/vfstab file.
We have used the swap command at several places so far. Now, let's take a look at its syntax:
swapThe options are described here:
-a
-d
-l. Identify the swap space on the system: the device name and the total physical swap space—that is, it does not include any space from the physical memory.
-s. Display the allocated, reserved, and available swap space. This swap space may include part of available physical memory (the virtual swap space).
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/25196159/viewspace-683722/ ,如需转载,请注明出处,否则将追究法律责任。