Add a swap partition to digitalocean in a few simple steps

888u

Last update at :2024-05-01,Edit by888u

When I checked the statistics, I found that someone was searching for digitalocean swap. In fact, such a problem should be searched by novices. Generally, people who have used VPS for a period of time will know how to deal with it. In fact, I have posted a similar article on our website before "Adding a swap partition to XEN VPS", but what I did not explain is that the adding method for XEN and KVM virtual VPS is the same, which means it can be used universally, but you can also Don't think that KVM and XEN can add swap, so can openvz? Let me tell you clearly that openvz is not allowed.

Let’s continue frying the leftovers here and add swap to digitalocean in a few simple steps:

Add 2G swap bs*count is the swap size

dd if=/dev/zero of=/var/swapfile bs=1M count=2048

Create swap file

/sbin/mkswap /var/swapfile

Activate swap file

/sbin/swapon /var/swapfile

Check whether the swap is correct: /sbin/swapon -s

In addition, for security reasons, it is recommended to execute: chmod 0600 /var/swapfile and change the permissions

Add automatic mounting settings at startup to the fstab file

echo “/var/swapfile swap swap defaults 0 0” >>/etc/fstab

SWAP deletion method

/sbin/swapoff /var/swapfile

rm -f /var/swapfile

Delete the added automatic mounting swap settings

vi /etc/fstab deletes previously mounted content

Recommended site search: How to bind domain name to server, US vps server, qq proxy server ip, Qingdao ip proxy, domain name space purchase and view ip, US host rental, instant ip server replacement, foreign server vps, ip138 website query, < /p>

Add a swap partition to digitalocean in a few simple steps

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码