Wednesday, February 10, 2010

Creating logical volume for swap

Click Here For Free Windows Downloads
mywindowsdownloads.blogspot.com

Click here for all Free Linux Downloads



Blog address for Linux in Hindi


Assuming /dev/vol_gr0/log_vol2 is the swap volume, we want to create. We will be performing following steps for creating swap:


1. Create logical volume of size 512 Mb:


# lvm lvcreate vol_gr0 -n log_vol2 -L 512M


2. Format this new swap space using following command:


# mkswap /dev/vol_gr0/log_vol2


3. Make the swap to mount automatically, by adding following entry in /etc/fstab file:


/dev/vol_gr0/log_vol2 swap swap defaults 0 0


4. Lastly, enable the extended logical volume using following command:


# swapon -va


5. We may test this logical volume, for its proper extension:


# cat /proc/swaps


Or


# free


Create swap file


1. Find out the size of new swap file in MB and multiply it by 1024 to get number of blocks. E.g. the block size 512 MB swap file is 524288.


2. Run the following command as root, with count equal to calculated block size:


# dd if=/dev/zero of=/swapfile bs=1024 count=524288


3. Run the following command to setup swap file:


# mkswap /swapfile


4. Enable swap file immediately using following command:


# swapon /swapfile


5. to make it automatically enabled at boot time, add the following entry in /etc/fstab file:


/swapfile swap swap defaults 0 0


6. We can verify it is enabled or not by following command:


# cat /proc/swaps


Or


# free

No comments:

Post a Comment