制作GRUB启动软盘/备份恢复硬盘引导程 & GRUB手册

上一篇 / 下一篇  2007-12-08 01:41:20 / 个人分类:Linux系统配置

.rLm1}4Ig0如何制作GRUB引导软盘

#T2L0AObg051Testing软件测试网'o:g C:b;zWeDw

GRUB是Ubuntu linux默认的引导程序,由GNU项目组开发,它可以支持当前常见的大部份操作系统的引导。本文主要介绍如何将GRUB安装到一张软盘上,并且最终制作 完成的引导软盘将可以启动你现在硬盘上已经安装的操作系统,你也可以通过这张软盘进入GRUB的命令操作界面,通过输入命令开启动你想使用的操作系统。本 文所有操作均在Ubuntu Linux下进行。51Testing软件测试网0l(^W9b&gZ

/zl J&B2_u01.执行下面的命令,获取管理员权限.51Testing软件测试网)u-k/`|1B

sudo -s51Testing软件测试网5zZ/V;`*cWeU)k\[
51Testing软件测试网3gWBo]#Z+Q.R

answer the <password> prompt51Testing软件测试网g2\&P:F6UI}T

Z9Z8xl n6u'E9l#k\C02.将软盘格式化成ext2文件系统:

M)W6Vj|K.oR%@0
mke2fs /dev/fd051Testing软件测试网2k;vJOakK
51Testing软件测试网}ty Y4P

3.加载软驱,复制GRUB启动所需的文件.51Testing软件测试网T$i6G^ }!@,en

mount /dev/fd0 /media/floppy mkdir /media/floppy/boot mkdir /media/floppy/boot/grub cd /boot/grub cp stage1 stage2 /media/floppy/boot/grub51Testing软件测试网~$A,d|IJ2C-M

jDy4ry'h p(@4J,P0如果你希望可以用这张软盘启动你的电脑上现有的操作系统,请将/boot/grub/下的menu.lst、device.map两个文件复制到软盘上相应的目录里下。51Testing软件测试网m$HyFX:}'W

51Testing软件测试网#~6U2w!oDG

4.卸载软驱(umount /dev/fd0),进入终端并启动GRUB,并进入GRUB的命令操作模式,你将看到GRUB的命令提示符(grub>),执行下面的命令:51Testing软件测试网I7QQ;^Z9n

device (fd0) /dev/fd0 root (fd0) setup (fd0) quit51Testing软件测试网mB%Ix&d
y:q
51Testing软件测试网yz }yvvK

5.这样,一张GRUB的引导软盘就制作完成了,如果你在第三步中将那两个文件复制到了软盘上面,那用这张软盘启动你的电脑的启动界面和你通过硬盘启动时的界面是一模一样的;51Testing软件测试网-s5Y(U9fn2U4Cu3o7Ii+?

51Testing软件测试网!Q7AX(m3K h*f b

6.为了安全起见,你也可以将当前硬盘上上的引导系统备份到一张软盘上(备份成一个文件),进行这种备份操作前提是你的GRUB是安装在了你的硬盘上。引导程序包含在一个名为boot.mbr的文件。以下为备份操作:51Testing软件测试网%YDqw;W jf h

dd if=/dev/hda ōf=/media/floppy/boot.mbr bs=512 count=1
8i%[Rx/Q-I1oi"e [}A*u0

Kf^*@;sY iQ)V0当你硬盘上的引导程序出现问题时,你可以通过软盘启动,执行下面的命令来进行修复:

e|+B1Fc(Uy7J_0
dd if=/media/floppy/boot.mbr ōf=/dev/hda bs=512 count=151Testing软件测试网Ck/X*|5K6haI
====================================51Testing软件测试网s^IC$W"K'TX1U
相关注释:51Testing软件测试网Y hoOc7a`S

The map between BIOS drives and OS devices

51Testing软件测试网 } ry R1lz Oc1B

When you specify the option--device-map(seeBasic usage), the grub shell creates thedevice map fileautomatically unless it already exists. The file name/boot/grub/device.mapis preferred.

%aikrG g051Testing软件测试网9h5Gb4q:Dj+w ~

If the device map file exists, the grub shell reads it to map BIOS drives to OS devices. This file consists of lines like this:51Testing软件测试网4a$s7^e-C9C

devicefile51Testing软件测试网N(`'}"Xb7{Xov

deviceis a drive specified in the GRUB syntax (seeDevice syntax), andfileis an OS file, which is normally a device file.

,[mP&F\q1P-U0

jHv8h0?'P/c%co0The reason why the grub shell gives you the device map file is that it cannot guess the map between BIOS drives and OS devices correctly in some environments. For example, if you exchange the boot sequence between IDE and SCSI in your BIOS, it gets the order wrong.

(H yD un;y0

Gfydx-{+?q1V0Thus, edit the file if the grub shell makes a mistake. You can put any comments in the file if needed, as the grub shell assumes that a line is just a comment if the first character is `#'.51Testing软件测试网+Gg C1^8cX

13.2.3 device

— Command:devicedrive file
"Q5W#p+Um1TK~D0
51Testing软件测试网`]U"u N!`sO

In the grub shell, specify the filefileas the actual drive for abiosdrivedrive. You can use this command to create a disk image, and/or to fix the drives guessed by GRUB when GRUB fails to determine them correctly, like this:

F1nI V/@j;XI0
grub>device (fd0) /floppy-image
"Ju9o3E,C$wIM0grub>device (hd0) /dev/sd0
S[1X5[#sbU%_0

*X'~%}Qr6{&{8x051Testing软件测试网0Q z+vm[8yk

This command can be used only in the grub shell (seeInvoking the grub shell).51Testing软件测试网7_ ]W8\i$i

==============================================================
V@(rk;?$p0

GNU GRUB Manual 0.97

Table of Contents

/pq9B&{s,}i0Next:, Up:(dir)

e%J5\)|B7}0

GNU GRUB manual

})^!k,m.J t9I;s0This is the documentation of GNU GRUB, the GRand Unified Bootloader, a flexible and powerful boot loader program forpcs.51Testing软件测试网K1S9idl9Ct

51Testing软件测试网 u4p)}#hX:a

This edition documents version 0.97.

$I.VO&p(X4{#KY6`0

rBPL3}y7Z7]0This manual is for GNU GRUB (version 0.97, 8 May 2005).51Testing软件测试网 L|3_Q7hc onI

+|eZ3di0Copyright © 1999,2000,2001,2002,2004,2006 Free Software Foundation, Inc.

"\0HOCp lf0
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, with the Front-Cover Texts being “A GNU Manual,” and with the Back-Cover Texts as in (a) below. A copy of the license is included in the section entitled “GNU Free Documentation License.”51Testing软件测试网0q9]T v Ny

(a) The FSF's Back-Cover Text is: “You have freedom to copy and modify this GNU Manual, like GNU software. Copies published by the Free Software Foundation raise funds for GNU development.”

-[x8A"X4~}s0
参考来源:
0{r8?]'S!d#x[ z0http://www.gnu.org/software/grub/manual/html_node/index.html#Top
z4C` K+x(Y;Gt!h)D0http://www.ubuntulinux.org/wiki/HowToMakeAGRUBBootFloppy51Testing软件测试网Dz p;LW*S6G

TAG: GRUB 启动软盘 Linux系统配置

 

评分:0

我来说两句

Open Toolbar