4

I manage an Ubuntu server part-time in a scientific research laboratory, which has 512G memory and 8G swap space. Recently, we occasionally encounter low-frequency memory shortage, so I plan to expand the swap space. Currently, this server cannot accept any shutdown or accident. I find that they all recommend restarting the device after configuring the swap,

eg: Increase swap in 20.04

and I'm not sure if I can avoid this

My plan is:

First, find current swap file

$ sudo swapon --show
NAME      TYPE SIZE USED PRIO
/swap.img file   8G 7.3G   -2

swap off and remove

sudo swapoff /swap.img 
sudo rm /swap.img

create new swap file

sudo dd if=/dev/zero of=/swap.img bs=1M count=92160
sudo chmod 600 /swap.img

create swap

sudo mkswap /swap.img

enable swap

sudo swapon /swap.img
# not reboot

Is it ok and safe to do?

Rohit Gupta
  • 348
  • 2
  • 4
  • 11
zhang
  • 167

0 Answers0