Linux Grub

先看一下linux下的grub配置文件:

 

[root@rcc-pok-idg-2305 ~]# cat /boot/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 do not have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /, eg.
#          root (hd0,0)
#          kernel /boot/vmlinuz-version ro root=/dev/xvda1
#          initrd /boot/initrd-version.img
#boot=/dev/xvda
default=1#默认启动第几个系统
timeout=5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu #隐藏GRUB的启动菜单,这项也是可选的,也可以用#号注掉;
title Red Hat Enterprise Linux Server (2.6.18-128.el5xen)
        root (hd0,0)
        kernel /boot/vmlinuz-2.6.18-128.el5xen ro root=LABEL=/ rhgb quiet
        initrd /boot/initrd-2.6.18-128.el5xen.img
title Red Hat Enterprise Linux Server (kernel-2.6.18-128.el5)
        root (hd0,0)
        kernel /boot/vmlinuz-2.6.18-128.el5 ro root=LABEL=/ rhgb
        initrd /boot/initrd-2.6.18-128.el5.img

转载一篇好文章:

http://www.linuxsir.org/main/?q=node/129

 

1、什么是多重操作系统引导管理器及工作原理;

系统启动引导管理器,是在计算机启动后运行的第一个程序,他是用来负责加载、传输控制到操作系统的内核,一旦把内核挂载,系统引导管理器的任务就算完成退出,系统引导的其它部份,比如系统的初始化及启动过程则完全由内核来控制完成;

Briefly, boot loader is the first software program that runs when a computer starts. It is responsible for loading and transferring control to the operating system kernel software (such as the Hurd or the Linux). The kernel, in turn, initializes the rest of the operating system (e.g. GNU).

在X86 架构的机器中,Linux、BSD 或其它Unix类的操作系统中GRUB、LILO 是大家最为常用,应该说是主流;

Windows也有类似的工具NTLOADER;比如我们在机器中安装了Windows 98后,我们再安装一个Windows XP ,在机器启动的会有一个菜单让我们选择进入是进入Windows 98 还是进入Windows XP。NTLOADER就是一个多系统启动引导管理器,NTLOADER 同样也能引导Linux,只是极为麻烦罢了;

在Powerpc 架构的机器中,如果安装了Linux的Powerpc 版本,大多是用yaboot 多重引导管理器,比如Apple机目前用的是IBM Powerpc处理器,所以在如果想在Apple机上,安装Macos 和Linux Powerpc 版本,大多是用yaboot来引导多个操作系统;

因为目前X86架构的机器仍是主流, 所以目前GRUB和LILO 仍然是我们最常用的多重操作系统引导管理器

 

 

什么是GRUB;

GNU GRUB 是一个多重操作系统启动管理器。GNU GRUB 是由GRUB(GRand Unified Bootloader) 派生而来。GRUB 最初由Erich Stefan Boleyn 设计和应用;

GNU GRUB is a Multiboot boot loader. It was derived from GRUB, GRand Unified Bootloader, which was originally designed and implemented by Erich Stefan Boleyn.

 

目前在在Unix类的操作系统中,大多是都有GRUB;GRUB几乎能引导所有X86架构的操作系统;功能之强,使用简单是GRUB最大的卖点

 

查看grub的安装

[root@rcc-pok-idg-2305 ~]# rpm -qa | grep -i grub*
grub-0.97-38.fc10

 

在Linux中,GRUB软件包的安装,及在配置过程中安装grub到 /boot中还是不够的, 还要把GRUB,写入MBR才行;有时我们重新安装了Windows,Windows会把MBR 重写,这样GRUB就消失了;如果您出现这样的情况,就要进行这个过程;

[root@localhost ~]# grub

会出现grub> 提示符,这是grub命令行模式 ,如果能在开机中出现提示符,没有引导不起来的系统,除非您的系统破坏的极为严重。如果仅仅是GRUB被破坏了,GRUB命令行是能让操作系统引导起来的;

 

获取帮助GRUB的 help

只要您在grub> 提示符的后面输入help 就能得到GRUB所有的命令提示;

 

