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 ?

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.

| improve this answer | |
  • 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 '13 at 9:02
  • @Axel ubuntu would be my pick but I think it is going to be migrated to superuser. – Karthik T Jan 21 '13 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.

| improve this answer | |
  • 1
    You also need to call mkswap on the file. – lindelof Jul 5 '14 at 8:02
  • If a swap already exists will this change the existing swap to be increased to 1G? – unc0nnected Nov 12 '14 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 '14 at 9:59
  • @larsmans - ah, I see, that is really cool that it can do that. thanks – unc0nnected Nov 14 '14 at 21:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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