Adding a Linux Swap File for Virtual Memory

Give your Linux system more virtual memory

By Robin Rowe

HOLLYWOOD, CA (Hollywood  Today) 2012/2/27 – Sometimes you need a little more memory for programs that use a lot of memory like Firefox. It used to be you had to dedicate a separate swap partition, but now Linux virtual memory can use a file instead of a partition, like Windows. Here’s how to set that up….

# dd if=/dev/zero of=/boot/swapfile bs=1024 count=524288
# mkswap /boot/swapfile
# chown root:root /boot/swapfile
# chmod 0600 /boot/swapfile
# swapon /boot/swapfile

vi /etc/fstab

/boot/swapfile swap swap defaults 0 0


$ free

Leave a Reply

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