LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-24-2015, 11:50 AM   #1
Higgsboson
Member
 
Registered: Dec 2014
Location: UK
Distribution: Debian 8 Cinnamon/Xfce/gnome classic Debian live usb
Posts: 508

Rep: Reputation: 50
How to create hibernation function on Debian


I would like to use a hibernate function on my Debian 7.7 OS.
There is a debian tutorial about this - but I'm not an experienced system administrator so it's a bit difficult to understand.https://wiki.debian.org/Hibernation/...Swap_Partition

I have finally decided to create a swap file rather than a swap partition for the sake of simplicity.
I have 2gb RAM and am a normal user - so I think I can set the 'swappiness' to low so that the swap file is used mainly for hibernation.

Can anyone please point me to somewhere where I can install the hibernate function onto a debian/ubuntu distro?
Also, I would've thought that a dpkg could have been written which simplifies this process with the use of a GUI.
In fact, additional functions such as screensaver and wallpaper changer would make the dpkg very useful.

However, any help on creating hibernation on my OS would be really great.
Thank you.
 
Old 01-24-2015, 12:53 PM   #2
joe_2000
Senior Member
 
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Void, Debian
Posts: 1,016

Rep: Reputation: 308Reputation: 308Reputation: 308Reputation: 308
Personally, I 've never used a swap file. Having a swap partition is a pretty standard thing.
Let's first check: Maybe you already have a swap partition!
As root, type
Code:
fdisk -l
and post the output please.
 
Old 01-24-2015, 01:46 PM   #3
Beryllos
Member
 
Registered: Apr 2013
Location: Massachusetts
Distribution: Debian
Posts: 529

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
Another way to check for the existence and location of swap space is:
Code:
cat /proc/swaps
On my system, the result is:
Code:
Filename				Type		Size	Used	Priority
/dev/sda5                               partition	4100092	100576	-1
Next, see if pm-utils is installed. I would do this by logging in as root and using this command line:
Code:
man pm-hibernate
Before you try actually hibernating, save any unsaved work, because sometimes graphic cards don't wake up after suspend or hibernate, you get a black screen, and you may have to reboot. I see that the manual has some information about command line options that may correct graphics wake-up problems, and it may also be important to have the correct drivers installed.

When you are ready to hibernate, the command is simply:
Code:
pm-hibernate
 
Old 01-24-2015, 02:21 PM   #4
Higgsboson
Member
 
Registered: Dec 2014
Location: UK
Distribution: Debian 8 Cinnamon/Xfce/gnome classic Debian live usb
Posts: 508

Original Poster
Rep: Reputation: 50
Quote:
Originally Posted by joe_2000 View Post
Personally, I 've never used a swap file. Having a swap partition is a pretty standard thing.
Let's first check: Maybe you already have a swap partition!
As root, type
fdisk -l
and post the output please.
I used gparted to create all the partitions on my hard disk.
I did not create any swap partitions.

Code:
fdisk -l

Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders, total 312581808 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x9b3c9b3c

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048    81922047    40960000   83  Linux
/dev/sda2        81922048   163842047    40960000   83  Linux
/dev/sda3       163842048   245762047    40960000   83  Linux
/dev/sda4       245762048   312580095    33409024    5  Extended
/dev/sda5       245764096   307204095    30720000   83  Linux

Disk /dev/sdb: 1000.2 GB, 1000200658432 bytes
255 heads, 63 sectors/track, 121600 cylinders, total 1953516911 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x116e116d

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *          63   512002047   256000992+   7  HPFS/NTFS/exFAT
/dev/sdb2       512002048   593922047    40960000   83  Linux
 
Old 01-24-2015, 02:27 PM   #5
Higgsboson
Member
 
Registered: Dec 2014
Location: UK
Distribution: Debian 8 Cinnamon/Xfce/gnome classic Debian live usb
Posts: 508

Original Poster
Rep: Reputation: 50
Quote:
Originally Posted by Beryllos View Post
Another way to check for the existence and location of swap space is:
cat /proc/swaps
Quote:
pm-hibernate
Neither of these commands produce an output.
I don't have a swap file yet and I haven't configured the OS to respond to a hibernate command.

I was wondering what size swap space was needed and how to create the hibernate function.
 
Old 01-24-2015, 02:50 PM   #6
joe_2000
Senior Member
 
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Void, Debian
Posts: 1,016

Rep: Reputation: 308Reputation: 308Reputation: 308Reputation: 308
Quote:
Originally Posted by Higgsboson View Post
Neither of these commands produce an output.
I don't have a swap file yet and I haven't configured the OS to respond to a hibernate command.

I was wondering what size swap space was needed and how to create the hibernate function.
Ok, if you feel comfortable using gparted you should create a swap partition. Resize one of the existing partitions first. For hibernate to work, swap needs to be larger than your RAM. Maybe 1,5 times your RAM or so.
Reduce the size of one of your other partitions by the needed amount of space and then create the swap partition. Gparted will offer an option to format it as swap.
Note that you will have to unmount the disk to be able to modify the partition table, so ideally do it from within a live system.

