I’ve finally terminated my upgrade to Xubuntu 11.10, with the usual small problems, nothing really too bad.
But now, when i boot I don’t see anymore the “Windows” entry in the boot menu made with grub2, I’ve installed os-prober that should help in will find additional entries on the hard disks and add them to the menu, but this don’t solved too my problem.
As alternative you could have your windows Entry in place, but when selecting it, you get an error like:
- you need to load kernel first
- chainloader: no such command.
- no such partition
Grub2 super short howto
This part comes from the complete tutorial about grub2 from the site Dedoimedo, while i was searching for an help i’ve read his complete how to about grub2 and i really suggest to take the time to read it for a complete overview.
GRUB 2 has three main parts:
- /etc/default/grub – the file containing GRUB 2 menu settings.
- /etc/grub.d/ – the directory containing GRUB 2 menu creating scripts.
- /boot/grub/grub.cfg – the GRUB 2 configuration file, not editable.
update-grub command reads the /etc/grub.d directory and looks for executable scripts inside it. The scripts are read, in the order of their numbering, and written into the grub.cfg file, along with the menu settings read from the /etc/default/grub file.
Boot entries come from several sources – the default that comes with the distribution, other operating systems probed on the connected disks and custom scripts written by the user, following a strict syntax. The scripts are written as shell (sh).
Step 1, know your hard disk
The first thing that you need to know it’s the exact mapping of your hard-disk, for this we’ll use the old but always good fdisk with the option -l, this is my Xubuntu machine harddisk
linuxaria@xubuntu-home:~$ sudo fdisk -l [sudo] password for linuxaria: Disk /dev/sda: 40.0 GB, 40007761920 bytes 255 heads, 63 sectors/track, 4864 cylinders, total 78140160 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xcccdcccd Device Boot Start End Blocks Id System /dev/sda1 * 63 36817199 18408568+ 7 HPFS/NTFS/exFAT /dev/sda2 36817200 42698879 2940840 c W95 FAT32 (LBA) /dev/sda3 42700798 78139391 17719297 5 Extended /dev/sda5 42700800 43698175 498688 82 Linux swap / Solaris /dev/sda6 43700224 59322367 7811072 83 Linux /dev/sda7 59324416 78139391 9407488 83 Linux |
So, in short :
/dev/sda1 = Windows
/dev/sda2 = extra partition formatted with fat32
/dev/sda5 = Linux swap
/dev/sda6 = / partition of Xubuntu
/dev/sda7 = /home partition of Xubuntu
My windows partition is /dev/sda1 that on Grub2 is mapped as (hd0.1), note that this is different from grub (not 2) where the first partition of the first disk was (hd0,0)
Step 2 create a custom Grub 2 script
Create the file /etc/grub.d/15_Windows, and add the following lines to it:
#! /bin/sh -e echo "Adding Windows" >&2 cat < < EOF menuentry "Windows" { set root=(hd0,1) chainloader +1 } EOF |
And now make this script executable with the command:
chmod +x /etc/grub.d/15_Windows |
Step 3 update grub 2 configuration file
Now, we must tell to grub 2 to recreate his config file, to do it execute, as root, the command update-grub2
root@xubuntu-home:/etc/grub.d# update-grub Generating grub.cfg ... Found linux image: /boot/vmlinuz-3.0.0-12-generic Found initrd image: /boot/initrd.img-3.0.0-12-generic Adding Windows Found memtest86+ image: /boot/memtest86+.bin done |
Now your custom script is included in the file /boot/grub/grub.cfg
You just have to reboot and enjoy (?) your Windows partition.
Popular Posts:
- Copy – A new cloud storage service with Linux Client
- Linux Games: Haunt
- Share your files easily on your computers with NitroShare
- Linuxaria, now running on Wheezy
- BitMessage: Encrypted messaging, BitCoin-style
Find me on Google+

nice; I’ve been adding it manually every update …
why not just run update-grub?
Done it, it doesn’t see my windows partition, otherwise it would be much easier
root@xubuntu-home:/etc/grub.d# ls00_header 05_debian_theme 10_linux 15_windows 20_linux_xen 20_memtest86+ 30_os-prober 40_custom 41_custom README
r
oot@xubuntu-home:/etc/grub.d# mv 15_windows /tmp/
root@xubuntu-home:/etc/grub.d# update-grub
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.0.0-12-generic
Found initrd image: /boot/initrd.img-3.0.0-12-generic
Found memtest86+ image: /boot/memtest86+.bin
done
No windows entry with a simple update-grub.
There is something wrong in my Xubuntu 11.10 ?
It’s a fresh install with all the defaults.. so it took less time to add the windows entry manually than finding than problem.
Quicker way:
Boot the Live disc
Mount the Ubuntu partition: sudo mount /dev/sdaX /mnt
Run grub-install: sudo grub-install –root -directory=/mnt/ /dev/sda
Reboot, then run sudo update-grub
This gives you a newly installed grub2, which recognizes Windows
Thanks for the feedback Emery,
i tried that but it didn’t work, check my answer to the other comment.
Best Regards
I have always this f*#§ing error…
Generating grub.cfg …
Found linux image: /boot/vmlinuz-3.0.0-12-generic
Found initrd image: /boot/initrd.img-3.0.0-12-generic
Found memtest86+ image: /boot/memtest86+.bin
errore: syntax error.
errore: Incorrect command.
errore: syntax error.
error: line no: 98
Syntax errors are detected in generated GRUB config file.
Ensure that there are no errors in /etc/default/grub
and /etc/grub.d/* files or please file a bug report with
/boot/grub/grub.cfg.new file attached.
What is, by the way?
Hello,
Have you add something on grub.cfg on the directoy /etc/grub.d/ ?
It seem to be a syntax error somewhere.