Monday, April 01, 2019

Adding or Enlarging Swap file


#create a swap file, fallocate is not working

#fallocate -l 2G /swapfile

dd if=/dev/zero of=/swapfile bs=1024 count=2097152
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
#also make it part of fstab
/etc/fstab
/swapfile swap swap defaults 0 0

##enlarge to 8 gb
swapoff /swapfile
dd if=/dev/zero of=/swapfile bs=1M count=6144 oflag=append conv=notrunc
mkswap /swapfile
swapon /swapfile

No comments: