当前时区为 UTC + 8 小时



发表新帖 回复这个主题  [ 1 篇帖子 ] 
作者 内容
1 楼 
 文章标题 : 双系统重装xp grub2修复
帖子发表于 : 2010-01-21 14:31 
头像

注册: 2009-09-10 9:28
帖子: 30
送出感谢: 0 次
接收感谢: 0 次
原文:http://blogs.koolwal.net/2008/12/28/windows-xpvista-dual-boot-does-not-boot-from-grub2-or-grub-pc/
Purpose: Wondering why Windows XP or (Windows Vista) on your dual-boot computer, i.e. having Windows XP and Linux installed, is not able to boot? The answer is that either there is a bug in the GRUB2 package or IDE disk naming convention has changed in GRUB2 from legacy GRUB.

Are you getting following error messages from GRUB2 when you try to boot Windows XP?

chainloader: no such command.
no such partition
you need to load kernel first
If you are then follow the steps below to try to solve your problem.

Set-up:

A laptop having dual-boot – Windows XP and Debian (Lenny) on separate partitions on a single hard drive. Here is my partition structure:

# fdisk -l /dev/sda

Disk /dev/sda: 60.0 GB, 60011642880 bytes
255 heads, 63 sectors/track, 7296 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0×2e61c242

Device Boot Start End Blocks Id System
/dev/sda1 * 1 3315 26627706 7 HPFS/NTFS
/dev/sda2 3316 7296 31977382+ 5 Extended
/dev/sda5 * 3316 5139 14651248+ 83 Linux
/dev/sda6 5140 5200 489951 82 Linux swap / Solaris
/dev/sda7 5201 7296 16836088+ b W95 FAT32

Step 1: Install GRUB2


Suppose you upgraded to GRUB2 doing following:

#apt-get update
#apt-get install grub2

Step 2: Reboot system


Now upon installing the GRUB2 package successfully and reboot your machine you will see a changed GRUB menu. Now select “Chainload into GRUB2″ and chances are that you won’t even find your XP partition listed in there (I didn’t find mine).


Step 3: Create a boot file for Windows XP/Vista/7


Boot into your Linux system by selecting your kernel (if there are multiple) from your GRUB2 menu and see if it boots fine. Upon booting into Linux do the following:

# nano /etc/grub.d/11_Windows (this will essentially create a new file)

and add the following lines:

#! /bin/sh -e
echo "Adding Windows" >&2
cat << EOF
menuentry "Windows XP" {
set root=(hd0,1)
chainloader +1
}
EOF

Note: In earlier version of GRUB, if your Windows was installed on First partition then you need to give root=(hd0,0), since that’s how GRUB use to number the partitions. However from this new version onwards, you need to give root=(hd0,1) if your Windows is installed on first partition of the hard drive.

Update: One of the commenter (Thanks Jorge), suggested that he had to give the following additional command:

chmod a+x /etc/grub.d/11_Windows

So under new GRUB2:

Windows on:

First partition (/dev/sda1): root=(hd0,1)

Extended First partition (/dev/sda5): root=(hd0,5)

Extended Second partition (/dev/sda6): root=(hd0,6)

and so on…

Now save the file (11_Windows) and give the following command:

# update-grub2

You should be able to see something like this:

# update-grub2
Updating /boot/grub/grub.cfg ...
Found Debian background: moreblue-orbit-grub.png
Found linux image: /boot/vmlinuz-2.6.26-rt1-rt
Found initrd image: /boot/initrd.img-2.6.26-rt1-rt
Found linux image: /boot/vmlinuz-2.6.26-1-686
Found initrd image: /boot/initrd.img-2.6.26-1-686
Found linux image: /boot/vmlinuz-2.6.25-2-686
Found initrd image: /boot/initrd.img-2.6.25-2-686
Adding Windows
done


Step 4: Reboot again


Now reboot your system and again go to “Chainload into GRUB2″ option and you should see an entry for Windows XP and it should be able to boot into Windows XP.

Step 5: Upgrade to GRUB2 “really”


Once you are convinced that the new GRUB2 is letting you boot into Linux and Windows properly, you can install the GRUB2 into your MBR (Master Boot Record) by either selecting the option “upgrade-from-grub-legacy” from the GRUB menu or by giving the command “upgrade-from-grub-legacy” when you are into your Linux system.

Additional Notes:

GRUB2 boot menu configuration file: The file /boot/grub/grub.cfg is equivalent of /boot/grub/menu.lst of the old GRUB. This file is self-generated by the command “update-grub” and upgrade-grub2?. Both these command do the same thing.
Do NOT select the option “upgrade-from-grub-legacy” unless and until you have verified that the GRUB2 loads your OS properly.
GRUB2 configuration files: All the GRUB2 configuration files are stored at the location /etc/grub.d. Read the file README under that location to get an idea as to how those configuration file works.
Lastly you can edit the GRUB2 boot config file (/boot/grub/grub.cfg) on-the-fly from the GRUB2 menu. Just press “e” and you will be in a editor mode and you can change the lines and experiment with it until you are able to boot successfully into Windows and/or Linux. You don’t have to boot the system into Linux every time you need to make changes to the GRUB2 config files.
As usual, please leave a comment/feedback if you have any. Comments encourages bloggers to post more and keep their spirits high.

Also don’t forget to rate this post below.

Liked this post? You may like these too:
HOWTO: Linking files from your Windows shared network drives in Wiki
INFO: GRUB2 – 101 Class
HOWTO: Resolving more udev issues on Debian


页首
 用户资料  
 
显示帖子 :  排序  
发表新帖 回复这个主题  [ 1 篇帖子 ] 

当前时区为 UTC + 8 小时


在线用户

正在浏览此版面的用户:没有注册用户 和 3 位游客


不能 在这个版面发表主题
不能 在这个版面回复主题
不能 在这个版面编辑帖子
不能 在这个版面删除帖子
不能 在这个版面提交附件

前往 :  
本站点为公益性站点,用于推广开源自由软件,由 DiaHosting VPSBudgetVM VPS 提供服务。
我们认为:软件应可免费取得,软件工具在各种语言环境下皆可使用,且不会有任何功能上的差异;
人们应有定制和修改软件的自由,且方式不受限制,只要他们自认为合适。

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
简体中文语系由 王笑宇 翻译