您的位置:首页 > 其它

grub安装

2014-02-11 13:15 375 查看
grub的安装有两种方式:

1、在grub的命令行模式进行安装
[root@Wiker ~]# grubProbing devices toguess BIOS drives. This may take a long time.

GNU GRUB version 0.97 (640K lower / 3072Kupper memory)
[ Minimal BASH-like line editing issupported. For the first word, TAB lists possible command completions. Anywhere else TAB lists the possible completions of a device/filename.]grub> root (hd0,0)root (hd0,0) Filesystem type is ext2fs, partition type 0x83grub> setup (hd0)setup (hd0) Checking if "/boot/grub/stage1"exists... no Checking if "/grub/stage1" exists...yes Checking if "/grub/stage2" exists...yes Checking if "/grub/e2fs_stage1_5"exists... yes Running "embed /grub/e2fs_stage1_5(hd0)"... 27 sectors are embedded.succeeded Running "install /grub/stage1 (hd0)(hd0)1+27 p (hd0,0)/grub/stage2 /grub/grub.conf"... succeededDone.这个方法是可以安装mbr里面的446个字节的内容,不会安装/boot/grub里面的内容,其他的直接复制就可以了,如果连/boot/grub里面的内容都搞丢了的话,可以去/usr/share/grub里面拷贝,里面除了grub.conf没有以为,其他的都有
2、第二种方法:命令行使用grub-install来安装,这种方式分两种情况 1):安装grub到系统所在的硬盘 [root@Wiker ~]#grub-install /dev/sdaInstallationfinished. No error reported.This is the contentsof the device map /boot/grub/device.map.Check if this iscorrect or not. If any of the lines is incorrect,fix it and re-run thescript `grub-install'.
# this device map wasgenerated by anaconda(hd0) /dev/sda 2):安装在服务器上面的第二块硬盘上面,分为三个小步骤 1、给第二块硬盘进行分区[root@Wiker boot]#fdisk -l /dev/sdb
Disk /dev/sdb: 5368MB, 5368709120 bytes255 heads, 63sectors/track, 652 cylindersUnits = cylinders of16065 * 512 = 8225280 bytesSector size(logical/physical): 512 bytes / 512 bytesI/O size(minimum/optimal): 512 bytes / 512 bytesDisk identifier:0x00000000
Disk /dev/sdb doesn'tcontain a valid partition table[root@Wiker boot]#fdisk /dev/sdbDevice containsneither a valid DOS partition table, nor Sun, SGI or OSF disklabelBuilding a new DOSdisklabel with disk identifier 0x8130427e.Changes will remainin memory only, until you decide to write them.After that, ofcourse, the previous content won't be recoverable.
Warning: invalid flag0x0000 of partition table 4 will be corrected by w(rite)
WARNING:DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') andchange display units to sectors (command 'u').
Command (m for help):nCommand action e extended p primary partition (1-4)pPartition number(1-4): 1First cylinder(1-652, default 1): Using default value 1Last cylinder,+cylinders or +size{K,M,G} (1-652, default 652): +100M
Command (m for help):p
Disk /dev/sdb: 5368MB, 5368709120 bytes255 heads, 63sectors/track, 652 cylindersUnits = cylinders of16065 * 512 = 8225280 bytesSector size(logical/physical): 512 bytes / 512 bytesI/O size(minimum/optimal): 512 bytes / 512 bytesDisk identifier:0x8130427e
Device Boot Start End Blocks Id System/dev/sdb1 1 14 112423+ 83 Linux
Command (m for help):wThe partition tablehas been altered!
Calling ioctl() tore-read partition table.Syncing disks.[root@Wiker boot]#partprobe /dev/sdb[root@Wiker boot]#cat /proc/partitions major minor #blocks name
8 0 125829120 sda 8 1 262144 sda1 8 2 79872000 sda2 8 3 524288 sda3 8 16 5242880 sdb8 17 112423 sdb1 253 0 59604992 dm-0 253 1 524288 dm-1[root@Wiker boot]#mkfs.ext4 /dev/sdb1 mke2fs 1.41.12(17-May-2010)Filesystem label=OS type: LinuxBlock size=1024(log=0)Fragment size=1024(log=0)Stride=0 blocks,Stripe width=0 blocks28112 inodes, 112420blocks5621 blocks (5.00%)reserved for the super userFirst data block=1Maximum filesystemblocks=6737100814 block groups8192 blocks pergroup, 8192 fragments per group2008 inodes per groupSuperblock backupsstored on blocks: 8193,24577, 40961, 57345, 73729
Writing inode tables:done Creating journal(4096 blocks): doneWriting superblocksand filesystem accounting information: done
This filesystem willbe automatically checked every 33 mounts or180 days, whichevercomes first. Use tune2fs -c or -i tooverride. 2、创建目录,一定要叫boot,然后把刚才的分区挂载到boot上面[root@Wiker boot]#mkdir /mnt/boot[root@Wiker boot]#mount /dev/sdb1 /mnt/boot/[root@Wiker boot]# cd/mnt/boot/[root@Wiker boot]# lslost+found 3、使用grub-install进行安装,需要制定root-directory目录[root@Wiker boot]#grub-install --root-directory=/mnt/ /dev/sdbProbing devices toguess BIOS drives. This may take a long time.Installationfinished. No error reported.This is the contentsof the device map /mnt//boot/grub/device.map.Check if this iscorrect or not. If any of the lines is incorrect,fix it and re-run thescript `grub-install'.
(fd0) /dev/fd0(hd0) /dev/sda(hd1) /dev/sdb[root@Wiker boot]#pwd/mnt/boot[root@Wiker boot]# lsgrub lost+found[root@Wiker boot]# ls grub/ device.map iso9660_stage1_5 stage1 xfs_stage1_5e2fs_stage1_5 jfs_stage1_5 stage2fat_stage1_5 minix_stage1_5 ufs2_stage1_5ffs_stage1_5 reiserfs_stage1_5 vstafs_stage1_5本文出自 “IT没有圈” 博客,请务必保留此出处http://wiker.blog.51cto.com/8481872/1357973
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: