Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Debian 8 Cinnamon/Xfce/gnome classic Debian live usb
Posts: 508
Rep:
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.
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
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:
Distribution: Debian 8 Cinnamon/Xfce/gnome classic Debian live usb
Posts: 508
Original Poster
Rep:
Quote:
Originally Posted by joe_2000
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
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)
Distribution: Debian 8 Cinnamon/Xfce/gnome classic Debian live usb
Posts: 508
Original Poster
Rep:
Quote:
Originally Posted by joe_2000
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?
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.
... 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.
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...
Distribution: Debian 8 Cinnamon/Xfce/gnome classic Debian live usb
Posts: 508
Original Poster
Rep:
Quote:
Originally Posted by Beryllos
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.
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...
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.
Distribution: Debian 8 Cinnamon/Xfce/gnome classic Debian live usb
Posts: 508
Original Poster
Rep:
Quote:
Originally Posted by joe_2000
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.