PDA

View Full Version : [ubuntu] Hibernate function does not work



Johan-Steyn
May 24th, 2009, 11:05 PM
Hi All,

Since upgrading to Jaunty my HP G5000 notebook cannot go into hibernation mode.

The power management settings are set up that the computer should hibernate when the laptop lid is closed; but it fails to do so. It also fails when I select the Hibernate option from the Shutdown / Log Out menu.

It goes to the command prompt screen and then displays a brief message "Cannot find swap-on device" and then it goes back to the log in screen.

Any ideas how to fix his? It was previously working fine in Intrepid.

Thanks,

JS

Didius Falco
May 24th, 2009, 11:17 PM
Hi All,

Since upgrading to Jaunty my HP G5000 notebook cannot go into hibernation mode.

The power management settings are set up that the computer should hibernate when the laptop lid is closed; but it fails to do so. It also fails when I select the Hibernate option from the Shutdown / Log Out menu.

It goes to the command prompt screen and then displays a brief message "Cannot find swap-on device" and then it goes back to the log in screen.

Any ideas how to fix his? It was previously working fine in Intrepid.

Thanks,

JS

Hi,

Open a Terminal and type
cat /etc/initramfs-tools/conf.d/resume

then type
sudo blkid

Compare the UUID number generated by the first command to the UUID number of your swap file. If they don't match, type


sudo gedit /etc/initramfs-tools/conf.d/resume and change the UUID number to match the UUID number from the blkid command.

Save the file, and then run
sudo update-initramfs -u

Regards,

Didius

CBHedricks
May 24th, 2009, 11:22 PM
Did it work before the upgrade with an early edition of Linux or just with the OS that came installed on the notebook.

Chances are the lid switch uses drivers (soft switch) or has to interface thru software inorder to function correctly. If that is the case you may have to look for alternative drivers to use as well. That is the rub with HP notebooks - they are designed from the ground around the Vista OS.

CB

Johan-Steyn
May 25th, 2009, 07:28 AM
Hi Darius,

I think we are the right track here.

The UUID numbers did not match and I used the (cat /etc/initramfs-tools/conf.d/resume) command to change the numbers and they do now match. This was the initial UUID number:

"RESUME=UUID=8bf41afa-459c-4aa1-bdb8-e583feb8e464" (initial)

I changed it using the (sudo gedit /etc/initramfs-tools/conf.d/resume) command and this is the (sudo blkid) output:

"/dev/sda5: UUID="7023d173-f86d-47b4-b504-0ebc61b0a400" TYPE="ext3""

I restarted but unfortunately the hibernate function still failed. I got the following message "Cannot find swap-on device, try swapon -a".

I ran the "swapon -a" command and got the following reply:

johansteyn@johansteyn-laptop:~$ swapon -a
swapon: cannot stat /dev/disk/by-uuid/8bf41afa-459c-4aa1-bdb8-e583feb8e464: No such file or directory

Still the "old" UUID number.

Your help would be appreciated.

Thanks

JS

Johan-Steyn
May 25th, 2009, 07:39 AM
Hi CB,

Thanks for the response.

I changed over to Ubuntu Intrepid 8.10 from Vista. The hibernate function was working 100% previously in Intrepid.

However it was since upgrading to Jaunty 9.04 a few weeks ago; that the hibernate function failed to work anymore.

It kicks out the following error "Cannot find swap-on device, try swapon -a". If I type "swapon -a" in the terminal it says there is no such file or directory.

I think this has to do with the UUID numbers, as suggested by Darius.

Regards,

JS

pspsampsp
May 25th, 2009, 09:44 AM
make sure you run sudo update-initramfs -u and have the initramfs-tools installed.

mcduck
May 25th, 2009, 09:52 AM
Hi Darius,

I think we are the right track here.

The UUID numbers did not match and I used the (cat /etc/initramfs-tools/conf.d/resume) command to change the numbers and they do now match. This was the initial UUID number:

"RESUME=UUID=8bf41afa-459c-4aa1-bdb8-e583feb8e464" (initial)

I changed it using the (sudo gedit /etc/initramfs-tools/conf.d/resume) command and this is the (sudo blkid) output:

"/dev/sda5: UUID="7023d173-f86d-47b4-b504-0ebc61b0a400" TYPE="ext3""

I restarted but unfortunately the hibernate function still failed. I got the following message "Cannot find swap-on device, try swapon -a".

