5

I would like to increase swap space on my existing Ubuntu machine. At present it is merely 10 % of RAM available.

I would like to make it as 50 % more than RAM.

How can I do it on a machine which is already configured ?

0

2 Answers 2

3

Use the gparted Live cd (or any other live cd with gparted) and carve out the extra space and resize the swap partition to whatever size you want.

2
  • Just wanted to say exactly the same thing. BTW this is IMHO rather a question for superuser or one of the other sites.
    – Axel
    Jan 21, 2013 at 9:02
  • @Axel ubuntu would be my pick but I think it is going to be migrated to superuser.
    – Karthik T
    Jan 21, 2013 at 9:04
2

Make an empty file of the desired size,

dd if=/dev/zero of=swapfile count=1M bs=1k   # 1GB

(make sure this is owned by root and has permissions 0600), then

mkswap swapfile
swapon swapfile

You need superuser rights for swapon. To make the swapfile persist across reboots, put it in /etc/fstab.

4
  • 1
    You also need to call mkswap on the file.
    – lindelof
    Jul 5, 2014 at 8:02
  • If a swap already exists will this change the existing swap to be increased to 1G? Nov 12, 2014 at 21:07
  • @RyanWiancko It gets increased by 1GB. You can have multiple swapfiles; I'm not sure what the Linux strategy for choosing between them is.
    – Fred Foo
    Nov 13, 2014 at 9:59
  • @larsmans - ah, I see, that is really cool that it can do that. thanks Nov 14, 2014 at 21:37

You must log in to answer this question.

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