(19) System troubleshooting

System troubleshooting

1. The MBR dominant partition is damaged

 1. The dominant partition of the virtual machine can be overwritten

   dd if=/dev/zero of=/dev/vda bs=446 count=1


   The system will not be able to boot normally


 2. Add an optical drive according to the virtual machine version (for example, the system optical drive of 7.0 is an image of version 7.0)



 3. Select the repair option in the boot mode ##Note: CD-ROM boot

   After entering the system, open the shell chroot /mnt/sysimage
   to view the partition where the boot program is located df

   Install the program that dominates the partition grub2-install /dev/xda



   After the installation is complete, boot with the virtual hard disk drive (note the image version, the installation steps are different for different versions)
   
2. The file boot is damaged

  1. The boot file of the boot partition /boot/grub2/grub.cfg The
   boot file specifies the location of the boor partition ;load kernel;start system initialization process  
set root='hd0,msdos1'
linux16 /boot/vmlinuz-3.10.0-123.el7.x86_64 ro root=/dev/vda1

initrd16 /boot/initramfs-3.10.0-123.el7.x86_64.img



  2. If you delete it accidentally, you can automatically create  
   grub2-mkconfig with the command > /boot/grub2/grub.cfg
[root@localhost grub2]# grub2-mkconfig > /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-123.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-123.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue -946cb0e817ea4adb916183df8c4fc817
Found initrd image: /boot/initramfs-0-rescue-946cb0e817ea4adb916183df8c4fc817.img

done


 

  3. If the system does not have this file ( rm -fr /boot/grub2/grub.cfg manually delete the file) , it must be manually booted at startup

(Note: In this experiment, restart the virtual machine to boot directly from the hard disk, not from the CD-ROM)

grub > set root='hd0,msdos1'
grub > linux16 /boot/vmlinuz-3.10.0-123.el7.x86_64 ro root=/dev/vda1

grub > initrd16 /boot/initramfs-3.10.0-123.el7.x86_64.img

grub > boot





三、内核引导文件损坏  vmlinuz

(手动删除内核引导文件)


  1.内核引导文件vmlinuz
    检测硬件设备;设备驱动初始化;将/只读挂载;载入初始进程 systemd
  2.内核文件损坏,则无法正常开机,须重新安装内核软件
  3.开机模式中选择修复选项  ##注意:光驱启动
    进入系统后,打开shell  chroot  /mnt/sysimage
    挂载光驱  mount /dev/sr0  /mnt
    将光驱中内核软件拷贝至指定目录下
    mkdir /kernel

    cp /mnt/Packages/kernel-3.10.0-123.el7.x86_64.rpm /kernel


    解开kernel,得到所需的内核引导软件
    rpm2cpio  kernel-3.10.0-123.el7.x86_64.rpm | cpio -id
    cp ./boot/vmlinuz-3.10.0-123.el7.x86_64  /boot

    查看/boot分区文件是否完整,ok后以虚拟硬盘驱动开机即可



四、img文件损坏
   

  1.若不小心删除,可通过命令自动创建


  2.img文件损坏后,无法正常开机,须重新建立img文件

  3.开机模式中选择修复选项  ##注意:光驱启动
    进入系统后,打开shell  chroot  /mnt/sysimage
    在/boot目录下自动建立文件  mkinitrd /boot/initramfs-`uname -r`.img `uname -r`

    ##uname -r 系统内核版本:3.10.0-123.el7.x86_64



    查看/boot分区文件是否完整,ok后以虚拟硬盘驱动开机即可

五、systemd初始化
 
  1.systemd初始化目录 /etc/systemd/system/multi-user.target.wants/
    开启selinux和systemd-tools;加载内核参数;加载系统时钟,键盘,主机名称
    读写挂载/文件系统;激活raid,lvm设备;激活系统配额;
    启动/etc/systemd/system/multi-user.target.wants/中所有脚本
    启用虚拟控台;启动图形;

  2.若系统故障,开机自动关机
    重启时按上下键,停止系统引导
    开机时按e,在内核引导时设置图形化界面开启
    正常开启后,修改systemd初始化默认参数,即可修复
    systemctl set-default graphical.target

六、root用户密码修改
 
   ###root用户密码被更改或忘记
   1.重启时按上下键,停止系统引导
   2.按e,在内核引导时找到指定行linux16,从最后往前删除至ro
    修改ro=rw rd.break

   3.ctrl + x 启动修改设定后的系统引导


   4.进入系统后切换到真实系统环境,修改root密码
    chroot /sysroot
    passwd
   5.建立文件 /.autorelabel
    ##当selinux关闭时,可不建立该文件;但当selinux开启时,必须建立该文件
    建议:重启时默认执行此命令

   6.输入2次exit退出、重新启动


















Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325468175&siteId=291194637