Last update at :2024-01-01,Edit by888u
1. Linux Swap partition size selection
The size of the Linux Swap partition is related to the physical memory size of your server itself. The larger the memory, the larger the Swap partition should be set. The relationship between the two is as follows.
Physical memory swap partition (SWAP)
2. Linux Swap partition Create/add Swap partition
1. View the current Linux Swap partition
The command is as follows:
free -m2. Close the Swap partition
If we need to add a Swap partition, we must first close the Swap partition. The command is as follows:
swapoff -aIf the Swap partition cannot be closed, it may be because the current physical memory usage + the current usage of the Swap partition has exceeded the total size of the physical memory. We can restart the server first and close the Swap partition when the machine first starts.
3. Create Swap partition file
The creation command is as follows, where /var/swapfile is the file location and bs*count is the file size. For example, the following command will create a 4G file:
dd if=/dev/zero of=/var/swapfile bs=1M count=40964. Create Swap file system
Format the file just now into a Swap partition file. The command is as follows:
mkswap /var/swapfile5. Enable Swap partition
Open the Swap partition based on the new Swap partition file:
swapon /var/swapfile6. View the current Linux partition
Check whether the Swap partition is successfully created/added:
free -mAs shown in the figure below, a 4GB Swap partition space has been successfully created:
7. Setting up startup
Add the following code to the /etc/fstab file to allow the Linux swap partition to be automatically mounted at boot:
/var/swapfile swap swap defaults 0 0Recommended site searches: registration-free space, Hong Kong vps host rental, free virtual host application, website IP query, proxy server IP, Japanese proxy server IP, domain name registration website, which Hong Kong space is better, virtual host rental, private server rental ,
发表评论