Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have configured a new Ubuntu 10.10 installation in a Notebook to use a swap file, instead of using a swap partition. For default is not possible to get Ubuntu to hibernate using a swap file, so i used this tutorial to do that, but it does some changes in grub config, it is specific to grub1, and my new Ubuntu uses grub2.

My changed "grub config" is now overwritten, every time after i update. Does anybody know of a better way (more automatic) to do that?

share|improve this question

I've given a quick read to the tutorial and, if I have understood correctly, you just need to specify the resume options to the Linux command line. With Grub2 is really simple, and your changes will be always preserved. You need to edit the /etc/default/grub file, specifically this line:

GRUB_CMDLINE_LINUX="resume=... resume_offset=..."

After that, run sudo update-grub for the changes to take effect.

Changing GRUB_CMDLINE_LINUX won't affect other Linux installations you have (because /etc/grub.d/30_os-prober does not use this variable).

About the problem you're having: is the partition of the swapfile encrypted? If so, hibernation won't work. If not, then the output of filefrag -v /swapfile may be helpful.

share|improve this answer
Thanks! I will try. But I think it config all linux entries in grub with this line. – tfmoraes Oct 13 '10 at 16:26
Don't forget: after changing /etc/default/grub you need to run update-grub. – JanC Oct 13 '10 at 16:44
@tfmoraes: why wouldn't you want this added to all linux entries? – JanC Oct 13 '10 at 16:45
@JanC: Because I may have other Linux distributions installed. – tfmoraes Oct 13 '10 at 17:21
If you look at /etc/grub.d/30_os-prober, you'll see that GRUB_CMDLINE_LINUX is not used, so changing it won't affect other Linux installations. – Andrea Corbellini Oct 13 '10 at 17:43

if I don' t put those lines in /etc/default/grub nothing occurs. But if I put those lines, It crashes on startup by a hibernation with this messages:

resume: libgcrypt version:
Loading image data pages (197173 pages)... 100% done
Wrote 770.2 MB in 12.3 seconds (62.8 MB/s)
read 770.2 MB in 10.3 seconds (75.0 MB/s)
total image i/o 1540.4 MB in 22.5 seconds (68.4 MB/s)
share|improve this answer

Your Answer


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.