One thing to be careful with: When you reduce the size of an existing partition, move the partition's end, not the beginning! Otherwise you will be moving the partition, which takes a long time.
In any event, do not interrupt this process. Make sure your computer is connected to power rather than running it on batteries.
Backup your data before starting the process!

Once that's done, you'll need to configure the swap partition in your /etc/fstab.

Mine looks like this:
Code:
# swap was on /dev/sda4 during installation
UUID=1766664c-5439-40fb-89b6-aa32c2a28d4b none    swap    sw  0   0
You'll need to replace the UUID with yours, which you can find out by typing
Code:
blkid
As root. (or prepended by sudo)

Reboot and check if the swap is active by
Code:
free
When all that's done, post back to get instructions for the next step. (Setting up hibernate)
 
1 members found this post helpful.
Old 01-24-2015, 04:40 PM   #7
Higgsboson
Member
 
Registered: Dec 2014
Location: UK
Distribution: Debian 8 Cinnamon/Xfce/gnome classic Debian live usb
Posts: 508

Original Poster
Rep: Reputation: 50
Quote:
Originally Posted by joe_2000 View Post
Ok, if you feel comfortable using gparted you should create a swap partition. Resize one of the existing partitions first. For hibernate to work, swap needs to be larger than your RAM. Maybe 1,5 times your RAM or so.
Reduce the size of one of your other partitions by the needed amount of space and then create the swap partition. Gparted will offer an option to format it as swap.
Note that you will have to unmount the disk to be able to modify the partition table, so ideally do it from within a live system.
Thank you for your excellent instructions.
I was seeking to create a swap file but decided to create a swap partition as you've mentioned.
I used gparted and reduced the logical partition sda5 to 4gb and formatted it to 'linux-swap'.

Quote:
Once that's done, you'll need to configure the swap partition in your /etc/fstab.
Mine looks like this:
# swap was on /dev/sda4 during installation
UUID=1766664c-5439-40fb-89b6-aa32c2a28d4b none swap sw 0 0
You'll need to replace the UUID with yours, which you can find out by typing
blkid
As root. (or prepended by sudo)
I have a debian OS on sda1 and sda2.
So does this mean I need to boot one of these OSs and add the UUID of the swap partition in /etc/fstab?
Or is it possible to put the UUID of the swap partition in the /etc/fstab file of both OSs? That way, the swap partition can be used by whichever OS is booted.
Would that be possible, or must the swap partition be dedicated to a specific OS?
 
Old 01-24-2015, 05:33 PM   #8
joe_2000
Senior Member
 
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Void, Debian
Posts: 1,016

Rep: Reputation: 308Reputation: 308Reputation: 308Reputation: 308
Quote:
Originally Posted by Higgsboson View Post
Thank you for your excellent instructions.
I was seeking to create a swap file but decided to create a swap partition as you've mentioned.
I used gparted and reduced the logical partition sda5 to 4gb and formatted it to 'linux-swap'.



I have a debian OS on sda1 and sda2.
So does this mean I need to boot one of these OSs and add the UUID of the swap partition in /etc/fstab?
Or is it possible to put the UUID of the swap partition in the /etc/fstab file of both OSs? That way, the swap partition can be used by whichever OS is booted.
Would that be possible, or must the swap partition be dedicated to a specific OS?
You can use the swap partition from both systems. That's even the recommended way. Let us know if it works.
 
Old 01-24-2015, 06:48 PM   #9
Beryllos
Member
 
Registered: Apr 2013
Location: Massachusetts
Distribution: Debian
Posts: 529

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
Quote:
Originally Posted by Higgsboson View Post
... So does this mean I need to boot one of these OSs and add the UUID of the swap partition in /etc/fstab?
Or is it possible to put the UUID of the swap partition in the /etc/fstab file of both OSs? That way, the swap partition can be used by whichever OS is booted.
Would that be possible, or must the swap partition be dedicated to a specific OS?
If you use a swap partition just for swap (virtual memory), that is fine.

If you use it for hibernation, there is a problem. When you boot either OS, it will overwrite the hibernation data from the other OS.

Edit: removed incorrect reference to another thread.


Another Edit: I can't find a recent thread on this topic (Linux+Linux dual-boot with hibernation). I might just try it myself to see what happens.

Last edited by Beryllos; 01-24-2015 at 07:07 PM.
 
Old 01-25-2015, 04:21 AM   #10
joe_2000
Senior Member
 
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Void, Debian
Posts: 1,016

Rep: Reputation: 308Reputation: 308Reputation: 308Reputation: 308
Quote:
Originally Posted by Beryllos View Post
Another Edit: I can't find a recent thread on this topic (Linux+Linux dual-boot with hibernation). I might just try it myself to see what happens.
What you say makes a lot of sense though. I can't imagine how that would work...
To the very least you'd lose the first hibernate state.
On the other hand: Can you actually boot another operating system while the first one is in hibernate mode? Not sure...
 
