PDA

View Full Version : [ubuntu] Swap



Allin01
January 3rd, 2009, 01:53 PM
Hi,

I have installed ubunto. I have not created swap partition.

Now I need to have swap for hibernate!

What is the best way to do so?

And what is the optimum swap size?

Regards

nemilar
January 3rd, 2009, 02:00 PM
If you left some space available on your drive after partitioning (unused space), you can create a swap partition there. If not, you'll have to resize. Either way, I recommend you use gparted; if you have to resize, you'll need to download the gparted liveCD and boot it; if you still have some unpartitioned space left on your drive, you can do it from within ubuntu with the 'gparted' command.

gparted liveCD: http://gparted.sourceforge.net/livecd.php


I hear recommendations usually on the order of swap = 2 * physical memory

which tends to be a good amount.

Once you've created the swap partition, note what its device number is (e.g, /dev/sda5) and add the following line to your /etc/fstab file:


/dev/sda5 none swap defaults 0 0


replacing /dev/sda5 with the appropriate device.

Reboot.

Paqman
January 3rd, 2009, 02:25 PM
I hear recommendations usually on the order of swap = 2 * physical memory

which tends to be a good amount.


That recommendation tends to be overkill on a modern system. I would advise swap=RAM for hibernation, otherwise swap=1GB.

linux_tech
January 3rd, 2009, 02:31 PM
If you have a small amt of RAM, say 256MB, they recommend having a swap file of 2X = 512MB. If you have more memory, say 2GB, then swap becomes less of an issue and 1X is more than enough (setting swap @ 1GB-2GB is plenty)

linux_tech
January 3rd, 2009, 02:38 PM
more info on swap files here-
https://help.ubuntu.com/community/SwapFaq

Allin01
January 3rd, 2009, 05:01 PM
Is it better to have swap file or swap partition?

taurus
January 3rd, 2009, 05:09 PM
If you left some space available on your drive after partitioning (unused space), you can create a swap partition there. If not, you'll have to resize. Either way, I recommend you use gparted; if you have to resize, you'll need to download the gparted liveCD and boot it; if you still have some unpartitioned space left on your drive, you can do it from within ubuntu with the 'gparted' command.

gparted liveCD: http://gparted.sourceforge.net/livecd.php


I hear recommendations usually on the order of swap = 2 * physical memory

which tends to be a good amount.

Once you've created the swap partition, note what its device number is (e.g, /dev/sda5) and add the following line to your /etc/fstab file:


/dev/sda5 swap swap defaults 0 0


replacing /dev/sda5 with the appropriate device.

Reboot.

Shouldn't the entry for swap partition in /etc/fstab look like this?


/dev/sda5 none swap sw 0 0

nemilar
January 3rd, 2009, 05:14 PM
Actually, reading the manual for fstab, you are correct! I just copied/pasted what I had... not sure why my fstab was written that way, I sure didn't put it like that...

Verrrrrrry interesting. Thanks!!


Shouldn't the entry for swap partition in /etc/fstab look like this?


/dev/sda5 none swap sw 0 0

Paqman
January 3rd, 2009, 05:16 PM
Is it better to have swap file or swap partition?

Performance wise, I don't believe it makes any difference at all. A swap partition allows you to use hibernation, whereas a swap file won't. By default Ubuntu creates a swap partition.

Allin01
January 3rd, 2009, 05:34 PM
Performance wise, I don't believe it makes any difference at all. A swap partition allows you to use hibernation, whereas a swap file won't. By default Ubuntu creates a swap partition.

It says in swapfaqs "Add how to add the swap file to make Ubuntu hibernate to it "????