Hibernating your machine is of paramount importance, especially if you own a laptop. It is not just a convenience; it is a necessity should you have to move in a hurry and don't have time to save everything and perform a proper shutdown. Albeit, Mandriva has not supplied a working configuration for the hibernation function out of the box, therefore we are going to fix it. The steps below worked for my Mandriva Linux 2008 x86-64 and x86 installations and will most probably work for other post-2007 distributions, even Mandriva Linux 2007 Spring, but - as always - there are no guaranties. At worst your box will not hibernate and you might end up with a corrupt swap space (which can be mended very easily anyway).
The configuration file for the hibernation (suspend-to-disk) function is located in /etc/suspend.conf
. You will have to edit it as root. If you're using KDE, you can simply press Alt-F2 to get the Run Command popup dialog, type in the box the following command:
kdesu kwrite /etc/suspend.conf
press the Run button and supply your root password.
Now, edit your configuration file to read something like this:
snapshot device = /dev/snapshot resume device = /dev/hdz1 compress = y splash = y #image size = 350000000 #suspend loglevel = 4 #compute checksum = y #encrypt = y #early writeout = y
You don't have to use the lines starting with the hash sign (#), they are optional and already commented-out. Very important: replace /dev/hdz1
with your swap partition. If you are unsure what it is, here is a way to find out:
- Open Mandriva Control Center (the Configure Your Computer button beside the desktop pager on the Kicker).
- Go to "Local Disks" tab and select "Manage disk partitions".
- You will see that there is a green slice on the chart; click it.
- At the bottom right pane you will see that the mount point is swap and below that there is the device name. This is what you're looking for.
Now, we are halfway there. We need to make sure that the kernel will be using this partition as the restore partition.
- Open Mandriva Control Center (the Configure Your Computer button beside the desktop pager on the Kicker).
- Go to the "Boot" tab and select "Set up boot system".
- Press "Next".
- Make sure you have selected the entry you regularly use; if unsure, select "linux".
- Click on the Modify button.
- You will see on the Append text box some kernel options. Make sure it contains
resume=/dev/hdz1
, substituting/dev/hdz1
with your swap partition. - Save everything.
- If you had to edit the kernel options, reboot now.
Before trying to hibernate, make sure that your free swap space is at least as much as the total amount of your system's RAM. A good rule of thumb is to make your swap partition twice as big as the total amount of installed RAM. If you need more space you can either try resizing the swap partition, or create a new swap partition (e.g. with Mandriva Control Center) which is at least as big as your RAM and set this to be your suspend/resume partition as illustrated above.
If you followed all the steps this far, you should be able to suspend your Linux box to disk. Go ahead and test it.
If you'd like to suspend to RAM as well, things get tougher. You'll have to remove the vga=zzz
(where zzz is a number) from the kernel options, to force Linux not to use the graphical console, as this usually interferes with the system's ability to suspend or resume properly. However, you will lose the beautiful splash screen when booting up or suspending. You might also have to add the acpi_sleep=s3bios
kernel option if the system hangs while suspending. Suspending to RAM is still a bit like black arts for a good reason: when you are resuming from suspend-to-RAM the hardware is not fully re-initialized, which can lead to problems. Each vendor has an opinion of their own about what should be initialized and how this happens upon resume, so your mileage will vary. I have yet to achieve proper s2ram for my laptop, but I don't really care.
Another "bug" I ran across, is that the system swaps out like crazy right after resuming. I mean, it swaps out about 250Mb! This - of course - causes a monstrous amount of (blocking) disk activity upon resume, rendering the system unusable for 1-2 minutes. I have yet to identify the root of this problem, so I am just being patient with this.
Last, but not least, if suspend fails, try disabling services you might not need. Usually, running MySQL while hibernating is like asking for trouble. Same goes with some virtualization software (QEmu, VMware and so on), even when just their kernel module is loaded. Once again, disable everything not strictly necessary and try to hibernate; if it works, start adding stuff until you find what makes the process fail.
Edit, August 2008: Mandriva Linux 2008 Spring Edition (a.k.a. Mandriva Linux 2008.1) hibernates almost out-of-the-box. On my desktop it works flawlessly. However, there are a few problems resuming when you use the proprietary nVidia (nvidia) and ATI/AMD (fglrx) graphics drivers, so your mileage may vary. It is rumoured that Mandriva Linux 2009 will have these problems fixed. I'll wait and see :)