Wednesday, April 13, 2011

Create swap file in Linux

Some time ago when I was working with a BeableBoard-like dev board I had troubles creating Linux swap file. After reading some guides over the internet I'd like to share this simple how-to (Ubuntu):

1) Create "empty" file (~537 MB):
$ dd if=/dev/zero of=/swapfile1 bs=1024 count=524288

2) Setup Linux swap area:
$ mkswap /swapfile1

3) Activate swap space immediately:
$ swapon /swapfile1

4) Add to fstab (optional):
/swapfile1 swap swap defaults 0 0

To test:
$ free -m

To deactivate:
$ swapoff /swapfile1


Hope that someone would find it useful :)
-----------------------------------------------------------------------------------------------------------------

No comments:

Post a Comment