Debian grub2 update removed Windows boot option

427

Solution 1

This is based on for Ubuntu but it should be valid for Debian's grub2-package too:

/boot/grub/grub.cfg is overwritten each time you run /usr/sbin/update-grub2 or when it's called after a kernel update. grub2 should have auto-detected the windows installation via /etc/grub.d/30_os-prober and added it to the boot menu. Howewer custom entries should be made in /etc/grub.d/40_custom

Update:

You could try to add the Windows Loader manually by adding the following to /etc/grub.d/40_custom:

menuentry "Windows on /dev/hda1" {
insmod ntfs
set root='(hd0,1)'
search --no-floppy --fs-uuid --set YOURUUID
chainloader +1
}

"YOURUUID" is the UUID of your Windows partition. You can get it by doing a ls -l /dev/disk/by-uuid/ | grep hda1. After editing the file do a "sudo update-grub2" to generate a new grub.cfg.

It depends on os-prober, which may not be installed, in which case do a:

sudo apt-get install os-prober

... and run sudo update-grub2 again.

Solution 2

Wrikken's solution also worked for me. I'm regurgitating it in easy to follow directions.

Step 1

sudo apt-get install os-prober

This can be tested with:

sudo os-prober

Which, for me, gives the output:

/dev/sda1:Microsoft Windows XP Professional:Windows:chain

Step 2

sudo update-grub2
Share:
427
HTCone
Author by

HTCone

Updated on September 17, 2022

Comments

  • HTCone
    HTCone over 1 year

    These three functions are apart of my study guide and would greatly appreciate some assistance. In each case, the function returns a value (so use the return statement): it does not print the value (no print statement) or mutate (change the value of) any of its arguments.

    1) The repl function takes three arguments: ◦old is any value; ◦new is any value; ◦xs is a list.

     Example:
     >>> repl('zebra', 'donkey', ['mule', 'horse', 'zebra', 'sheep', 'zebra'])
     ['mule', 'horse', 'donkey', 'sheep', 'donkey']
    

    It returns a new list formed by replacing every occurrence of old in xs with new.

    It must not mutate the list xs; i.e., after return from the function, the actual argument given for xs must be what it was before.

     >>> friends = ['jules', 'james', 'janet', 'jerry']
     >>> repl('james', 'henry', friends)
     ['jules', 'henry', 'janet', 'jerry']
     >>> friends
     ['jules', 'james', 'janet', 'jerry']
    

    2) The search function looks for a value in a list. It takes two arguments: ◦y is the value being searched for. ◦xs is the list being searched in.

    It returns the index of the first occurrence of y in xs, if it occurs; −1 otherwise.

     Examples:
     >>> words = ['four', 'very', 'black', 'sheep']
     >>> search('four', words)
     0
     >>> search('sheep', words)
     3
     >>> search('horse', words)
     -1
    

    3) The doubles function is given a list of numbers and returns a new list containing the doubles of every number in the given list.

     Example:
     >>> doubles([1, 3, 7, 10])
     [2, 6, 14, 20]
    

    It must not mutate the given list:

     >>> salaries = [5000, 7500, 15000]
     >>> doubles(salaries)
     [10000, 15000, 30000]
     >>> salaries
     [5000, 7500, 15000]
    

    This is to be done without using any list methods except append. (In particular, you may not use the index or count for the search function.)

    Although you can use the list len function, and the list operations +, *, indexing, slicing, and == for comparing lists or elements. You will need to use some of these but not all.

    Any help is greatly appreciated like I mentioned in the introduction.

    So far all I have is.

     def repl (find, replacement, s):
         newString = ''
         for c in s:
             if c != find:
                 newString = newString + c
             else:
                 newString = newString + replacement
         return newString
    
     def search(y, xs):
          n = len(xs)
          for i in range(n):
              if xs[i] == y:
                  return i
          return -1
    

    and....

     def search(key,my_list):
       if key in my_list:
         return my_list.index(key)
       else:
         return 
    

    I'm not sure what needs to be returned after the else statement.

    • HTCone
      HTCone over 10 years
      I am not getting the right answers as shown in the examples. Also the code for the last two problems I still have yet to compile. I'm trying to refresh my memory with this and have had some trouble remembering the correct solutions.
    • Paco
      Paco over 10 years
      Can you edit your post with the details you've added here? You'll have a better chance to find the right answer
  • Wrikken
    Wrikken over 13 years
    update-grub2 indeed creates a new configutaion file, /etc/grub.d/30_os-orober is there, but elas, no Windows entry as of yet, so it seems it cannot detect it for some reason. Could it be a hd is blacklisted somewhere? (/grasping at straws).
  • Stefan
    Stefan over 13 years
    I don't know if there cold be a blacklisted hd. I'm still not really experienced with grub2. What output do you get from "sudo os-prober"?
  • Wrikken
    Wrikken over 13 years
    Aha, that was it, although I had a /etc/grub.d/30_os-prober, it depended on the (quite obviously named) os-prober executable which wasn't on the system (and for some reason grub fails to provide even a simple error report about that). A simple install of that package and rerunning update-grub2 did the trick, it's in grub.cfg now, my thanks!
  • Wrikken
    Wrikken over 13 years
    Ack., see my comment @ the 28th of september, this was indeed what solved it.
  • John
    John over 13 years
    Maybe you can copy and paste my answer as your own (and then I can remove mine)? I believe it is better if the solution is part of the answer instead of in the comments.