Sunday, December 11, 2011

How to create Swap space with a file

a) Login as the root user
b) Type following command to create 8GB swap file (1024 * 1024 * 8  =  8388608 block size):
# dd if=/dev/zero of=/swapfile bs=1024 count=8388608
Note : In  server there was not enough space to create swap file of 8 GB on / parent directory

a)    Create a file /u01/swapfile
b)    Create a symlink from the parent directory
cd  /

ln –s /u01/swapfile                   /swapfile


c)  Set up a Linux swap area:
# mkswap /swapfile

d)  Activate /swapfile swap space immediately:
# swapon /swapfile

e) To activate /swapfile after Linux system reboot, add entry to /etc/fstab file. Open this file using text editor such as vi:
# vi /etc/fstab
Append following line:
/swapfile swap swap defaults 0 0
So next time Linux comes up after reboot, it enables the new swap file for you automatically.
f) How do I verify swap is activated or not?
Simply use free command:
#  free -m

3 Comments:

At September 19, 2012 at 9:25 AM , Blogger srinicame said...

Thanx for the info.

 
At September 19, 2012 at 9:33 AM , Blogger srinicame said...

You have used swapfile and swapfile1 to indicate the same information. Please do correct the typo

 
At September 18, 2014 at 10:56 PM , Blogger Unknown said...

Nice post dear. I really like it Zero Clients & Thin Clients

 

Post a Comment

Subscribe to Post Comments [Atom]

<< Home