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 specifies the file size in KB, bytes, or MB specified by k, b, or m. For example, to create 500MB swap space, issue the following command:
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 -l
You 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 -d
This 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:
rm
You 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:
swap []
The options are described here:
-a . Activate a swap file whose full path is specified by .
-d . Make the file specified by unavailable to swapping without removing the file.
-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博客 ” ,链接:http://blog.itpub.net/25196159/viewspace-683722/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/25196159/viewspace-683722/