Thursday, March 12, 2015

Manage Swap Partition

SWAP Partition- 

Linux uses the SWAP space configured on one or more hard drive partitions to store in 
frequently used programs and data. SWAP space can extend the amount of effective RAM on your 
system. 
Normally, Linux (on a 32bit Intelstyle 
computer) can use a maximum 4GB of SWAP space in 
partitions no larger than 2GB. This 4GB cab be spread over a maximum of eight partitions. The 
typical rule of thumb suggests that SWAP space should be two times the amount of RAM. 
Example 
1GB physical RAM = 2GB SWAP space 

Two method of SWAP partition creating- 

1. Fdisk utility 
2. File method 

# fdisk –l                (Check the partition) 
/dev/sda1 à boot 
/dev/sda2 à / 
/dev/sda3 à Linux SWAP 
/dev/sda4 à Extended partition 

# fdisk /dev/sda         (Create a partition) 

+1024M 


82 



# partprobe /dev/sda or #partx –-a /dev/sda    (Update partition table) 
# reboot 
# mkswap –-L SWAP /dev/sda5                
# swapon /dev/sda5  or # swapon -–a 

#vim /etc/fstab 

LABEL=SWAPsda5 swap swap defaults 0 0 

Or 

/dev/sda5 swap swap defaults 0 0 

#mount –a

Check Swap Status- 


Remove Swap Partition-
  
#swapoff /dev/sda5 
Remove entry form “/etc/fstab” 
#reboot 

Create SWAP space from file method,  First create a blank file- 

# touch /swap 
# dd if=/dev/zero of=/swap bs=1M count=100 
# mkswap -–L SWAP /swap 
# swapon /swap

# vim /etc/rc.local 
Swapon /swap 

Swap run time verify status 

# cat /proc/swaps 

/dev/sda3 partition 4194296 0 1 /swap file 102392 0 2 
Previous Post
Next Post

0 comments: