Kiểm tra kích thước hiện tại của bộ nhớ
free -m
Kiểm tra file swap hiện tại
cat /etc/fstab
# Accessiblefilesystems, byreference, aremaintainedunder '/dev/disk'
# See man pagesfstab(5), findfs(8), mount(8) and/orblkid(8) for more info
#
/dev/mapper/centos-root / xfs defaults 0 0
UUID=11bbb941-3929-44fc-89d5-94272765cb99 /boot xfs defaults 0 0
/dev/mapper/centos-home /home xfs defaults 0 0
/dev/mapper/centos-swap swap swap defaults 0 0
File swap được đặt tại /dev/mapper/centos-swap
Turn off this swap file:
swapoff /dev/mapper/centos-swap
Remove the old swap file:
rm -f /dev/mapper/centos-swap
Create a new swap file (the size is 8GB in this example):
dd if=/dev/zero of=/dev/mapper/centos-swap count=8192 bs=1MiB
Make this file as a swap file:
mkswap /dev/mapper/centos-swap
Set right permission:
chmod 600 /dev/mapper/centos-swap
Turn the swap on again:
swapon /dev/mapper/centos-swap
Check what we did:
free -m
That's all.