Maintenance of swap space in Linux
Wen: Hao Qiang
Linux operating systems are more and more attention! I have accumulated some tips in learning and use, and now share it with you. Of course, I am here is not Linux tutorial. I just explain the creation, use, and removal of Linux swap space (exchange files and exchange partitions). Methods and techniques.
1. Create a swap space
1) Adding new ways of switching space is to create a new exchange partition or exchange file. Create a new exchange partition with the fdisk command. Increasing new exchange files can be easily implemented with DD commands. For example: establish an 8M page exchange file SWAP
DD if = / dev / zero of = / swap bs = 1024 count = 8192
This creates a swap file SWAP. For / dev / zero, it is a special device that is always zero to its read operation.
2) "Format" exchange area.
Use the mkswap command. The command format is as follows: MKSwap -c device size
-c is an optional switch for checking corrupted blocks before formatting the switching area. Device is the file name of the exchange partition or exchange file. SIZE is the size of the exchange area, the unit is K byte!
For example: mkswap -c / swap 8192
If MKSWAP -C / DEV / HDAX X is the logical partition number if mkswap -c / dev / hdax x is available for the switch partition.
Note: After MKSWAP for a file, you must use the sync command to ensure that the format information is already physically written into the exchange file. For a swap partition, there is no need to do SYNC.
2. Activate switch space
The new switching space must be activated with Swapon before use.
For example: swapon / swap activation exchange file SWapon / DEV / HDAX activation switch partition
Like a file system, the switching area is also automatically activated from a startup file (usually /etc/rc.d/rc.s) when the system is started. This command looks for / etc / fstab file, all / etc / fstabs, Type columns are activated by Swapon for SWAP (or OPTINS column SW).
Note: After the user added a switch area, a record must be added to the / etc / fstab file.
3. Close switch space
Turn off the switch Swapoff Device implementation.
The Device here can be the name of the exchange partition or file to be closed.
After the switching area is turned off, you can reclaim the file with the RM command directly with the RM command. Note: If you delete a file before you close it, there will be catastrophic consequences.
Finally, the corresponding record is removed in / etc / fstab, otherwise the error will not be found in the next boot.
Home: http://home.seasky.net/Acehq
Email: acehq@163.com