swap partition and hibernation question

Asked by oscar m.

Okay, I just started using linux a day ago. I installed Ubuntu by choosing "alongside" Windows 7. 30gb. (ubuntu)

It says hibernation mode will not be available. Is this because a swap partition won't be made?
If I choose to make a swap drive, will I be able to use hibernation?

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
oscar m.
Solved:
Last query:
Last reply:
Revision history for this message
François Tissandier (baloo) said :
#1

You need a swap partition for hibernation indeed. Same size as your RAM.
And anyway, it's always better to have a SWAP partition. Otherwise, if one day an application has a memory leak and fill your RAM, your computer will become almost unusable.

Revision history for this message
oscar m. (osxi-mjr) said :
#2

Whats the best way to make one? Isnt there some partition maker within Ubuntu? I read its better to make a swap twice as big as your RAM, I got 4gb.

Revision history for this message
François Tissandier (baloo) said :
#3

You can manage partitions from Ubuntu, yes. However, it depends what kind of manipulations you have to do on your harddrive.

Let's say you can do it from within Ubuntu, here is the process:
-check if you have Gparted in System>Administration
-if not, open the Software Center, and look for Gparted, install it
-BACKUP YOUR DATA. You never know, touching partitions is always risky, don't take any risk.
-open Gparted, create the swap partition wherever you want (make sure you choose the "linux-swap" partition format), click on "apply" to create it
-same size as your RAM should be enough. 8GB of swap, that's a lot... I don't think it's necessary.

