Sie sind auf Seite 1von 3

Adding A Windows Entry to GRUB Menu For Noobs

By Mark A

It is common for new, and even for older Linux users, to be dual booting between 
Linux and Windows on a machine. If after installing your favorite Linux distro 
you seem to be missing a Windows entry from your GRUB menu, this is what you 
will read about below.

If Separate Disks For Linux And Windows
Step 1) Find out which windows partition has the files boot.ini and ntldr. (This 
is important since you don't want to end up like me before, who took about an 
hour to finally figure it out.)

So if you only have one windows partition, then it defaults to that partition. 
However, if you have more than one, then it can be sometimes confusing. Locating 
the said files is a quick way to tell you that that partition is the correct 
one.  When does this happen?

Scenario.  I have 2 windows (NTFS) partitions. My installation is odd in that my system 
files   and   everything   else   are   on   drive   D.   This   setup   sometimes   happen.   Windows   will 
normally write its own bootloader on the MBR, which is the first few sectors of the disk 
it is installed on. Naturally, that would be on C. It would also default into writing 
the   said   2   files   to   that   drive   too,   along   with   the   system   files,   program   files, 
documents and settings and all that.  Why mine got to D I don't know.  Normally we would 
think that the bootable partition is D, since it has the system files. Well not all the 
time.  That is where I failed before.

Since you are doing this all on Linux, some few commands to help you find out 
about the partitions are `cat /proc/partitions` and mount. Run konsole and type 
`cat /proc/partitions` and you should get something like this,
$ cat /proc/partitions
major minor  #blocks  name

8 0 156290904 sda
8 1 53881978 sda1
8 2 1 sda2
8 5 102398278 sda5
8 16 39082680 sdb
8 17 12691318 sdb1
8 18 1 sdb2
8 19 26137755 sdb3
8 21 248976 sdb5

In my case my Windows partitions are on the drive sda, particulary sda1 and
sda5. How do I know it? The mount command helps me identify it too. On konsole
again, type mount and you should have something like this,

$ mount
/dev/sdb1 on / type ext4 (rw,relatime,errors=remount­ro)
tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
varrun on /var/run type tmpfs (rw,nosuid,mode=0755)
varlock on /var/lock type tmpfs (rw,noexec,nosuid,nodev,mode=1777)
udev on /dev type tmpfs (rw,mode=0755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)
fusectl on /sys/fs/fuse/connections type fusectl (rw)
lrm on /lib/modules/2.6.28­16­generic/volatile type tmpfs (rw,mode=755)
/dev/sdb3 on /home type ext4 (rw,relatime)
securityfs on /sys/kernel/security type securityfs (rw)
/dev/sda1 on /media/disk type fuseblk (rw,nosuid,nodev,allow_other,blksize=4096)
/dev/sda5 on /media/disk­1 type fuseblk (rw,nosuid,nodev,allow_other,blksize=4096)

Notice the lines in red? It tells me that my sdb partitions are Linux partitions 
since they are mounted on / and /home. The green lines, on the other hand, says 
that my Windows partitions are on sda. Don't bother about the other lines, they 
are just filesystems needed by Linux to run properly.

Do   note   however   that   the   green   lines   will   not   show   unless   you've   explicitly  
mounted   those   partitions.   Now   don't   worry,   we   won't   go   into   more   confusing  
console commands. Just fire up Dolphin, find the partition(s) marked as NTFS on  
the left pane and click. That should get them mounted automatically.

Once   you've   correctly   identified   the   correct   disk/partition,   we're   ready   to 
proceed to the next step.

Step  2)  Adding  the entry to  your  GRUB menu. Run  kate,  then  open  this  file ­ 
/boot/grub/menu.lst ­ as root. To do this, type `sudo kate /boot/grub/menu.lst` 
on konsole yet again. Don't forget to provide your password once it asks for it. 
Then scroll down to the end of the file, the menu entries are usually located 
there.   Or   just   add   the   following   lines   to   where   the   other   menu   entries   are 
positioned in the file.
title Windows XP
rootnoverify (hd1,0)
map (hd0) (hd1)
map (hd1) (hd0)
makeactive
chainloader +1

The first line is how you want your Windows entry to appear on the GRUB menu. 
The 2nd line ­ rootnoverify ­ sets the root device for Windows. Here, since my 
Windows   drive   is   a   slave   drive,   it   is   set   as   hd1.   And   since   my   bootable 
partition is the first one, it is 0. Thus we have (hd1, 0).

GRUB counts starting from zero. So the first hard drive is hd0, the second is 
hd1  and  so on.  It reads partitions  in  the same  way  too.  So if  your bootable 
partition, by any chance, were on another partition on that drive, then it could 
be something like this ­ (hd1, 1).  This is why it's important to identify your 
bootable partition in the first place (Step 1).  If you have an unusual Windows 
install, this could save you a lot of trouble.

The lines that start with map is a trick. Generally, Windows won't boot if it's 
not set as the first drive. In my case, I had BIOS read the Linux drive as the 
first, followed by my Windows drive. So we tell GRUB to swap the order of the 
drives,   making   Windows   now   as   the   primary/master   while   Linux   gets   to   be   the 
slave.

The next 2 lines just tells GRUB to set the partition as active, then executes 
the first sector of that partition.
If in other tutorials you see the line below in red,
title Windows XP
rootnoverify (hd1,0)
hide (hd0,0)
map (hd0) (hd1)
map (hd1) (hd0)
makeactive
chainloader +1

SKIP THAT LINE! You have been warned. For some reason, GRUB bugs out on it the 
next time you boot to Linux. It will cause the Linux drive to be set to another 
filesystem type which will give you the dreaded Error 17 message.  This was what 
happened to me  (further probing told me that my root partition was marked as an 
Amoeba filesystem). If this happens, the GRUB menu will no longer be there so 
you won't be able to boot to Linux.

If Single Disk Used For Linux And Windows
On a single drive it can't get any simple.   You don't have to use  map to swap 
the drive order.   If you have more than one Windows partitions on that drive, 
again   make   sure   you   identify   which   on   is   bootable.     Then   add   the   following 
lines,
title Windows XP
rootnoverify (hd1,0)
makeactive
chainloader +1

NOTE:   In   the   examples   above   make   sure   you   replace   the   drive   and   partition  
numbers to what is appropriate for your case.

So   there   we   go.   By   the   way   if   you   encounter   terms   suchs   as   'konsole'   just 
replace  it  with  your  Linux  distro's  default  terminal  application.   I  use  KDE 
extensively   hence   why   it   is   used   on   this   article.   Have   fun   on   your   newly 
installed Linux!  

* * * * *

Mark A  is supposedly a long­time Linux user.   Since the year 2000 he has installed and 


used Red Hat Linux, Fedora, Suse and Mandriva.   He has broken lots of installs as well 
due to his incessant tinkering of the Linux system.  Today he uses Kubuntu 9.04.  He is 
also one of the  content writers of Write Effects. Watch out for more of articles from 
Write Effects.

Das könnte Ihnen auch gefallen