Old 01-25-2015, 05:20 AM   #11
Higgsboson
Member
 
Registered: Dec 2014
Location: UK
Distribution: Debian 8 Cinnamon/Xfce/gnome classic Debian live usb
Posts: 508

Original Poster
Rep: Reputation: 50
Quote:
Originally Posted by Beryllos View Post
If you use it for hibernation, there is a problem. When you boot either OS, it will overwrite the hibernation data from the other OS.
That's ok, I don't mind that.
I just want the hibernate function to shut down everything and wake up when I wake up!
After that, the saved hibernate data won't be needed anymore.
 
Old 01-25-2015, 06:06 AM   #12
Higgsboson
Member
 
Registered: Dec 2014
Location: UK
Distribution: Debian 8 Cinnamon/Xfce/gnome classic Debian live usb
Posts: 508

Original Poster
Rep: Reputation: 50
Quote:
Originally Posted by joe_2000 View Post
Reboot and check if the swap is active by
free
When all that's done, post back to get instructions for the next step. (Setting up hibernate)
I have now done this. I've created the swap partition and put its swap UUID in /etc/fstab for sda1 and sda2.
Code:
sda2:
/# free
             total       used       free     shared    buffers     cached
Mem:       1798336     555056    1243280          0      29844     238384
-/+ buffers/cache:     286828    1511508
Swap:      4198396          0    4198396
sda1:
# free
             total       used       free     shared    buffers     cached
Mem:       1798308     497796    1300512          0      29144     226568
-/+ buffers/cache:     242084    1556224
Swap:      4198396          0    4198396
 
Old 01-25-2015, 06:13 AM   #13
joe_2000
Senior Member
 
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Void, Debian
Posts: 1,016

Rep: Reputation: 308Reputation: 308Reputation: 308Reputation: 308
Ok, great, so you have swap now.
To suspend, in a root terminal type
Code:
pm-suspend
To hibernate, use
Code:
pm-hibernate
If these commands are not known you probably need to install the package pm-utils (although I would expect it to come preinstalled on debian).

Map these commands to keyboard shortcuts if you like. Not sure how to do that in gnome, but it's probably somewhere in system settings -> keyboard...

You'll probably have to use a sudo rule to allow regular users to run them without password, open a new thread if you need help with that...
 
Old 01-25-2015, 07:12 AM   #14
Beryllos
Member
 
Registered: Apr 2013
Location: Massachusetts
Distribution: Debian
Posts: 529

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
Quote:
Originally Posted by joe_2000 View Post
What you say makes a lot of sense though. I can't imagine how that would work...
To the very least you'd lose the first hibernate state.
On the other hand: Can you actually boot another operating system while the first one is in hibernate mode? Not sure...
Here is a related thread:
LinuxQuestions - Hibernation and Linux-Linux Dual-boot
He can boot either one. The problem is that he loses the hibernated state if he boots the second OS, even though the second OS in his system doesn't use the swap partition; only the first OS is configured to use swap and to hibernate.
 
Old 01-25-2015, 08:10 AM   #15
Higgsboson
Member
 
Registered: Dec 2014
Location: UK
Distribution: Debian 8 Cinnamon/Xfce/gnome classic Debian live usb
Posts: 508

Original Poster
Rep: Reputation: 50
Quote:
Originally Posted by joe_2000 View Post
Ok, great, so you have swap now.
To suspend, in a root terminal type
pm-suspend
To hibernate, use
pm-hibernate
If these commands are not known you probably need to install the package pm-utils (although I would expect it to come preinstalled on debian).
On sda1, I used pm-suspend and the OS closed down. When I press any key on the keyboard it opens up again. This is what I was looking for.
On the desktop, when I press 'shut down' I have the added options for 'suspend' and hibernate'. Suspend works correctly.
But when I press hibernate, the OS appears to shutdown and I just get a blank screen. The OS won't re-open if I press any keys. I have to then manually boot the computer.
Is this normal because I don't understand how this function is different to 'shut down'?

On sda2, when I select suspend from the desktop, it closes down correctly. But when I press any key, there is still only a blank screen.
I then have to do a cold boot to boot up the computer.

Incidentally, what is the difference between 'suspend' and 'hibernate'?

Quote:
You'll probably have to use a sudo rule to allow regular users to run them without password, open a new thread if you need help with that...
Thankfully, the OS allows me to use suspend and hibernate as user.
Even so, these functions don't seem to be working properly for both OSs.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Unable to create a function in BASH rohit.dhaval1 Linux - Newbie 2 11-26-2013 07:14 AM
c++: create a function within a function? stateless Programming 3 01-30-2013 08:39 PM
how to create sudo right-click function? kiasta Ubuntu 4 04-07-2007 09:23 AM
Occasional hibernation on Debian 3.1rev1 Adan Linux - General 1 01-30-2006 05:09 AM
Can't turn off hibernation on Debian 3.1rev1 Adan Linux - Hardware 0 01-14-2006 06:05 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:03 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration