Increasing the Swap Space

This section describes how to increase the swap space on a guest vServer by using LVM commands.

Note:

The procedure described here is relevant to vServers created by using the EECS 2.0.6.x.x Guest Base Template. Do not use this procedure to modify the disks of vServers creating using a Guest Base Template that is earlier than EECS version 2.0.6.0.0.

  1. Create a volume as described in Creating Volumes.
  2. Attach the volume to the vServer for which you want to modify the swap space, as described in Attaching Volumes to a vServer.
  3. Log in, as the root user, to the vServer for which you want to modify the swap space, and verify whether the volume is attached.
  4. Format the partition as an LVM-type partition.
    # fdisk /dev/xvdc
    Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
    Building a new DOS disklabel. Changes will remain in memory only,
    until you decide to write them. After that, of course, the previouscontent won't be recoverable.
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
    
    Command (m for help): n
    Command action
    e   extended
    p   primary partition (1-4)
    p
    Partition number (1-4): 1
    First cylinder (1-261, default 1): Press Enter
    Last cylinder or +size or +sizeM or +sizeK (1-261, default 261): Press Enter
    Using default value 261
    
    Command (m for help): t
    Hex code (type L to list codes): 8e
    Changed system type of partition 2 to 8e (Linux LVM)
    
    Command (m for help): w
    The partition table has been altered!
    
    Calling ioctl() to re-read partition table.
    
    WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
    The kernel still uses the old table.
    The new table will be used at the next reboot.
    Syncing disks.
    
  5. Create a physical volume for the partition:
    # pvcreate /dev/xvdc1
    
  6. Add the newly formatted disk to the existing volume group:
    # vgextend myVolGroup /dev/xvdc1
    
  7. Create a logical volume:
    # lvcreate -l 511 myVolGroup -n myVolGroup-LogVol01
    
  8. Format the logical volume for swap use:
    # mkswap /dev/myVolGroup/myVolGroup-LogVol01
    
  9. Enable swap:
    # swapon /dev/myVolGroup/myVolGroup-LogVol01
    
  10. Verify the updated swap space by either using the top command, or by examining the /proc/swaps file as shown in the following example:
    ]# cat /proc/swaps
    Filename Type Size Used Priority
    /dev/mapper/VolGroup00-LogVol01 partition 524280 0 -1
    /dev/mapper/myVolGroup-myVolGroup--LogVol01 partition 2093048 0 -2