Linux add swap space file
To add swap space for Linux, you'll need to add either a swap partition or create a new (big) file and use it for swap:
To add a new 1GB file I do this:
To enable the swap file for the next boot, edit /etc/fstab and add this:
To check that the swap file is used, type:
That's it!
bs: blocksize
count: number of blocks 1 million blocks x 1K = 1G
To add a new 1GB file I do this:
root@debian>
mkdir /swap
dd if=/dev/zero of=/swap/swapfile_1gb bs=1024 count=1048576
mkswap /swap/swapfile_1gb
swapon /swap/swapfile_1gb
To enable the swap file for the next boot, edit /etc/fstab and add this:
/swapfile swap swap defaults 0 0
To check that the swap file is used, type:
swapon -s
free
That's it!
bs: blocksize
count: number of blocks 1 million blocks x 1K = 1G
Comments