-then you have to make sure Ubuntu will use it each time you boot. In Gparted, right click the swap, "information", copy the UUID (that's the ID of the partition)
-open a terminal in Applications>Accessories>Terminal
-type "sudo gedit /etc/fstab", enter your password
-BE CAREFUL, don't mess with this file :)
-just add this line at the end of the file:

UUID=COPY-THE-UUID-HERE none swap sw 0 0

-don't touch anything else ok ? :)
-save, close, reboot, the swap should be mounted, you can see it in the system monitor application.

Revision history for this message
François Tissandier (baloo) said :
#4

If the edition of the file seems too complicated for you, you can also install a partition manager, there are a couple in the software center. They will allow you to specify the new partition as a mountable swap. But there are also plenty of options, it's not easy to know which ones to check/uncheck.

Revision history for this message
oscar m. (osxi-mjr) said :
#5

Oh wow, That sounds pretty easy, the way you explained it.
I still want to make sure of some things though. Wont repartitioning a hard drive erase everything on it?
I have Gparted and I took a look at the partitions and I am way too paranoid about it because I got Windows with Ubuntu inside the same harddrive and now Im not sure which is which. I know what im doing most of the time but I am a fresh noob at Linux.

I already got my Windows7 backed up on an ext.HD and burned a recovery cd, but even though I dont want the hassle of reinstalling everything if something goes horribly wrong.
Does Gparted just take a portion or does it erase everything on it as well?

I can take a screen shot of both OS`s drive info just to make sure but Im at work for the next 8 hours but when I get back I can post it right away. Maybe you can help me from there. All I need to know is which drive to use and if im losing anything on that.

Thanks for your all your recent help Tissandier

Revision history for this message
oscar m. (osxi-mjr) said :
#6

Would it also be safer if I just make a swap file? Performance wise.
I do alot of recording and editing.

Revision history for this message
François Tissandier (baloo) said :
#7

A swap file would work indeed and would be a bit easier to create, but not much.
Performance wise, it could be a little bit slower.

Gparted can create the new partition without erasing anything. But of course, it requires to know what you are doing.
If you post a create capture of the disks' configuration in Gparted, I can probably tell you how easy it would be for you and what to do exactly. But I need to see both drivers partitions, that would be much safer ;)

Revision history for this message
oscar m. (osxi-mjr) said :
#8
Revision history for this message
oscar m. (osxi-mjr) said :
#9
Revision history for this message
François Tissandier (baloo) said :
#10

Ok, in Gparted, you should see another drive. Could you change in the drop down menu on the top right corner ? (currently it's "sda", you must have another drive). Change it, post me with the capture, and i'm sure I can easily help you.

Revision history for this message
oscar m. (osxi-mjr) said :
#11

http://i52.tinypic.com/212g5e9.jpg

wow, odd.
this doesnt drop down anything else but /dev/sda

Im I doing something wrong?

Revision history for this message
François Tissandier (baloo) said :
#12

Mmmmm, my mistake maybe... Do you have one hard drive ? Two maybe ?

Probably just one. And you installed Ubuntu using Wubi, right?

Revision history for this message
oscar m. (osxi-mjr) said :
#13

Yes sir, only one hard drive on my laptop. And yes, I installed using Wubi

Revision history for this message
François Tissandier (baloo) said :
#14

Mmmm ok, more complicated. have to go running now, will keep u updated when I'm back !

Revision history for this message
François Tissandier (baloo) said :
#15

Wubi makes things a bit more complicated:
-I'm not sure if it's easy to create a swap partition in wubi
-you can create a swap file more easily probably, but
-wubi is a partition within a partition, so performances can't be as good as a real native partition
-and if the windows partition has a serious problem, you loose both systems

I think it's a great solution to test Ubuntu, but it's better to use real partitionso if you plan to keep it.

Revision history for this message
oscar m. (osxi-mjr) said :
#16

I kind of figured it out.

I went on Windows C:/ubuntu/disks
It had:

Boot (folder)
root.disk
swap.disk

Then I went on Ubuntu> Terminal

Entered:

sudo su
swapoff -a
cd /host/ubuntu/disks/
mv swap.disk swap.disk.bak
dd if=/dev/zero of=swap.disk bs=1024 count=4194304
mkswap swap.disk
swapon -a
free -m

then

rm swap.disk.bak

I checked back on Windows and now the swap.disk on c:/ubuntu/disks
is now 4gb, used to be 256mb.

Final thing, I need to mount it I guess? Can you help me out?

Revision history for this message
oscar m. (osxi-mjr) said :
#17

Alright I did it. I mounted it just as how you told me to but theres another problem.
I rebooted and check the memory status', says 4gb. So I tested out Hibernation and I thought it was working then it went black and said "Cannot find Swap Header". Went back to desktop.

What does that mean?
Heres my fstab

# /etc/fstab: static file system information.
#
# Use 'blkid -o value -s UUID' to print the universally unique identifier
# for a device; this may be used with UUID= as a more robust way to name
# devices that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc nodev,noexec,nosuid 0 0
/host/ubuntu/disks/root.disk / ext4 loop,errors=remount-ro 0 1
/host/ubuntu/disks/swap.disk none swap loop,sw 0 0
/host/ubuntu/disks/swap.disk none swap sw 0 0

Did i do something wrong there?
For some reason Im thinking its this line:

/host/ubuntu/disks/swap.disk none swap loop,sw 0 0
/host/ubuntu/disks/swap.disk none swap sw 0 0

theres two lines for swap.disk Should I get rid of the first line..? its the older one or no?
OR Should I redo the second line by instead of inserting the location, instead putting the UUID?

Please get back to me, Im so close.

Revision history for this message
François Tissandier (baloo) said :
#18

One line is enough. Remove the one without "loop". I'm not 100% sure because it's a wubi install, but that sounds more logical.

Then try to reboot and see if it's better

Revision history for this message
oscar m. (osxi-mjr) said :
#19

GAH, still the same

Oct 15 00:30:46 ubuntu kernel: [ 58.062812] hda-intel: spurious response 0x0:0x0, last cmd=0x170503
Oct 15 00:30:46 ubuntu kernel: [ 58.062814] hda-intel: spurious response 0x0:0x0, last cmd=0x170503
Oct 15 00:30:46 ubuntu kernel: [ 58.062815] hda-intel: spurious response 0x0:0x0, last cmd=0x170503
Oct 15 00:30:46 ubuntu kernel: [ 58.062817] hda-intel: spurious response 0x0:0x0, last cmd=0x170503
Oct 15 00:30:46 ubuntu kernel: [ 58.062818] hda-intel: spurious response 0x0:0x0, last cmd=0x170503
Oct 15 00:30:46 ubuntu kernel: [ 58.062820] hda-intel: spurious response 0x0:0x0, last cmd=0x170503
Oct 15 00:30:46 ubuntu kernel: [ 58.062821] hda-intel: spurious response 0x0:0x0, last cmd=0x170503
Oct 15 00:30:46 ubuntu kernel: [ 58.062823] hda-intel: spurious response 0x0:0x0, last cmd=0x170503
Oct 15 00:30:46 ubuntu kernel: [ 58.062824] hda-intel: spurious response 0x0:0x0, last cmd=0x170503
Cannot find swap header

Wow, this is really frustrating

Revision history for this message
François Tissandier (baloo) said :
#20

Sounds like you are out of luck:

https://bugs.launchpad.net/ubuntu/+source/gnome-power-manager/+bug/313724

It seems that hibernation won't work with a swap file instead of a swap partition...
You should consider moving Ubuntu to a real partition if you want to use it at 100% speed & functionnalities.
However it's not a trivial operation: the way Windows is installed on the harddrive doesn't allow you to install another system super easily. On the long term, I still think it's the best solution, but it needs to be done with care.

Revision history for this message
oscar m. (osxi-mjr) said :
#21

I've accepted it. LOL
I guess I'll just install ubuntu on 32gb and run it on that.
Thanks for all the help man.

Revision history for this message
François Tissandier (baloo) said :
#22

Have fun :)

If you need any help, you know where to ask !