I ran the "swapon -a" command and got the following reply:

johansteyn@johansteyn-laptop:~$ swapon -a
swapon: cannot stat /dev/disk/by-uuid/8bf41afa-459c-4aa1-bdb8-e583feb8e464: No such file or directory

Still the "old" UUID number.

Your help would be appreciated.

Thanks

JS
Check your /etc/fstab as well, and make sure that you have correct UUID for your swap partition there.

Also, it's quite unlikely that "/dev/sda5: UUID="7023d173-f86d-47b4-b504-0ebc61b0a400" TYPE="ext3"" would refer to your swap partition. That partition is formatted as Ext3, while swap partiton would have type "swap"..

Could you run "sudo fdisk -l" and "blkid" and post the outputs together with your fstab here?

Johan-Steyn
May 25th, 2009, 08:19 PM
Hi mcduck,

Thanks for the reply.

The output from "sudo fdisk -l" is:

Disk /dev/sda: 60.0 GB, 60011642880 bytes
255 heads, 63 sectors/track, 7296 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x310d3c04

Device Boot Start End Blocks Id System
/dev/sda1 * 1 612 4915858+ b W95 FAT32
/dev/sda2 613 7296 53689230 5 Extended
/dev/sda5 613 7017 51448131 83 Linux
/dev/sda6 7018 7296 2241036 b W95 FAT32

The output from "blkid" is:

/dev/sda1: UUID="F761-6785" TYPE="vfat"
/dev/sda5: UUID="7023d173-f86d-47b4-b504-0ebc61b0a400" TYPE="ext3"
/dev/sda6: UUID="820C-E83D" TYPE="vfat"

For what it's worth I have dual boot partition with ******* XP; which I have to maintain to run one unfortunately non-linux compatible client application.

Thanks for your help.

Regards,

JS

Didius Falco
May 25th, 2009, 09:42 PM
Hi mcduck,

Thanks for the reply.

The output from "sudo fdisk -l" is:

Disk /dev/sda: 60.0 GB, 60011642880 bytes
255 heads, 63 sectors/track, 7296 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x310d3c04

Device Boot Start End Blocks Id System
/dev/sda1 * 1 612 4915858+ b W95 FAT32
/dev/sda2 613 7296 53689230 5 Extended
/dev/sda5 613 7017 51448131 83 Linux
/dev/sda6 7018 7296 2241036 b W95 FAT32

The output from "blkid" is:

/dev/sda1: UUID="F761-6785" TYPE="vfat"
/dev/sda5: UUID="7023d173-f86d-47b4-b504-0ebc61b0a400" TYPE="ext3"
/dev/sda6: UUID="820C-E83D" TYPE="vfat"

For what it's worth I have dual boot partition with ******* XP; which I have to maintain to run one unfortunately non-linux compatible client application.

Thanks for your help.

Regards,

JS

You don't have a swap partition.

You have sda1, which is your Windows partition. Your Ubuntu partition is sda5, and then you have a second Fat32 partition - sda6.

Do you have a second Fat32 partition by design, for storage or something?

If that's supposed to be your swap partition, you'll need to format it as a linux/swap partition. After that you'll want to add it to your fstab file in a format similar to this:


UUID=17dc755b-447b-4d6e-ba41-b60ef443d2ae none swap sw 0 0 Do another
sudo blkid, because the UUID number will change.

Then you'll repeat the steps in post #2:

http://ubuntuforums.org/showpost.php?p=7340132&postcount=2

All the above is if if you want a separate swap partition. I don't use Hibernate (I'm on a desktop), so I'm not sure if you can use Hibernation with a swap file or not. I'll go have a look into that now, just because now I want to know. <G>

Okay, I'm back - you can use a swap file for Hibernation, but it needs to be big enough for both swap and Hibernation or Hibernation will fail.

Here is a guide to doing it the swap file way:

http://ubuntuforums.org/showthread.php?t=1042946


Regards,

Didius

bmwerks
May 26th, 2009, 12:46 AM
Hi,

Open a Terminal and type
cat /etc/initramfs-tools/conf.d/resume

then type
sudo blkid

Compare the UUID number generated by the first command to the UUID number of your swap file. If they don't match, type


sudo gedit /etc/initramfs-tools/conf.d/resume and change the UUID number to match the UUID number from the blkid command.

Save the file, and then run
sudo update-initramfs -u

Regards,

Didius
thanks a milli it worked for me. i recently repartitioned so it needed to be updated.

