There are two solutions for linux to expand swap space: one is to create a new swap partition; the other is to create a swap file. If all your hard disk space has been allocated to other partitions, there is no extra budget to purchase a new hard disk. we can use the swap file to add a virtual swap empty...
Linux expands swap space
There are two solutions: one is to create a new swap partition, and the other is to create a swap file.
Create a swap file
If all your hard disk space has been allocated to other partitions and there is no extra budget to purchase a new hard disk, we can use the swap file to increase the virtual swap space, however, the execution performance is worse than the actual swap partition.
To create a swap file, run the dd command to add a MB swap file:
# Dd if =/dev/zero of =/100M. swap bs = 1 M count = 100
Run the mkswap command to format the myswap file into the s file system. The system can use it, switch to the/directory, and run the following command:
# Change the file type of fdisk/100m. swap to 82 linux swap.
# Mkswap/100m. swap
Setting up swapspace version 1, size = 104853 kB
# Swapon-s view the current swap information
Filename Type Size Used Priority
/Dev/mapper/VolGroup00-LogVol01 partition 524280 0-1
# Swapon-a/100m. swap-p-2 activate the partition and set its priority
# Swapon-s view the modified swap space
Filename Type Size Used Priority
/Dev/mapper/VolGroup00-LogVol01 partition 524280 0-1
/100m. swap file 102392 0-2
# Free
Total used free shared buffers cached
Mem: 255840 56164 199676 0 8128 26640
-/+ Buffers/cache: 21396 234444
Swap: 626672 0 626672
# Swapoff cancel activation of swap space, swapon-a/dev/sda2-p-10 activate and set priority
Author ehlopxp