Friday, June 29, 2018

swap - Increase Swapfile on operational system



new to this and I am trying to figure what will be the best way to go on about this. I have a system that I need to increase its swap file, I realized that the swap partition is not lvm so that is kind of out. However, my current swap partition is 8Gb but needs to be at 16GB.



#  swapon -s

Filename Type Size Used Priority
/swapfile file 8191996 6341008 -1


I guess my issue is that it is a swap file and not a partition (at least is an issue for me :(...) I read online I can use dd to create a swapfile, but I'm not sure I understand how to actually increase the size or if I need to create a new partition.



/etc/fstab looks like this:



/swapfile        swap           swap    defaults        0 0



Any recommendations on how to proceed?


Answer



As mentioned above, you can resize the swapfile to gain the desired effect.
But I would recommend adding another swapfile, with the same priority, so you will not need to swap out the GB's of swapped data.



# Create another swapfile, mind the filename!
sudo dd if=/dev/zero of=/swapfile2 bs=1M count=8192
# Make the new file a swapfile
sudo mkswap /swapfile2

# Enable it
sudo swapon /swapfile2
# Change its priority
sudo swapon /swapfile2 -p -1 # Or anything you want


Then add /swapfile2 swap swap defaults 0 0 to /etc/fstab.


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...