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 installed windows7 and ubuntu 11.10 on my asus laptop. I have a large data partition (NTFS) shared by both OS, so I want the laptop wake up to the original OS after hibernate. However, GRUB doesn't seem to have a notion of which OS started hibernate. Is there some way to inform GRUB the OS started hibernate.

Here is my idea (hopefully, someone has better ideas way ahead of me), but don't know where to start:

on ubuntu, before going into hibernation, set GRUB_TIMEOUT=0 and run grub-set-default to ubuntu. This way, next time GRUB has to boot/resume into ubuntu. Upon resume from hibernate or at shutdown, set GRUB_TIMEOUT=10 (or some other non-zero value).

But this only solves half of the problem (if the idea is doable). I still don't know how to set GRUB default before W7 hibernate.

Really love to head suggestions.

share|improve this question
add comment

2 Answers 2

up vote 2 down vote accepted

If you change /etc/default/grub to have the two lines:

GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true

It will always pick the last OS booted, thus bringing up the hibernated OS without your intervention; however, it will also do this even if you didn't hibernate.


(Thanks to @drs305 who wrote the GRUB 2 Basics guide on the Ubuntu Forums.)

share|improve this answer
    
Thanks for the suggestion. It worked as you said. It would largely satisfy my needs, with one minor drawbacks. If I need to change the default boot OS, I better know that it arrived GRUB via shutdown, not hibernate. But that's minor. Thanks a lot!!! –  G. He Mar 14 '12 at 1:59
    
If it answered your question, go ahead and click the green check mark next to it to mark it as The Answer™. Otherwise, could you please clarify your comment—I'm having a bit of time understanding it. Thanks! –  zpletan Mar 14 '12 at 3:30
    
Yes, you answered my question, mostly. I think it would be even more foolproof in GRUB to clearly mark either the computer is coming back from hibernate, or from a fresh start (shutdown/restart). –  G. He Mar 14 '12 at 11:15
add comment

I've run Ubuntu 11.10 and Windows 7 alongside each-other, with a separate NTFS data partition as you describe, for some time now, and my solution has been to just ignore this, and get to the GRUB menu regardless if I shut down or hibernated the last time I left my computer.

The effects of this are the following:

  1. Hibernate from OS (a). The computer will save state to disk and shut down.

  2. Start the computer. It will go to the GRUB menu as usual. Choose which OS to start.

  3. If you start in OS (a), you will resume from hibernation just as expected.

  4. If you start in OS (b), you will start that OS from whatever state you left it last (hibernated/shut down).

  5. If you started in OS (b), then restart the computer and shut down OS (a), it will resume from hibernation just the way it did without starting OS (b) in between.

In short, my machine seems to handle hibernation and shut down of the two operation systems independently, and the only feature I don't have that you talk about, is the lack of choice in which OS to start after hibernation. This makes it possible to, for instance, work on something in Windows, realize you need to do something in Ubuntu so you hibernate, restart in Ubuntu, shut down and resume Windows - something that would not be possible with your desired setup.

I leave no warranties that this is indeed trouble-free, or works on any machine - but so far it's been trouble-free for me, and worked very well on my machine.


Update in response to comment:
If chkdsk starts when you boot into W7 after hibernating and using Ubuntu in between, it might be because Ubuntu mounted the W7 partition automatically. Probably Ubuntu changed something on the disk, which got W7 confused.

Try disabling automatic mount of the W7 partition - either by commenting out the correct line in /etc/fstab or by setting some options in a GUI somewhere (for some reason I can't find the correct settings program...)

share|improve this answer
    
Right after I installed both OSes, it did make some trouble for me. W7 went into ChkDisk a couple times after I booted into it. I was wondering what was going on, then I realized it has to be the hibernate issue. I was so scared that I turned off hibernate. Now with zpletan's suggestion, I can (almost) safely turn hibernate back on. –  G. He Mar 14 '12 at 2:05
    
@G.He: If chkdsk started when booting into W7 after hibernating and running Ubuntu in between, it might have been because you mounted the W7 partition in Ubuntu and that got W7 confused. See my updated post (in a minute or three) for more details. –  Tomas Lycken Mar 14 '12 at 12:35
    
I believe you're right that chkdsk is caused by the grub send the computer to the 'wrong' OS after hibernate. After taking zpletan's suggestion, that situation never happened and I have never seen a chkdsk. Kudos to zpletan. –  G. He Mar 16 '12 at 21:15
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.