In Linux you can create a swap FILE that performs pretty much the same function as a separate swap PARTITION, but not with the problem that if later you need to resize some partitions you have to dick around with a partition that's in the way. Yes, I know you can delete it and fix things later but to me it just seems easier to not have to worry about it. Again, this little cheat sheet is something that's mostly for myself, a quick copy-paste thing, and if it helps someone else, all the better.

 

Create a 1GB /swapfile1 and place it in /etc/fstab:

dd if=/dev/zero of=/swapfile1 bs=1024 count=1048576 && mkswap /swapfile1 && chown root:root /swapfile1 && chmod 0600 /swapfile1 && swapon /swapfile1 && echo "/swapfile1 swap swap defaults 0 0" >> /etc/fstab

 

Create a 2GB /swapfile1 and place it in /etc/fstab:

dd if=/dev/zero of=/swapfile1 bs=1024 count=2097152 && mkswap /swapfile1 && chown root:root /swapfile1 && chmod 0600 /swapfile1 && swapon /swapfile1 && echo "/swapfile1 swap swap defaults 0 0" >> /etc/fstab

 

Create a 4GB /swapfile1 and place it in /etc/fstab:

dd if=/dev/zero of=/swapfile1 bs=1024 count=4194304 && mkswap /swapfile1 && chown root:root /swapfile1 && chmod 0600 /swapfile1 && swapon /swapfile1 && echo "/swapfile1 swap swap defaults 0 0" >> /etc/fstab

Leave a Reply

Your email address will not be published. Required fields are marked *

Prove that you are not a spam robot: * Time limit is exhausted. Please reload CAPTCHA.