Didius Falco
May 26th, 2009, 12:50 AM
My pleasure!

Regards,

Didius

Johan-Steyn
May 26th, 2009, 08:32 PM
Hi Didius Falco,

Thanks for your response. You were quite correct int that the /dev/sda6 should be swap.

I used "gparted" to format the /dev/sda6 from Fat32 to linux swap.

This is the new output from "sudo fdisk -l"

Disk /dev/sda: 60.0 GB, 60011642880 bytes
255 heads, 63 sectors/track, 7296 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x310d3c04

Device Boot Start End Blocks Id System
/dev/sda1 1 612 4915858+ 7 HPFS/NTFS
/dev/sda2 613 7296 53689230 5 Extended
/dev/sda5 613 7017 51448131 83 Linux
/dev/sda6 7018 7296 2241036 82 Linux swap / Solaris

However "blkid" sill reports /dev/sda6 as:
/dev/sda1: UUID="B864FB2164FAE0D4" TYPE="ntfs"
/dev/sda5: UUID="7023d173-f86d-47b4-b504-0ebc61b0a400" TYPE="ext3"
/dev/sda6: UUID="820C-E83D" TYPE="vfat"

Any ideas why?

I edited the "/etc/fstab" file based on the "blkid" output:

# /etc/fstab: static file system information.
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc defaults 0 0
# /dev/sda5
UUID=7023d173-f86d-47b4-b504-0ebc61b0a400 / ext3 relatime,errors=remount-ro 0 1
/swapfile none swap sw 0 0
# /dev/sda6
UUID=820C-E83D none swap sw 0 0

Also I have ample hard disc space available and would therefor rather use the swap partition than the swap file.

However, still no joy.

Your assistance will be appreciated.

Kind Regards,

JS

unutbu
May 26th, 2009, 08:44 PM
How about try


sudo umount /dev/sda6 # don't worry if Ubuntu says sda6 was not mounted
sudo mkswap /dev/sda6 # This will format sda6 as swap space.
sudo blkid -c /dev/null

blkid usually reads a /etc/blkid.tab. This file
is not updated when you change a partition
with partition editor like GParted.
Running "sudo blkid -c /dev/null" tells Ubuntu not to read
/etc/blkid.tab but to probe partitions directly.

Then repeat Didius Falco's instructions from post #2.

Johan-Steyn
May 27th, 2009, 05:12 AM
Hi Unutbu,

Thanks for your reply.

I ran the commands suggested and got the following output:

Code: "sudo umount /dev/sda6"

umount: /dev/sda6: not mounted

No problems, so far.

Code "sudo mkswap /dev/sda6"

Setting up swapspace version 1, size = 2241032 KiB
no label, UUID=449d7785-d4cf-4eaa-99a3-f3c09f4d7b69

This is the right partition (in terms of size) - but no label? - is that significant?

Code: "sudo blkid -c /dev/null"

/dev/sda1: UUID="B864FB2164FAE0D4" TYPE="ntfs"
/dev/sda5: UUID="7023d173-f86d-47b4-b504-0ebc61b0a400" TYPE="ext3"
/dev/sda6: UUID="820C-E83D" TYPE="vfat"

Blikid is still reporting it as Fat32.

I followed the instructions from Didius Falco in post #2, and the UUID's now match. I have also edited the "etc/fstab" file with output from "blikid":

# /dev/sda5
UUID=7023d173-f86d-47b4-b504-0ebc61b0a400 / ext3 relatime,errors=remount-ro 0 1
/swapfile none swap sw 0 0
# /dev/sda6
UUID=820C-E83D none swap sw 0 0

But, this is the output from "swapon -a"

swapon: cannot stat /swapfile: No such file or directory
swapon: cannot stat /dev/disk/by-uuid/820C-E83D: No such file or directory

Your assistance would be greatly appreciated.

Kind Regards,

JS

drs305
May 27th, 2009, 01:19 PM
I don't see where the error occurred, but the swap should definitely not be vfat and the uuid's don't match. Try running mkswap again, setting the uuid to match in fstab and resume. It doesn't really matter which UUID you use, as long as they match and they aren't used by any other device. Since your "blkid" command gives you the current uuid for /dev/sda6, I'll use it in the following commands to get the UUID to agree in the appropriate files:


sudo umount /dev/sda6
sudo swapoff -a
sudo mkswap -U "820C-E83D" /dev/sda6
echo "RESUME=UUID=820C-E83D" | sudo tee /etc/initramfs-tools/conf.d/resume
sudo swapon -a

