当前位置:Linux教程 - 安装启动 - 安装启动 - 硬盘改变位置之后重新安装GRUB以及修改相应文件的方法

安装启动 - 硬盘改变位置之后重新安装GRUB以及修改相应文件的方法

硬盘改变位置之后重新安装GRUB以及修改相应文件的方法
2004-04-23 15:18 pm
来自:Linux文档
现载:Www.8s8s.coM
地址:无名

修改GRUB(2003-09-22 09:50:49)
By seraphim
Author:Seraphim(张乐奕)
Mail:[email protected]
Date:2003-08
问题描述:
原来系统是装在计算机第二个IDE口上(hdc),mount了另外一块hda到/u01下面。
现在想把这两块硬盘的位置对调一下,hda->hdc,原来的hdc->hda,请问我该如何修改GRUB的配置?
当前硬盘配置和GRUB配置如下所示:
linux:/home/zhangleyi # fdisk -l
Disk /dev/hdc: 10.2 GB, 10262568960 bytes
16 heads, 63 sectors/track, 19885 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Device Boot Start End Blocks Id System
/dev/hdc1 * 1 25 12568+ 83 Linux
/dev/hdc2 26 2522 1258488 82 Linux swap
/dev/hdc3 2523 19885 8750952 83 Linux
Disk /dev/hda: 20.5 GB, 20576747520 bytes
255 heads, 63 sectors/track, 2501 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 2501 20089251 83 Linux
linux:/home/zhangleyi # more /etc/grub.conf
root (hd0,0)
install --stage2=/boot/grub/stage2 /grub/stage1 d (hd0) /grub/stage2 0x8000 (hd0,0)/grub/menu.lst
quit
linux:/home/zhangleyi # more /boot/grub/menu.lst
# Modified by YaST2. Last modification on Sat Aug 2 09:56:00 2003

gfxmenu (hd1,0)/message
color white/blue black/light-gray
default 0
timeout 8
title linux
kernel (hd1,0)/vmlinuz root=/dev/hdc3 vga=791 splash=silent
initrd (hd1,0)/initrd
title floppy
root (fd0)
chainloader +1
title failsafe
kernel (hd1,0)/vmlinuz.shipped root=/dev/hdc3 ide=nodma apm=off acpi=off vga=normal nosmp maxcpus=0 disableapic 3
initrd (hd1,0)/initrd.shipped
linux:/home/zhangleyi #
首先感谢www.linuxsir.com的beyond_2000斑竹的耐心解释,才有了这篇东西的诞生。
其次,对于GRUB的详细解释,可以用info grub得到。
目的:
本来系统安装在hdc上(也就是第二个IDE接口的primary位置上),GRUB装在另一块硬盘hda上,现在想把这两块硬盘位置对调一下。
方法:
首先more /etc/fstab,确认当前有几个独立的文件系统,我的机器情况如下:
/dev/hdc3是/,/dev/hdc1是/boot,/dev/hdc2是swap。
1. 关机,把硬盘的连线从hdc改成hda
2. 用SuSE安装盘的CD1启动计算机
3. 在启动菜单中选择rescue
4. 输入root,不需要密码,进入rescue命令行
5. pwd,可以看到当前目录为/root,退回到/
5. 键入grub,进入grub命令状态
6. find /boot/grub/stage1,该命令用于确认包含boot所需文件的目录,显示hd0,0
7. root (hd0,0)
8. setup (hd0) 显示成功安装GRUB
9. quit,退出grub命令行状态
10. mount /dev/hda1 /tmp (备注:没有该硬盘连线之前是hdc,现在是hda了,该命令将mount原先的/boot分区)
11. mount /dev/hda3 /usr (备注:该命令将mount原先的/分区)
12. vi /tmp/grub/menu.lst,将所有的hd1改为hd0,hdc改成hda,存盘退出
13. vi /usr/etc/fstab, 将所有的hdc改成hda,hda改成hdc,存盘退出
14. 重启计算机,OK