1. Use 'fallocate' to create swapfile of desired size:
- Code: Select all
fallocate -l 2G /swapfile
Or use 'dd' create 2048MB swap file (1024 * 2048MB = 2097152 block size):
- Code: Select all
dd if=/dev/zero of=/swapfile bs=1024 count=2097152
2. Adjust permissions
- Code: Select all
chmod 600 /swapfile
3. Set up a Linux swap area:
- Code: Select all
mkswap /swapfile
4. Activate /swapfile swap space:
- Code: Select all
swapon /swapfile
5. To activate /swapfile after Linux system reboot, append the following entry to /etc/fstab file:
- Code: Select all
/swapfile swap swap defaults 0 0