cat /etc/initramfs-tools/conf.d/resume


The "echo" command should have updated the RESUME swap id. If the "resume" UUID doesn't match, edit the resume file as previously described to make it 820C-E83D and then update the initramfs.

mcduck
May 27th, 2009, 03:17 PM
Every time you run mkswap, the UUID for that partition will change. Notice how mkswap even reports the new UUID.


sudo mkswap /dev/sda6

Setting up swapspace version 1, size = 2241032 KiB
no label, UUID=449d7785-d4cf-4eaa-99a3-f3c09f4d7b69

So the correct UUID definitely isn't "820C-E83D" any more. I suggest ignoring the blkid output (as it clearly isn't correct), the partition definitely is formatted as swap after running mkswap, so simply use the UUID mkswap gave you in your /etc/fstab.

Johan-Steyn
May 27th, 2009, 03:52 PM
Hi drs305,

Thanks for your reply,

I ran the command as you suggested, but encountered a problem with the mkswap code.

Output as follows:

Code: "sudo umount /dev/sda6"

umount: /dev/sda6: not mounted

Code: "sudo swapoff -a"

''''

Code: "sudo mkswap -U "820C-E83D" /dev/sda6"

mkswap: error: UUID parsing failed

Code: echo "RESUME=UUID=820C-E83D" | sudo tee /etc/initramfs-tools/conf.d/resume

RESUME=UUID=820C-E83D

Code: "Sudo swapon"

Usage:
swapon -a [-e] [-v] enable all swaps from /etc/fstab
swapon [-p priority] [-v] <special> enable given swap
swapon -s display swap usage summary
swapon -h display help
swapon -V display version

The <special> parameter:
{-L label | LABEL=label} LABEL of device to be used
{-U uuid | UUID=uuid} UUID of device to be used
<device> name of device to be used
<file> name of file to be used

So I adjusted the swapon with the parameter -a (enable all swaps).

Code: "Sudo swapon -a"

swapon: cannot stat /swapfile: No such file or directory
swapon: cannot stat /dev/disk/by-uuid/820C-E83D: No such file or directory

No joy.

Code: '"cat /etc/initramfs-tools/conf.d/resume"

RESUME=UUID=820C-E83D

At least that is correct.

I attempted to hibernate the computer afterwards and although it went into initial hibernation mode (black screen, flashing cursor) without error messages, it returned from to the login screen immediately.

We are so close I can almost taste it.

Any further assistance to sort out the "mkswap" error will be appreciated.

Regards,

JS

drs305
May 27th, 2009, 03:58 PM
I omitted the "-a" in "swapon", as you discovered. (corrected). The command needs either a specific device (such as /dev/sda6) or -a (use all available swap devices).

For whatever reason, the mkswap command is not working correctly. The next thing I would try would be to go into gparted, turn off swap, delete the swap partition entirely, create a new one and make sure it's formatted as swap, then run the commands again.

The new swap partition will have a new UUID, so you will have to get them to all agree again.

Continue to use the "-c /dev/null" switch with the blkid command to ensure you are getting the current and correct UUID.

Didius Falco
May 27th, 2009, 04:11 PM
I just ran


sudo rm /dev/.blkid.tab

followed by
sudo blkid

running blkid recreated both the .blkid.tab file and the .blkid.tab.old files.

Then I opened the .blkid.tab file and made up my own UUID number for my Win XP partition and saved it. Running blkid promptly changed it back to the proper UUID number, so my attempt to recreate the situation failed.

I'm wondering if backing up then deleting the .blkid.tab file and running blkid would resolve the problem. Failing that, perhaps putting the correct UUID number into the .blkid.tab file would correct the problem.

Either way, one of the basic commands consistently reporting the wrong information is Unacceptable Behavior, and must be corrected.


Regards,

Didius

Johan-Steyn
May 27th, 2009, 05:26 PM
Hi All,

Finally! I got it working.

Used "gksudo nautilus" searched from "bllkid" (the sudo command gave me problems)

Manually changed filetype "vfat" to "swap.'

Made sure etc/fstab; blkid and /etc/initramfs-tools/conf.d/resume had the same UUID, and Bob's your uncle!

Thanks to mcduck, didius falco, unutbu, drs305 and others for you excellent advice and assistance.

Much appreciated!

Regards,

JS