RedHat Extending Swap
id : wjeeg1lerr
category : computer
blog : unixlinux
created : 06/25/10 - 14:01:37

On an LVM 2 Logical Volume
  • First, disable swapping on your associated logical volume :
# swapoff -v /dev/vg00/lvsys01

  • Use lvresize to resize your logical volume :
# lvresize /dev/vg00/lvsys01 -L+2G

  • Re-create the new swap space :
# mkswap /dev/vg00/lvsys01

  • Enable the extend volume
# swapon /dev/vg00/lvsys01

  • Check if everything was alright :
# free -m
# cat /proc/swaps


With a new swap file
  • Determine the size of the new swap file in megabytes and multiply by 1024 to determine number of blocks.
  • Create the new swap file with 'dd command :
# dd if=/dev/zero of=/swapfile bs=1024 count=2097152

  • Create the swap file with mkswap command :
# mkswap /swapfile

  • Enable swap with swapon command :
# swapon /swapfile

  • Don't forget ton enable it at boot time, edit your /etc/fstab file and add :
/swapfile swap swap defaults 0 0

  • Check if everything was alright :
# free -m
# cat /proc/swaps