Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

how to increase swap memory in debian?

share|improve this question
    
Umm...doesn't this belong on SU? –  daviesgeek Dec 2 '11 at 6:30
add comment

closed as off-topic by MDMarra, TheCleaner, Falcon Momot, MadHatter, Ward Sep 19 '13 at 5:06

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions must demonstrate a minimal understanding of the problem being solved. Try including attempted solutions, why they didn't work, and the expected results. See How can I ask better questions on Server Fault? for further guidance." – MDMarra, TheCleaner, Falcon Momot, MadHatter, Ward
If this question can be reworded to fit the rules in the help center, please edit the question.

3 Answers

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.

share|improve this answer
add comment

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.
share|improve this answer
    
Btw. you will have to run swapon with sudo, otherwise you might get command not found. –  kadaj Jul 14 '13 at 16:50
add comment

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.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.