Linux add swap

Information of device properties, device configuration, internal register modification, memory mapping.
Creating, building, loading and executing binary images form RedBoot, including Linux kernel.
Creating, building, loading and executing binary files from Linux user and kernel space.

Linux add swap

Postby kakanakov » Sat May 14, 2011 9:42 am

Procedure to add a swap file

You need to use dd command to create swapfile. Next you need to use mkswap command to set up a Linux swap area on a device or in a file.

a) Login as the root user

b) Type following command to create 512MB swap file (1024 * 512MB = 524288 block size):
Code: Select all
# dd if=/dev/zero of=/swapfile1 bs=1024 count=524288

c) Set up a Linux swap area:
Code: Select all
# mkswap /swapfile1

d) Activate /swapfile1 swap space immediately:
Code: Select all
# swapon /swapfile1

e) To activate /swapfile1 after Linux system reboot, add entry to /etc/fstab file. Open this file using text editor such as vi:
Code: Select all
# vi /etc/fstab

Append following line:
Code: Select all
/swapfile1 swap swap defaults 0 0

So next time Linux comes up after reboot, it enables the new swap file for you automatically.

g) How do I verify swap is activated or not?
Simply use free command:
Code: Select all
$ free -m
User avatar
Posts: 28
Joined: Fri Mar 06, 2009 4:36 pm
Location: Lab 2204a, campus 2, TU - Plovdiv

Return to EP9302_Linux

Who is online

Users browsing this forum: No registered users and 2 guests