grub> help
help
blocklist FILE                         boot
cat FILE                               chainloader [--force] FILE
clear                                  color NORMAL [HIGHLIGHT]
configfile FILE                        device DRIVE DEVICE
displayapm                             displaymem
find FILENAME                          geometry DRIVE [CYLINDER HEAD SECTOR [
halt [--no-apm]                        help [--all] [PATTERN ...]
hide PARTITION                         initrd FILE [ARG ...]
kernel [--no-mem-option] [--type=TYPE] makeactive
map TO_DRIVE FROM_DRIVE                md5crypt
module FILE [ARG ...]                  modulenounzip FILE [ARG ...]
pager [FLAG]                           partnew PART TYPE START LEN
parttype PART TYPE                     quit
reboot                                 root [DEVICE [HDBIAS]]
rootnoverify [DEVICE [HDBIAS]]         serial [--unit=UNIT] [--port=PORT] [--
setkey [TO_KEY FROM_KEY]               setup [--prefix=DIR] [--stage2=STAGE2_
terminal [--dumb] [--no-echo] [--no-ed terminfo [--name=NAME --cursor-address
testvbe MODE                           unhide PARTITION
uppermem KBYTES                        vbeprobe [MODE]

 

 

系统引导过程主要由以下几个步骤组成(以硬盘启动为例)

  1、 开机;

  2、 BIOS加电自检(POST——Power On Self Test),内存地址为0fff:0000;

  3、 将硬盘第一个扇区(0头0道1扇区,也就是Boot Sector)读入内存地址0000:7c00处;

  4、 检查(WORD)0000:7dfe是否等于0xaa55.若不等于则转去尝试其他介质;如果没有其他启动介质,则显示 “No ROM BASIC” ,然后死机;

  5、 跳转到0000:7c00处执行MBR中的程序;

  6、 MBR先将自己复制到0000:0600处,然后继续执行;

  7、 在主分区表中搜索标志为活动的分区。如果发现没有活动分区或者不止一个活动分区,则停止;

  8、 将活动分区的第一个扇区读入内存地址0000:7c00处;

  9、 检查(WORD)0000:7dfe是否等于0xaa55,若不等于则显示 “Missing Operating System”,然后停止,或尝试软盘启动;

  10、 跳转到0000:7c00处继续执行特定系统的启动程序;

  11、 启动系统。

  以上步骤中(2),(3),(4),(5)步由BIOS的引导程序完成;(6),(7),(8),(9),(10)步由MBR中的引导程序完成。

  一般多系统引导程序(如Smart Boot Manager, BootStar, PQBoot等)都是将标准主引导记录替换成自己的引导程序,在运行系统启动程序之前让用户选择想要启动的分区。而某些系统自带的多系统引导程序(如 LILO,NT Loader等)则可以将自己的引导程序放在系统所处分区的第一个扇区中,在Linux中即为两个扇区的SuperBlock.

 

 

To summarize the boot process for PCs:

1 When a PC is turned on,the BIOS(Basic Input Output Service) performs a self test.

2 When the machine passes its self test,the BIOS loads the Master Boot Record(or MBR).This is usually the first hard drive on the system but may also be a diskette,CD or USB key;

3For a hard drive,the MBR loads a stage 1 boot loader,which is tppically either the LILO or GRUB stage1 boot loader on a Linux System. This is another 512 byte single-sector record.

4 The stage1 boot loader usually loads a sequence of records called the stage 2 boot loader

5 The stage 2 boot loads the OS.For Linux,this is the kernel and possibly an initial RAM disk

 

rc.d init.d区别:

rcc-pok-idg-2318:/etc # ls -l | grep -i init
drwxr-xr-x 11 root root       4096 Aug 18  2010 init.d
-rwxr-xr-x  1 root root       3861 Feb 20  2009 initscript
-rw-r--r--  1 root root       2982 Aug 18  2010 inittab
lrwxrwxrwx  1 root root          6 Feb 19 19:56 rc.d -> init.d

 

/var/log下面有关于很多启动相关的信息。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

惹不起的程咬金

来都来了,不赏点银子么

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值