1

I used the Windows installer to install Ubuntu. It did not ask me the size of swap. I am currently using Ubuntu and have only about 200 MB and my system crashes when I open too many applications.

0

2 Answers 2

1

First of all, swap should be equal 2x physical RAM for up to 2 GB of physical RAM, and then an additional 1x physical RAM for any amount above 2 GB, but never less than 32 MB.

For adding swap space, you have three options: create a new swap partition, create a new swap file, or extend swap on an existing LVM logical volume. It is recommended that you extend an existing logical volume.

Creating a logical volume for swap

To add a swap volume group (assuming /dev/VolGroup00/LogVol02 is the swap volume you want to add):

  1. At a terminal with root privileges (sudo -s), create the logical volume of size 1024 MB (for example):

    lvm lvcreate VolGroup00 -n LogVol02 -L 1024M

  2. Format the new swap space:

    mkswap /dev/VolGroup00/LogVol02

  3. Add the following entry to the /etc/fstab file:

    /dev/VolGroup00/LogVol02 swap swap defaults 0 0

  4. Enable the extended logical volume: swapon -va

  5. Test that the logical volume has been extended properly: cat /proc/swaps or free.

Creating a swap file

To add a swap file:

  1. Determine the size of the new swap file in megabytes and multiply by 1024 to determine the number of blocks. For example, the block size of a 512 MB swap file is 65536.
  2. At a terminal with root privileges (sudo -s), type the following command with count being equal to the desired block size:

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

  3. Setup the swap file with the command:

    mkswap /swapfile

  4. To enable the swap file immediately but not automatically at boot time:

    swapon /swapfile

  5. To enable it at boot time, edit /etc/fstab to include the following entry:

    /swapfile swap swap defaults 0 0

    The next time the system boots, it enables the new swap file.

  6. After adding the new swap file and enabling it, verify it is enabled by viewing the output of the command cat /proc/swaps or free.

Extending swap on a logical volume

To extend a swap logical volume (assuming /dev/VolGroup00/LogVol01 is the volume you want to extend):

  1. At a terminal with root privileges (sudo -s), disable swapping for the associated logical volume:

    swapoff -v /dev/VolGroup00/LogVol01

  2. Resize the LVM logical volume by 1024 MB (for example):

    lvm lvresize /dev/VolGroup00/LogVol01 -L +1024M

  3. Format the new swap space:

    mkswap /dev/VolGroup00/LogVol01

  4. Enable the extended logical volume:

    swapon -va

  5. Test that the logical volume has been extended properly: cat /proc/swaps or free.

Source: http://www.centos.org/docs/5/html/5.1/Deployment_Guide/s1-swap-what-is.html

0

Instead of increasing the current swap area, you can just add a new one (here 1 GiB):

dd if=/dev/zero of=/swapfile1 bs=1M count=1024
chmod 600 /swapfile1
mkswap /swapfile1
echo "/swapfile1  swap  swap defaults 0 0" >> /etc/fstab
swapon /swapfile1

Not the answer you're looking for? Browse other questions tagged .