Ubuntu – Does 12.04 support hibernating to a swap file

12.04hibernateswap

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.

Best Answer

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.