how to increase swap memory in debian?

  • 1
    Umm...doesn't this belong on SU?
    – daviesgeek
    Dec 2, 2011 at 6:30

3 Answers 3


In a pinch, you can create a new swap partition or file.

For a partition:

  1. Format the new partition with mkswap /dev/sdx1
  2. Add the new swap partition to /etc/fstab.
  3. Run swapon -a to activate the new swap.

To add a swap file:

  1. Create the file. This command creates a 1 gigabyte file: dd if=/dev/zero of=/swap bs=1M count=1000
  2. Format the swap file: mkswap /swap
  3. Add the new swap file to /etc/fstab: /swap swap swap defaults 0 0
  4. Run swapon -a to activate the new swap.
  • Btw. you will have to run swapon with sudo, otherwise you might get command not found.
    – John Doe
    Jul 14, 2013 at 16:50

Run the following commands

dd if=/dev/zero of=/swap bs=512k count=1024
mkswap /swap
chmod 0600 /swap
swapon /swap

you will also have to add this line to /etc/fstab

/swap swap swap defaults 0 0

You can run free -m to find the swap space used in megabytes before and after the allocation of swap space.


Good info on several ways to increase/change swap partition size here: https://help.ubuntu.com/community/SwapFaq. Follow the steps mentioned in section: How do I add more swap?

This needs a few changes.

  1. You need to do swapoff -a after you update the /etc/fstab with the new swap partition info. Without this, after you run swapoff at a later stage, it will show both partitions.

  2. Even if you use hibernation, you may not need to add the new swap's UUID in GRUB_CMDLINE_LINUX in /etc/default/grub file.

The other steps steps are fine and works.

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