How-to: create a swap file

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

How-to: create a swap file

#1 Post by jpeps »

I just ran across this, that might come in useful when there's no swap partition already formatted; just create a swap file:

#as root
#to create a 130mb file
dd if=/dev/zero of=/mnt/hda1/knoppix.swp bs=1024 count=132207

#protect it from everyone but root
chmod 600 /mnt/hda1/knoppix.swp

# format the file to be used as swap
mkswap /mnt/hda1/knoppix.swp

# add swap file it to the usable ram
swapon /mnt/hda1/knoppix.swp

Post Reply