建立grub引导
- 格式:wps
- 大小:288.19 KB
- 文档页数:15
制作BOOTMGR启动并可加载Grub引导的光盘测试环境:iso文件使用Qemu/简易启动测试器V4.0 beta6加载一、建立Grub引导的ISO文件主要是为下一步做铺垫。
1、将mkisofs.exe、cygwin1.dll放在一个文件夹内,并在这个目录下新建一文件夹iso_root(由于Grub不提倡用UltraIso制作光盘引导镜像,故用mkisofs);2、将Grub4fordos安装包内的文件grldr、grldr.mbr和menu.lst放在上述iso_root文件夹内;3、在menu.lst文件靠前的位置加一行如下内容,为了一会儿从grub菜单转回bootmgr菜单用:title bootmgrchainloader (bd)/BOOTMGR4、在1中那个大文件夹内建立并编辑批处理文件,输入以下内容:mkdir iso_rootcp grldr iso_rootcp menu.lst iso_rootmkisofs -R -b grldr -no-emul-boot -boot-load-size 4 -o grldr.iso iso_root5、这时已经建立了一个名为grldr.iso的光盘镜像,用虚拟机测试,应当可以进入grub菜单;6、用UltraIso打开grldr.iso,启动光盘---保存引导文件,命名为grldr.mbr(把结尾的.bif去掉即可);二、建立bootmgr方式引导的光盘,1、到windows7原始安装盘或者已经装好的windows7系统中提取如下文件:bootmgr、boot文件夹(只要里面的bcd和boot.sdi,想要中文显示的可以多几个文件/夹但意义不大);2、使用Bootice软件编辑上述bcd文件,新建启动项--实模式(grub4fordos),启动磁盘---boot,启动文件\grldr.mbr,名称Grub;3、用UltraIso将bootmgr、boot文件夹(只要里面的bcd和boot.sdi)放入上述grldr.iso镜像内;4、用UltraIso打开windows7原始安装盘ISO镜像,启动光盘---保存引导文件,命名为bootmgr;启动光盘----加载引导文件,把bootmgr.bif写入grldr.iso镜像内;5、用UltraIso把grldr.iso镜像根目录内grldr.mbr文件用“一、6”步骤中的文件替换。
基于UEFI引导的win8.1和ubuntu13.10双系统安装1.前言UEFI引导的出现乃至变得火热让系统安装的问题变得复杂,尤其是在windows横空出世并针对URFI优化更是让其与ubuntu组成的双系统安装变得情况百出(顺带哀悼下由此退出江湖的wubi安装)。
最近花了一天多的时间完成了win8.1与ubuntu13.10基于UEFI引导的安装,在过程中遇到了一些问题,理解了一些硬件和软件架构,摸索了一个不算完美的解决方案,在此整理,希望能够帮助到需要的人。
实验环境:电脑——联想Y510P支持UEFI启动,N卡Windows——Windows8.1简体中文64位Ubuntu——Ubuntukylin13.10AMD64位2.UEFI boot与Legacy boot基本输入/输出系统(BIOS)是硬件和操作系统之间的一层。
UEFI与Legacy都是系统引导的技术,都是实现电脑在硬件开机之后找到操作系统过程中的引导。
Legacy boot是传统的引导方式,其引导基于驱动器上的主引导记录(MBR)。
通俗的解释,一次系统启动的流程为,硬件开启→BIOS自检→读入MBR→读取激活主分区→启动系统。
一些蛋疼的人们认为Legacy boot有一些他们不能容忍的缺点:1)无法直接引导超过2.2T的驱动器2)缺乏安全性验证3)启动时间慢于是他们加强了BIOS的功能,设计了UEFI boot模式(仅针对64位系统),可以解决上述的问题,于是MBR被抛弃了,引进了一个新的引导分区EFI,采用全局唯一标识分区表GPT来引导分区,下图中可以在硬盘管理中看到EFI系统分区。
另一方面,UEFI boot也提供了驱动、系统信息的临时储存,用于加快开机。
在引导的时候也提供了SecureBoot,禁止加载未知的系统(正中Windows下怀)。
UEFI boot与Legacy boot对于我们安装双系统的影响是两个系统需要使用同一引导模式。
grub 使用手册以下是一个简单的 GRUB 使用手册:一、概述GRUB(Grand Unified Bootloader)是一个用于引导操作系统的启动引导程序。
它允许用户在多个操作系统之间进行选择,并提供了一些配置和诊断工具。
二、使用方法1. 进入 GRUB 菜单在计算机启动时,按下特定的键(通常是 Esc、F1、F2、F10 或 Del)进入GRUB 菜单。
这个菜单会显示可用的操作系统和启动项。
2. 选择操作系统使用上下箭头键选择要启动的操作系统,然后按 Enter 键。
如果您选择了一个带有操作系统的设备(例如硬盘上的某个分区),则会启动该操作系统。
3. 配置 GRUB您可以通过 GRUB 配置文件来定制 GRUB 的行为。
配置文件通常位于`/etc/default/grub` 或 `/etc//` 目录下。
使用文本编辑器打开配置文件,并进行所需的更改。
更改后,运行以下命令以更新 GRUB:```bashsudo update-grub```4. 修复 GRUB如果 GRUB 损坏或无法正常工作,您可以尝试使用以下命令修复它:```bashsudo grub-install /dev/sda```其中 `/dev/sda` 是您的硬盘设备名称。
这将重新安装 GRUB 到硬盘的MBR(主引导记录)中。
5. 退出 GRUB在 GRUB 菜单中,按下 Esc 键或按下任意键即可退出 GRUB 并返回到操作系统或启动菜单。
三、常见问题与解决方法1. 如何解决 GRUB 无法正常引导的问题?如果 GRUB 无法正常引导操作系统,您可以尝试使用系统恢复模式或启动盘来修复引导记录。
在恢复模式下,您可以使用命令行工具来修复 GRUB。
如果您有启动盘,可以使用它来启动计算机并运行修复工具。
一些常见的修复工具有 Boot-Repair、EasyBCD 等。
2. 如何添加新的操作系统到 GRUB?要添加新的操作系统到 GRUB,您需要编辑 GRUB 的配置文件。
使⽤Ubuntu原⽣的Grub2作为主引导,引导六个系统⽅法下⾯是Grub2引导各种系统的⽰例。
其实,⼤家有经验的话,光看⽰例,⾃⼰应该就懂怎么改了(注意:所引导的Mac系统是PC⿊苹果)。
我的Grub2配置⽂件列表(/boot/grub/grub.cfg):set default=0set timeout=3# Windows本地系统启动menuentry "Windows NT, XP/2003/Vista/Win7/Win8.1" {set root='(hd0,msdos1)'drivemap -s (hd0) ${root}chainloader +1# 对于NT6系统,也可以⽤:ntldr /bootmgr}# ⿊苹果本地系统启动menuentry "Mac OS X 10.8.5, Mountain Lion" {drivemap -s (hd0) (hd0,msdos7)linux16 (hd0,msdos5)/SysBackup/memdisk iso rawinitrd16 (hd0,msdos7)/wowpc.iso}# Ubuntu本地系统启动menuentry "Ubuntu Mate x86_64 3.11.0-12 generic" {search --no-floppy --set --label matebuntulinux /boot/vmlinuz root=LABEL=matebuntu rw quietinitrd /boot/initrd.img}# WindowsPE应急启动menuentry "Windows PE Boot" {linux16 (hd0,msdos5)/SysBackup/memdisk iso rawinitrd16 (hd0,msdos5)/SysBackup/win2k3pe.iso}# UbuntuLiveCD应急启动menuentry "Ubuntu LiveCD Boot" {loopback lo (hd0,msdos5)/SysBackup/flashback7e.isolinux (lo)/casper/vmlinuz boot=casper iso-scan/filename=/SysBackup/flashback7e.isoinitrd (lo)/casper/initrd.lz}# Mac变⾊龙应急启动menuentry "Mac Chameleon Boot" {drivemap -s (hd0) (hd0,msdos5)linux16 (hd0,msdos5)/SysBackup/memdisk iso rawinitrd16 (hd0,msdos5)/SysBackup/mac-wowpc.iso}# 内存颗粒损换检测menuentry "Memory test (memtest86+)" {linux16 /boot/memtest86+.bin}# 标准⼆进制可引导⽂件引导# menuentry "Grub for Dos" {# ntldr (hd0,msdos1)/grldr # }。
RHEL开机时的先后顺序BIOS —> MBR —> Kernel —> init1、当电脑一打开电源时电脑就会进入BIOS(BIOS的工作主要是检测一些硬件设备);2、检测完后会进入MBR也就是boot loader(MBR位于硬盘的第一个扇区总共512bytes,其中前446bytes里面的编码是在选择引导分区也就是决定要由哪个分区来引导);3、载入系统的Kernel(核心),在Kernel里主要是载入电脑设备的驱动程序,以便可以控制电脑上的设备,并且以只读方式来挂载根目录,也就是一开始只能读取到根目录所对应的那个分区,所以/etc、/bin、/sbin、/dev、/lib这五个目录必须同根目录在一个分区中;4、最后启动init这个程序,所以init这个程序的进程编号为1,是Linux中第一个执行的程序;init这个程序会根据Run level来执行以下这些程序:·/etc/rc.d/rc.sysinit;·/etc/rc.d/rc 和etc/rc.d/rc?.d/·/etc/rc.d/rc.local·如果有适当的图形界面管理程序二、BIOS初始化时主要的三个任务BIOS(B asic I nput/O utput S ystem)1、电脑周边设备的检测,加电自检POST (Power on self test);2、BIOS会选择要由哪一个设备来开机,例如:软盘启动、光盘启动、网络启动、最常见的从硬盘启动;3、选择好由哪个设备开机后,就开始读取这个设备的MBR 引导扇区;三、介绍Boot Loader中的主要工作1、Boot Loader可以安装在两个地方:·安装在硬盘的MBR中;·当有时候MBR中被其他开机管理程序占用就可以将Boot Loader 安装在硬盘中的其中一个分区的引导扇区上,;2、Boot Loader的程序码分为两个阶段:(1)Boot Loader第一阶段的程序码非常小,只有446bytes,可以存入在MBR或是某一个分区的引导扇区里,(2)Boot Loader第一阶段的程序码是从boot 分区来载入的,就是说Boot Loader 第二阶段程序码存放在/boot 这个分区中;3、下面来看三个Boot Loader 的开机流程范例,如在一块硬盘中安装了两个系统分别为:windows 2003 和Red hat linux当电脑开机后,会先载入MBR通过第一阶段程序码来载入第二阶段程序码,进入GRUB开机菜单这里选择哪个系统就会载入相应的核心;splashimage=(hd0,0)/grub/splash.xpm.gz开机时使用的背景图案,这里的(hd0,0)意思为(硬盘编号,分区编号)hiddenmenu隐藏开机的菜单(2)用于区分多个系统的设定,如果这台主机中还安装了其它系统并设定了多重启动,在这里还可以看到其它系统的设定;title Red Hat Enterprise Linux AS (2.6.9-11.EL)在GRUB开机菜单中所显示的开机的系统名称root (hd0,0)指定下面的档案位于哪个目录中,这个hd0,0 同样指的是用于指引导的目录,通常指/boot目录kernel /vmlinuz-2.6.9-11.EL ro root=LABEL=/ rhgb quiet设定kernel镜像的存放位置,这个位置相对于上面root 那一行所指定的位置的相对位置,ro root=LABEL=/ 是设定/在根目录的位置,ro是只读的意思,也就是以只读方式挂载根目录,也可以使用root=/dev/hda2 类似于这种形式来挂载根目录;rhgb 意思是以图形界面显示开机过程,去掉则以文字界面显示;quiet 意思是设定开机过程中不显示错误信息;initrd /initrd-2.6.9-11.EL.img 将这个指定的文件载入到内存中,这个文件里都是存放一些驱动程序;3、如果我们修改完grub.conf 这个配置文件后,设定为立即生效;4、另外,如果硬盘上的MBR被清除掉了,可使用下面的指令来重新安装boot loader 到MBR中:/sbin/grub-install /dev/hda5、介绍进入GRUB的开机管理程式可以做哪些动作(开机前改Kernel的参数)(1)开机后在进入GRUB界面后,先选择要使用的系统(这里选择Linux)(2)按下a键,可以在开机修改Kernel的参数,也就是可以传一个参数给Kernel;这时可以看到下面这个界面(3)上图中root=LABEL=/ 这部分不可以动,将后面的都去掉后,先输入一个空格再输入一个1,如下图:这个1 就是附加的一个参数,表示要进入单用户模式,不需要输入root密码就可以以root 身份登录;(4)当进入到#提示字元时,就可以设定root 密码了。
云主机添加Grub2引导WinPE ISO(Windows系统)导读云主机安装的系统是Windows 2008 R2,BIOS+MBR,想利用Grub2引导发位于磁盘上Windows PE ISO 或其他系统,可以采用在Windows 系统中安装grub2实现。
安装配置步骤第一步、Grub2下载,文件准备到Grub2官网ftp:///gnu/grub/ 下载文件grub-2.02-for-windows.zip,将其解压至任意路径下,比如D:\。
这样Grub2的主程序目录将位于D:\grub-2.02-for-windows第二步,Grub2安装以管理员身份运行CMD,输入命令wmic diskdrive list brief,记录下安装目标磁盘DeviceID,本教程将安装至\\.\PHYSICALDRIVE0============================================== ====================================Microsoft Windows [Version 10.0.10586](c) 2015 Microsoft Corporation. All rights reserved.C:\Windows\system32>wmic diskdrive list briefCaption DeviceID Model Partitions Size WDC WD5000AAKX-001CA0 \\.\PHYSICALDRIVE0 WDC WD5000AAKX-001CA0 3 500105249280C:\Windows\system32>===================================================== =============================将当前路径切换至Grub2主程序所在路径,输入cd /d d:\grub-2.02-for-windows===================================================== =============================C:\Windows\system32>cd /d d:\grub-2.02-for-windowsd:\grub-2.02-for-windows>===================================================== =============================查看grub-install.exe的帮助文件,可以输入grub-install.exe --help或grub-install.exe -?,显示如下内容:===================================================== =============================Usage: grub-install [OPTION...] [OPTION] [INSTALL_DEVICE]Install GRUB on your drive.--compress=no|xz|gz|lzo compress GRUB files [optional]-d, --directory=DIR use images and modules under DIR[default=C:\grub-2.02-for-windows/<platform>]--fonts=FONTS install FONTS [default=unicode]--install-modules=MODULES install only MODULES and their dependencies[default=all]-k, --pubkey=FILE embed FILE as public key for signature checking --locale-directory=DIR use translations under DIR[default=C:\grub-2.02-for-windows/locale]--locales=LOCALES install only LOCALES [default=all]--modules=MODULES pre-load specified modules MODULES--themes=THEMES install THEMES [default=starfield]-v, --verbose print verbose messages.--allow-floppy make the drive also bootable as floppy (defaultfor fdX devices). May break on some BIOSes.--boot-directory=DIR install GRUB images under the directory DIR/grubinstead of the boot/grub directory--bootloader-id=ID the ID of bootloader. This option is onlyavailable on EFI and Macs.--core-compress=xz|none|autochoose the compression to use for core image--disk-module=MODULE disk module to use (biosdisk or native). Thisoption is only available on BIOS target.--efi-directory=DIR use DIR as the EFI System Partition root.--force install even if problems are detected--force-file-id use identifier file even if UUID is available--label-bgcolor=COLOR use COLOR for label background--label-color=COLOR use COLOR for label--label-font=FILE use FILE as font for label--macppc-directory=DIR use DIR for PPC MAC install.--no-bootsector do not install bootsector--no-nvram don't update the `boot-device'/`Boot*' NVRAMvariables. This option is only available on EFIand IEEE1275 targets.--no-rs-codes Do not apply any reed-solomon codes whenembedding core.img. This option is only availableon x86 BIOS targets.--product-version=STRING use STRING as product version--recheck delete device map if it already exists--removable the installation device is removable. This optionis only available on EFI.-s, --skip-fs-probe do not probe for filesystems in DEVICE--target=TARGET install GRUB for TARGET platform[default=i386-pc]; available targets: arm-efi,arm-uboot, arm64-efi, i386-coreboot, i386-efi,i386-ieee1275, i386-multiboot, i386-pc,i386-qemu, i386-xen, ia64-efi, mips-arc,mips-qemu_mips, mipsel-arc, mipsel-loongson,mipsel-qemu_mips, powerpc-ieee1275,sparc64-ieee1275, x86_64-efi, x86_64-xen-?, --help give this help list--usage give a short usage message-V, --version print program versionMandatory or optional arguments to long options are also mandatory or optional for any corresponding short options.INSTALL_DEVICE must be system device filename.grub-install copies GRUB images into boot/grub. On some platforms, it may also install GRUB into the boot sector.Report bugs to <bug-grub@>.===================================================== =============================参数说明:--directory 指定镜像和模块的路径,本教程将此参数设置为--directory=D:\grub-2.02-for-windows\i386-pc,如果把grub2压缩包解压至c盘,此参数可以不进行设置,因为default=C:\grub-2.02-for-windows/<platform>,platform 会根据当前的平台从i386-pc和i386-efi两个路径中进行自动选择。
Grub引导程序的安装、配置及使用汇总(一)安装linux时安装grub.安装redhat linux时会提示安装引导程序,如果选择grub为引导程序,建议把grub安装到硬盘的引导扇区MBR. grub 还可以引导其它操作系统,如 FreeBSD、NetBSD、OpenBSD、GNU HURD 和 DOS,以及 Windows 95、98、NT、2000、XP。
(二)grub的配置一旦选择了grub为引导程序,下面我们来了解一下它的配置./boot/grub/grub.conf是grub产生一个引导选择菜单以及设置一些选项.下面是我的grub.conf:#==========例子开始==========# grub.conf generated by anaconda# Note that you do not have to rerun grub after making changes to this file # NOTICE: You have a /boot partition. This means that# all kernel and initrd paths are relative to /boot/, eg.# root (hd0,6)# kernel /vmlinuz-version ro root=/dev/hda10 # initrd /initrd-version.img#boot=/dev/hdadefault=0timeout=10splashimage=(hd0,6)/grub/splash.xpm.gz# --> Redhat Linux 8.0 <--title Red Hat Linux (2.4.18-14)root (hd0,6)kernel /vmlinuz-2.4.18-14 ro root=LABEL=/initrd /initrd-2.4.18-14.img# --> Microsoft Windows XP <--title Microsoft Windows XProotnoverify (hd0,0)chainloader +1#===========例子结束==========配置选项解释:以"#"开头的是注释行.我这里有两个操作系统,分别是Red Hat Linux和Microsoft Windows XP.其中 timeout标识默认等待时间,我这设置为10秒,超过10秒用户还没作出选择的话,将自动选择默认的操作系统(我这里默认的是Redhat linux 8.0)里0表示第一个,1表示第二个.所以如果你想修改默认的操作系统,就修改default后的数字.title一项是设置操作系统的名称,grub不支持中文(有点遗憾).splashimage一项指定grub界面的背景图片,有兴趣的朋友可以修改grub的背景哦!root (hd0,6)标识从第一个硬盘,第7个分区来启动搜索引导内核.注意这儿的root与linux的root分区不同,此root非彼root也! grub的硬盘标识方法与linux的有点不同.在linux中第一个主分区为hda1,第二个主分区为hda2,第一个逻辑分区为hda5,而在 grub 中是以(hdx,y)来标识的,如第一个主分区为(hd0,0)第一个逻辑分区为(hd0,4)依此类推.所以这儿root后面的是你的 /boot所在分区标识.知道了内核在哪儿,还要具体指出哪个文件是内核文件,这就是kernel的工作。
grub引导启动win10Ubantu凤凰OS三系统在Ubantu OS下,⽤⽂件管理器打开系统磁盘下的 boot⽂件夹,然后⽤管理员⾝份打开grub⽂件夹,然后打开grub.cfg(⽤记事本打开)4. 在grub.cfg⽂件⾥⾯找到下⼀段内容(⽐较靠下):# This file provides an easy way to add custom menu entries. Simply type the# menu entries you want to add after this comment. Be careful not to change# the ‘exec tail’ line above.5.在这⼀段的下⾯添加下⾯的内容(不要照抄,有⼏个项⽬需要根据你的情况改动);menuentry “PhoenixOS” {set root=(hd0,3)linux /PhoenixOS/kernel quiet root=/dev/sda3 androidboot.hardware=android_x86 video=-16 SRC=/PhoenixOSinitrd /PhoenixOS/initrd.img}第⼀⾏:“PhoenixOSS”,这个随便写,你想在grub显⽰什么就输⼊什么。
第⼆⾏:“hd0,3“,这个是你安装安卓系统的分区。
这个需要看看安卓系统所在磁盘在linux下被识别为什么,这个可以在deepin的分区管理看.⽐如说,我在win下安装在C盘,在deepin的磁盘管理看到对应的是sda3,所以是hd0,3别为sda”x“(x是数字)。
该分区若在linux下识别为sdb”x“,那么你就在这⾥写上hd1,x,以此类推。
第三⾏:”sda3“,同样的,是你安装安卓系统的分区第三四⾏:PhoenixOS,这个是安卓系统安装⽬录的⽂件夹名。
保存后退出重新启动就可以了。
Recovery Using the Ubuntu Desktop/Live CD(RECOMMENDED)IntroductionThis method will install Grub boot-loader into the Master Boot Record (MBR)of the main computer hard drive.The slight complexity of this method consists of determining whether Ubuntu Operating System installed on your computer was configured for Grub or Grub 2.If you fresh-installed Ubuntu Karmic 9.10 or newer, you are running Grub2.If you ran previous version of Ubuntu and upgraded to Ubuntu Karmic 9.10, you are running Grub Legacy by default; unless you have executed upgrade-from-grub-legacy, then you are running Grub2.If you are running Ubuntu Jaunty or Intrepid, you are running Grub Legacy.If you are not sure, follow the guide assuming you are running Grub2 -- there will be a point to make a correction.You can check the current version installed on your system via Synaptic or from the command line. Open a Terminal and enter the following:grub-install -vGRUB 2 should display a version number of 1.96 or later. Legacy GRUB is version 0.97. Create and boot from a Live CDGrub2: Download the latest version of Ubuntu Desktop edition from /GetUbuntu/download and burn your Ubuntu CD.Grub Legacy: See the dual-boot guide about recovering grubReboot your computer and boot into a live session.Mount your Ubuntu partition from Places menu. If you have multiple Ubuntu partitions (e.g., /boot, /home, /), you need to mount the /boot partition.Are you using Grub or Grub 2?Go into boot/grub directory and check for the existence of the files menu.lst and grub.cfg.Grub Legacy uses boot/grub/menu.lst .Grub 2 uses uses boot/grub/grub.cfg .If you are still not sure, view the file and check whether syntax follows Grub2 conventions.If you downloaded Ubuntu Karmic 9.10 Live CD, but your installed version of Ubuntu uses GrubLegacy, please use this guide https:///community/DualBoot/Grub#Ubuntu%209.10%20&%20earlierOverwriting the Master Boot RecordExisting MBR will be lost. In order to dual-boot your computer, we will be creating a newMaster Boot Record to include all operating systems, including Ubuntu Linux andMicrosoft Windows. This is to be expected.Your Ubuntu partition is now mounted. You will need to continue Using the Terminal.Verify if your partition is correct.mount | tail -1You should see output similar to this:/dev/sda2 on /media/0d104aff-ec8c-44c8-b811-92b993823444 type ext4(rw,nosuid,nodev,uhelper=devkit)Note the designation for the disk /dev/sda which you will be using later, and the directory in/media.Use Tab Completion in Terminal to complete the path. Hitting the <TAB> key willautomatically finish file names, directory locations, and other long or hard to type file names.To make sure this is indeed the Ubuntu boot partition, runls /media/0d104aff-ec8c-44c8-b811-92b993823444/bootBut substitute the example's UUID, 0d104aff-ec8c-44c8-b811-92b993823444, with your volume'sUUID which you found earlier. If your boot partition was a separate partition which you mountedin a previous step, use this insteadls /media/0d104aff-ec8c-44c8-b811-92b993823444In either case, the output should be something like this:config-2.6.18-3-686 initrd.img-2.6.18-3-686.bakSystem.map-2.6.18-3-686grub lost+found vmlinuz-2.6.18-3-686initrd.img-2.6.18-3-686 memtest86+.binIf what you have is not similar, unmount it and try another partition.Now that everything is mounted, we just need to reinstall GRUB by specifying the correctdirectory and the correct drive name:sudo grub-install--root-directory=/media/0d104aff-ec8c-44c8-b811-92b993823444/dev/sdaIf you get BIOS warnings try:sudo grub-install--root-directory=/media/0d104aff-ec8c-44c8-b811-92b993823444/dev/sda --recheckReplace /dev/sda with the location you want to install GRUB on.If all went well, you should see something like this:Installation finished. No error reported.This is the contents of the device map /boot/grub/device.map. Check if this is correct or not. If any of the lines is incorrect, fix it and re-run the script `grub-install'.(hd0) /dev/sdaReboot, making sure to boot to your hard drive and not to the live CD. Grub should be installed and both Ubuntu and Windows should have been automatically detected and listed in the menu. The Master Boot Record will execute Grub as the initial boot-loader. The Windows boot-loader is contained within the Windows partition and will then be chainloaded by the Grub boot-loader.For Grub LegacyPlease refer to the guidehttps:///community/DualBoot/Grub#Ubuntu%209.10%20&%20earlier TroubleshootingI don't see a Grub menuIf the menu is not normally displayed during boot, hold down the SHIFT key as the computer attempts to boot to display the GRUB 2 menu. For Grub Legacy, use ESC key to display a menu. Grub comes up in shell mode with no boot menuYou may have mixed up Grub Legacy and Grub 2. This symptom is most typical when you assumed you have Grub 2, but your Ubuntu OS actually uses Grub Legacy. Follow these instructions again using Ubuntu 9.04 Live CD.If you are certain you have Grub 2 and it's still displaying shell mode by now, follow the method using chroot listed here...http://www.ubuntu-inside.me/2009/06/howto-recover-grub2-after-windows.html.What if Grub 2 does not list WindowsIf, after installing grub, Windows does not appear in the boot-menu, boot into Ubuntu and execute commandsudo update-grub2Grub 2 gives "error: no such device: xxxxx.xxxxx.xxxxx.xxxx"If at any time grub2 gives this error, boot up into Ubuntu (on hard disk if possible, otherwise with Live CD), open a terminal and run commandsudo update-grub2This should automatically detect the devices and configure grub appropriately.What if Grub Legacy misses WindowsIf, after installing grub, Windows does not appear in the boot menu, you will need to edit /boot/grub/menu.lst (That is a lowercase "L" and not the number 1 in menu.lst)Open a terminal and enter:gksu gedit /boot/grub/menu.lst Or, in Kubuntu:kdesu kate /boot/grub/menu.lstYour Windows stanza should look something like this:title Windows XP/Vista # Use any title you wish, it will appear in the grub boot menurootnoverify (hd0,0)# This is the location of the windows partition makeactivechainloader +1Note: Put your Windows stanza before or after AUTOMAGIC KERNEL LIST in the menu.lst Recovery using Microsoft Windows and Its Bootloader If you have your Linux system in a second (or third...) hard disk this method will not work. Please check Super Grub Disk's method that address this problem.This method will also fail with Grub 2. This method allows you to restore GRUB and keep the Windows boot-loader as your primary boot-loader. Thanks to Ubuntu's support for NTFS writing this method is now quite simple.The previous method puts GRUB back on the MBR (Master Boot Record) of the hard drive instead of in the root partition. Should you not wish to do so, for instance if you use a third-party boot manager like Boot Magic or System Commander, this next suggestion will be helpful. Another reason to prefer this method is for when restoring the Grub menu after a re-ghosting. In either case, use this alternative.Restoring GRUB1. Boot from a Live CD, like Ubuntu Desktop, or similar. It is recommended to use Ubuntu 9.04 or newer as this has NTFS write support.2. Open a Terminal . Open a root terminal (For non-Ubuntu live CDs type su the terminal. For Ubuntu based distros runsudo -i}Enter root passwords as necessary.3. Typegrubwhich makes a GRUB prompt appear.4. Typefind /boot/grub/stage1You'll get a response like "(hd0)" or in my case "(hd0,3)". Use the output from this command for the following commands.Note:You should have mounted the partition which has your Linux system before typing this command.(e.g. In Knoppix Live CD partitions are shown on the desktop but they're not mounted until you double-click on them or mount them manually)5. Typeroot (hd0,3)note the space between root and (hd0,3).6. Typesetup (hd0,3)into the prompt. This is key. Other instructions say to use "(hd0)", and that's fine if you want to write GRUB to the MBR. If you want to write it to your Linux root partition, then you want the number after the comma, such as "(hd0,3)".7. Typequit8. At this stage you can either restart the system and install your own boot-loader, or you can continue and tell the Windows boot-loader where to find GRUB which will handle booting Linux. Making Windows Load GRUB (and then Linux)This is taken from Dual-Boot Linux and Windows 2000/Windows XP with GRUB HOWTO which has been helping people dual boot since at least 2005.1. In Linux open a command window.2. Mount a drive which you can share with Windows. This could be a USB drive, a FAT32 partition on your hard drive, or if you are using a Linux distribution which supports NTFS writing natively (Such as Ubuntu 8.04 or later) then you can mount the actual Windows C:\ drive itself! The advantage of writing to the Windows drive is that you are going to need to put a file there eventually, so it saves time copying a file around. For example:#mkdir /tmp/windows#mount /dev/sda1 /tmp/windowsHowever, when writing directly to the C:\ drive you could also do some damage to the system if you delete or move something. If you do pick the option to write directly, go in, put the file where it belongs, and touch NOTHING else.3. Now you are going to make a copy of your boot partition. Finding out what this is called is not always completely reliable since the Linux naming conventions differ from the GRUB naming conventions. Linux labels partitions as hd[Letter][Number]or sd[Letter][Number]whereas GRUB always names them as hd[Number][Number]. If you installed GRUB on (hd0,0), then the/boot partition will be on hda1 or sda1. (Since (hd1,0) == hdb1 or sdb1, then by extension if you installed GRUB on (hd0,1) then the /boot partition will be on hda2 or sda2 and so on and so forth.) This narrows you down to two possibilities. If you now pastels /dev |grep hdit will let you know if you have that drive on your machine. If nothing comes up which matches, then that means you must have an sd drive.Note: The command df won't work as you are booted from a Live CD.4. Having determined your boot partition run this command as root by using sudosudo #dd if=/dev/sda2 of=/tmp/windows/linux.bin bs=512 count=1Looking at this example /dev/sda2 is your boot partition and /tmp/windows/ is the drive you want to copy the boot sector image to.5. If you haven't created linux.bin in the Windows drive then you need to copy it there now.6. Next, reboot your computer and boot into Windows. Open C:\boot.ini in Notepad, and add a new line at the bottom:c:\linux.bin="Linux"This file might be write protected. If that is so, you need to enable writing to the file. To do so, right click, and from the context menu select Properties. Then uncheck the box that says "File is read only". Make sure to put that checkmark back afterwards.Next, make sure that at the top of the boot.ini file there is a timeout set, i.e timeout=5 or some such number.Do not edit this file from the Live CD, even if you have NTFS write support. Linux and Windows represent line breaks in different ways, so even though you can edit the file, it won't adda new line.7. That's it, reboot and you will be given the option of booting into Linux, selecting that will chainload GRUB and this will let you boot into your Linux distro.Source: /showpost.php?p=121355&postcount=5Recovery Using the Unofficial RescatuxNote about grub2: Rescatux can be used to restore either Grub (Ubuntu 9.04 and previous versions) or Grub2 (Ubuntu 9.10 and later versions)Download Rescatux∙Burn the Rescatux ISO in a cdrom∙Make your PC boot from the cdrom∙At Debian Live Boot screen just press ENTERSelect Restore grub / Fix Linux Boot option and click on OK buttonSelect the partition where your Ubuntu is and click on OK buttonSelect the hard disk where you want Grub to be installed (usually the first one)Grub was installed OK confirmation / Grub was not installed error will appearLook for System -> Shutdown in the top tray in order to halt your machineRecovery Using the Unofficial "Super Grub Disk"Note about grub2: The methods regarding "Super Grub Disk" described here do not work with grub2 but with grub legacy. That means that you should not use them for fresh Ubuntu 9.10 install or Ubuntu newer versions.From within WindowsDownload Auto Super Grub DiskDouble-click auto_super_grub_disk_1.7 icon, install it, and reboot.On the next boot, select the UNetbootin-supergrubdisk menu entry; this will launch the AutoSuper Grub Disk.∙Do nothing till you see your Grub menu again.∙Next time you boot Windows, click yes when asked to remove UNetbootin-supergrubdisk to remove the Super Grub Disk menu entry.As a standalone cd/floppy/usbDownload Super Grub Disk∙Burn into a cdrom (better) or a floppy∙Boot from itSelect: GRUB => MBR & !LINUX! (>2) MANUAL |8-)∙Select the Linux or Grub installation you want to restore.∙You see the message: SGD has done it!∙Reboot∙You're done.Preserving Windows BootloaderThe method shown above puts GRUB back on the MBR (Master Boot Record) of the hard drive instead of in the root partition. If you use a third-party boot manager like Boot Magic or System Commander you probably won't want to do that. This method could also be used to restore the Grub menu after a re-ghosting. If this is the case, use this alternative.NOTE: This alternative, used without a third-party boot manager, will not cause Ubuntu to boot. This method will let you boot your second hard disk Linux installations from Windows while the Using the Ubuntu Desktop/Live CD. Preserving Windows Boot-loader instructions will not.Either:Download Super Grub Disk∙Burn into a cdrom (suggested) or a floppy∙Boot from itOr:Download UNetbootin Super Grub Disk Loader (Windows .exe version)∙Run the installer and reboot when once done installing.∙On the next boot, select the "UNetbootin-supergrubdisk" menu entry; this will launch the Super Grub Disk interface.Then:Pick the Super Grub Disk (WITH HELP) :-))) option∙Select your language from the listChoose WindowsSelect: Windows chainloads Grub!∙Select the Linux or Grub installation you want to restore to its own partition.You see the message: SGD has done it!∙Reboot∙Job completed.Recovery Using the Ubuntu Alternate/Install CDThis section explains how to rescue Grub, using the Ubuntu Alternate/install CD.1Enter your computers BIOS to check computer can boot from CD ROM. If you can boot from CD, insert CD ROM into drive. Exit the BIOS (if needed save your settings to make sure the computer boots from the CD ROM).When the Ubuntu splash screen comes up with the boot: prompt, type in rescue and press enter.1Choose your language, location (country) and then keyboard layout as if you were doinga fresh install.1Enter a host name, or leave it with the default (Ubuntu).At this stage you are presented with a screen where you can select which partition is your root partition (there is a list of the partitions on your hard drive, so you are required to know which partition number Ubuntu is on). This will bedev/discs/disc0/partX, where the X is a partition number.1you are then presented with a command prompt (a hash).1type$ grub-install /dev/XXXwhere XXX is the device of your Ubuntu install. (eg: grub-install /dev/""hda"" or grub-install /dev/""sdb"" ). Note: newer 2.6.xx kernels call all hard disks ""sdx"" now but not sure if grub does.The GUI Way: Using the Alternate/Install CD and Overwriting the Windows bootloaderAgain, this is for Grub legacy, not for Grub2. So, do not try with Ubuntu 10.04 or more recent unless you have deliberately installed Grub legacy and managed to get it working in the past. After re-initializing your mount points and other options, and after writing the changes to disk, system files are automatically installed. Each time I have tried this an error is thrown that busybox-initramfs could not be installed (I assume because a newer version exists - but I don't know. This error MIGHT be avoided if one has internet access, again, I don't know). The error aborts the installation of system files, and returns you to the menu. If you then select to install the grub boot-loader, it too, errors-out because the installation of system files did not complete. You are stuck in a loop. Unless you know some bash-magic to bypass this impasse, your only alternative (you will be unable to boot into your system now), is to return to the partitioner, reformat, and reinstall from scratch.1Boot your computer with the Ubuntu CD1Go through the installation process until you reach "[!!!] Disk Partition"1Select Manual Partitiono Mount your appropriate linux partitions:/o/booto swapo...DO NOT FORMAT THEM.1Finish the manual partition1Say "Yes" when it asks you to save the changes1It will give you errors saying that "the system couldn't install ....." after that。