linux method to add and increase swap partitions (swap)

  • 2020-05-07 20:46:17
  • OfStack

1) add or expand swap partitions
#dd if=/dev/zero of=/home/swap bs=512 count=1024000
bs is the sector size bs=512 refers to the size of 512B count is the number of sectors
Represents the creation of a file of size 512M /home/swap filled with null values. The of position can be adjusted by itself.
2) create swap partitions
/sbin/mkswap swapfile

3) activates the swap
/sbin/swapon swapfile
4) query the swap status currently in effect on the system
/sbin/swapon -s
5) set the boot to mount itself
For
/etc/fstab, add the following line
redhat or centos:
#/home/swap swap swap defaults 0 0
Ubuntu:
#/home/swap none swap sw 0 0
Use mount-a to check if the modification is correct


Related articles: