How do you create and use a swapfile in Linux 2.6?

by Geethalakshmi 2010-05-30 03:30:25

How do you create and use a swapfile in Linux 2.6?


Make the swapfile as big as the internal memory.

root@host:/# dd if=/dev/zero of=/swapfile bs=1M count=256
root@host:/# mkswap /swapfile

Edit /etc/fstab, add:
/swapfile none swap defaults 0 0

root@host:/# swapon -a

Be sure to mount the swapfile after regular file systems is mounted (in your startup scripts):
/bin/mount -n -o remount,rw
/bin/rm -f /etc/mtab*
/bin/mount -a -O no_netdev
swapon -a

Tagged in:

932
like
0
dislike
0
mail
flag

You must LOGIN to add comments