grup修复与安装操作介绍

一、bgru Stage1的安装

    1、stage1存储在MBR的前446字节,首先破坏。使用dd命令

blob.png

    2、使用grub-install命令安装修复grub stage1

blob.png

    3、使用grub命令修复

blob.png


二、进入救援模式,修改grub

    1、先破坏grub stage

blob.png

 重启后无法正常开机

blob.png

    2、使用安装光盘,进入修改模式

blob.png

blob.png

blob.png

blob.png


三、为现有的linux添一个磁盘,并安装grub,完成把此磁盘从此linux虚拟机移除,创建新的虚拟机使用此磁盘

    添加磁盘

blob.png

    成功添加磁盘,并完成分区及格式化操作

blob.png

blob.png

       在/mnt目录下创建boot子目录,并挂载到/dev/sdb1,创建testroot 子目录,并挂载到/dev/sdb3

[root@localhost ~]# mkdir /mnt/{boot,testroot}
[root@localhost ~]# mount /dev/sdb1 /mnt/boot/
[root@localhost ~]# mount /dev/sdb3 /mnt/testroot
[root@localhost ~]#

    安装grub到/mnt/boot目录下

[root@localhost ~]# grub-install --root-directory=/mnt /dev/sdb    //这里的--root-directory=/mnt是boot的父目录
Probing devices to guess BIOS drives. This may take a long time.
Installation finished. No error reported.
This is the contents of the device map /mnt/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'.
 
(fd0)	/dev/fd0
(hd0)	/dev/sda
(hd1)	/dev/sdb
[root@localhost ~]#

    完成安装

blob.png

把内核及initramfs复制到/mnt/boo目录下,并命名为vmlinuz及initramfs,以及创建grub.conf配置文件

blob.png

    在/dev/sdb3上创建完整的根目录、复制/bin/bash及/bin/bash的库文件到/mnt/testroot/下相应的位置

[root@localhost /]# mkdir /mnt/testroot/{bin,dev,home,lib64,media,opt,root,sys,usr,etc,lib,mnt,proc,sbin,srv,tmp,var}
[root@localhost /]# ls /mnt/testroot/
bin  etc   lib    lost+found  mnt  proc  sbin  sys  usr
dev  home  lib64  media       opt  root  srv   tmp  var
[root@localhost /]# cp /bin/bash /mnt/testroot/bin/
[root@localhost /]# ldd /bin/bash 
	linux-vdso.so.1 =>  (0x00007fff2a841000)
	libtinfo.so.5 => /lib64/libtinfo.so.5 (0x0000003f58800000)
	libdl.so.2 => /lib64/libdl.so.2 (0x0000003f4dc00000)
	libc.so.6 => /lib64/libc.so.6 (0x0000003f4e000000)
	/lib64/ld-linux-x86-64.so.2 (0x0000003f4d800000)
[root@localhost /]# cp /lib64/libtinfo.so.5 /mnt/testroot/lib64/
[root@localhost /]# cp /lib64/libdl.so.2  /mnt/testroot/lib64/
[root@localhost /]# cp /lib64/libc.so.6  /mnt/testroot/lib64/
[root@localhost /]# cp /lib64/ld-linux-x86-64.so.2 /mnt/testroot/lib64/
[root@localhost /]#

创建新的虚拟机,并使用/dev/sdb这个磁盘

blob.png

    完成后重启便可进入系统 

blob.png


原创文章,作者:Net20-deamon,如若转载,请注明出处:http://www.178linux.com/17523

(0)
Net20-deamonNet20-deamon
上一篇 2016-06-03
下一篇 2016-06-04

相关推荐

  • 第四周博客作业

    1、复制/etc/skel目录为/home/tuser1,要求/home/tuser1及其内部文件的属组和其它用户均没有任何访问权限。 ~]# cp -r /etc/skel /home/tuser1 ]# chmod -R 700 /home/tuser1/ 2、编辑/etc/group文件,添加组hadoop ~]# echo "hadoop:…

    Linux干货 2016-12-14
  • 磁盘管理

    1、创建一个10G分区,并格式为ext4文件系统。 (1)虚拟机添加21G硬盘 Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors Units = sectors of 1&nbsp…

    Linux干货 2016-12-18
  • 计算机的组成及其功能

        计算机是一种能接受和存储信息,并按照存储在其内部的程序对输入的信息进行加工、处理,然后把处理结果输出的高度自动化的电子设备。计算机是由运算器,控制器,存储器,输入装置和输出装置五大部件组成,每一部件分别按要求执行特定的基本功能。如下图所示: (1)  运算器或称算术逻辑单元(Arithmetical and Logica…

    Linux干货 2016-10-30
  • FHS文档系统各目录功能

         /bin 所有用户可用的基本命令程序文件     /sbin   供系统管理使用的工具程序     /boot 引导加载器必须用到的各静态文件 kernel,initramfs,grub  &nbsp…

    Linux干货 2016-10-18
  • 计算机;GPL等开源协议;Linux 哲学思想的炼成;MBR & GPT—fazion in magedu 20.July

    入门Linux的基础知识 fazionlan blog in 178Linux.July 22nd. 第一台计算机 1946第一台计算机ENIAC(electronic numerical integrator and calculator)在美国滨州大学诞生,是美国奥伯丁武器试验场为了满足计算弹道而研制的 冯诺依曼体系结构:1946年数学家提出运算器、控制…

    Linux干货 2016-07-29
  • N26-博客作业-week7

    1、创建一个10G分区,并格式为ext4文件系统;      (1) 要求其block大小为2048, 预留空间百分比为2, 卷标为MYDATA, 默认挂载属性包含acl;     ~]# fdisk /dev/sda Welcome to fdisk (util-li…

    Linux干货 2017-03-19

评论列表(1条)

  • nice_neo_linux
    nice_neo_linux 2016-06-03 16:45

    可以教教我怎么简单排版这样的博客吗?