Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm about to reinstall Ubuntu on a netbook with a tiny disk. Because of the tiny disk size, I'd strongly prefer to have a swap file than a swap partition. However, I want to be able to hibernate.

I know that hibernation needs to be manually enabled. I also know that hibernation to a swap file works on the old Eeebuntu that I'll be replacing, so hardware support is not a concern.

Does the precise kernel support hibernation to a swap file? What if anything do I need to configure?

Please note that I'm looking for reliable, up-to-date information. I don't mind if hibernation isn't supported out-of-the-box, but I'd prefer not to have to recompile a kernel if I can do without. I'll balk at patching the kernel for that machine.

share|improve this question
    
Not enough for an answer, but I see some swap file info here: help.ubuntu.com/community/SwapFaq –  Jorge Castro Aug 12 '12 at 20:01
    
@JorgeCastro No offense, but I don't trust this FAQ much. Has it been kept up-to-date? On the topic of hibernation, I've had plenty of bad experiences with outdated resources on the web. –  Gilles Aug 12 '12 at 20:08
    
I don't trust it either after reading the first few bullets which is why I left it as a comment, seems to be kept up to date though. I'm not finding much information on the web about this though. –  Jorge Castro Aug 12 '12 at 20:21
add comment

3 Answers

As far as I know the file /etc/initramfs-tools/conf.d/resume has the parameter from where to fetch the hibernation data and it was originally a device, but in (many) recent versions uses UUID. It defaults to the swap partition you installed and I know this because if you by some chance change your swap partition or UUID you need to update it there and run sudo update-initramfs -u for hibernation to work again. This is true for at least Quantal, Precise and Lucid so I guess its true for current supported versions too.

The swap partition must be at least as large as your total memory. Be aware that hibernating to swap can be a (physical) security risk if you don't use full disk encryption (LUKS via the alternative install cd). It's possible to use the data on the swap to find the vectors to decrypt your gnome keyring passwords.

share|improve this answer
    
this definitely should be in the faq. moved swap to another drive and wasn't able to make hibernate to work. found this info by sheer luck. –  Art Shayderov Oct 5 '12 at 8:19
add comment

I did not try to use it, but I found the following HOWTO:

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

This seems to explain quite nicely how to create the swap file and prepare it to use with hibernation. Hope that helps.

share|improve this answer
    
Welcome to Ask Ubuntu! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. –  hexafraction Aug 17 '12 at 13:38
    
Last tested on lucid. Sorry, but I'm looking for up-to-date information. This has the nasty habit of changing, not always for the better. –  Gilles Aug 17 '12 at 13:49
add comment

It's not recommended. From the Community documentation at: https://help.ubuntu.com/community/SwapFaq/

"The advantages of a swap file are many, but it is problematic for using the default "swsusp" hibernation method for powerless sleep."

Now "problematic" does not mean impossible but in the context of your original question I'd have to say that no, it is not supported, and is not available out of the box.

share|improve this answer
    
What version of Ubuntu was this FAQ entry written for? (See the comments under the question.) I'm looking for reliable information, and I don't mind having to configure a few things. I'd prefer not to recompile a kernel, but I'll do it if that's what it takes. –  Gilles Aug 18 '12 at 22:16
    
It's not an archived page, and is probably more current than a lot of the information in the community FAQs. I've never seen anything that says that the kernel has be designed to specifically use a swap file for hibernation, and in fact it is normally suggested to avoid it. You might just have to try it. - If you keep a copy of any config files that you changed I don't think there would be anything that would be too difficult to reverse if you find that it doesn't work easily for you. –  fabricator4 Aug 25 '12 at 22:58
    
Yeah, I'm going to try and see. Any day now, as soon as I find the time... It'll be a fresh installation, so if it fails I can restart the install anyway. When I've done it I'll report here. –  Gilles Aug 25 '12 at 23:02
    
Also, is there any real difference between using a swap partition and a swap file on a small hard drive? I have a EeePC with an 8Gb hard drive and 1Gb of RAM. I've found the best way of using this machine is with a 7Gb / and a 1Gb swap partition. I inserted an 8Gb SD card in the slot and set it to mount as /home in fstab and haven't looked back. A 7GB / is plenty for what this machine gets used for and even have a considerable number of programs install - photo editing, games, and the full suite that comes with Ubuntu. I just delete old kernels occassionaly. –  fabricator4 Aug 25 '12 at 23:02
    
I have more software and more data than the average user... Fitting within 16GB is a challenge, and being able to temporarily remove the swap file comes in useful once in a while. –  Gilles Aug 25 '12 at 23:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.