Wednesday, 7 December 2011

Swap Partition And Swap File In RHEL 5


[root@server1 ~]#swapoff –a
[root@server1 ~]# fdisk /dev/hda
Create a new partition of 2*RAM and assign the id 82 which is allocated for swap partition.
[root@server1 ~]#mkswap –v1 /dev/hda15
-v1 switch is used for version number.
Add an entry in /etc/fstab file
[root@server1 ~]# vi /etc/fstab
/dev/hda15 swap swap defaults 0 0
:wq Activate the swap partition using
[root@server1 ~]#swapon –a
(which reads /etc/fstab and turns on all the swap entries in the list.
[root@server1 ~]# swapon –s (is used to check the status of swap partition.)
Creating a swap file
[root@server1 ~]#swapoff –a
[root@server1 ~]#dd if=/dev/zero of=swapfile bs=512M count=1
[root@server1 ~]#mkswap –v1 /root/swapfile
Add an entry in the /etc/rc.local
[root@server1 ~]#vi /etc/rc.local
Swapon /root/swapfile

No comments:

Post a Comment