First, the loss of the hard disk boot stage
1, simulation problems: MBR master boot record is missing
dd if=/dev/zero of=/dev/vda bs=446 count=1 ##破坏MBR,/dev/vda*是本机所在的/boot区
Can not be turned on:
2, the solution:
若是真实主机,则需要插入镜像光驱,并从光驱启动 :若是虚拟机,则添加虚拟光驱,从光驱启动
virt-manager
The following is the operation in the virtual machine:
after she set up, after starting the virtual machine to enter the saving mode:
Then out of order:
CHROOT / mnt / sysimage ## is switched to the real root
location grub2-install / dev / vda ## / dev / vda problem truncated analog / boot consistent
force off (close) the virtual machine, then changed from the disk boot, the system can be restored to normal.
File boot phase problem
1, simulation problem: boot files are missing
(1) boot path to the file: /boot/grub2/grub.cfg
(2) to see the root of the partition where the kernel version and
view the root directory District:
Viewing the kernel version:
(3) Analog problem:
rm -rf /boot/grub2/grub.cfg ##删除引导文件
reboot ##重启系统
Solution:
At the command line, type:
set root='hd0,msdos1'
linux 16 /vmlinuz-3.10.0-514.el7.x86_64 ro root=/dev/mapper/rhel-root ##内核版本制定本机的,位置指定根目录所在分区
initrd16 /initramfs-3.10-514.el7.x86_64.img ##内核版本指定本机的
Note: The above steps are only a temporary change, the next boot will have the same error, so the need to restore access to the system boot files
2, simulation problem: Kernel file is missing
(1) kernel file: /boot/vmlinuz-3.10.0-514. el7.x86_64
(2) simulation problems:
rm -rf /boot/vmlinuz-3.10.0-514.el7.x86_64 ##删除内核文件
Solutions;
enter rescue mode
同上面解决MBR丢失相同的方法
(1) add a virtual drive, boot from the CD:
after the command line:
chroot /mnt/sysimage/ ##切换到真实根目录下
mount /dev/cdrom/media/
cp /media/Packages/kernel-3.10.0-514.el7.x86_64.rpm /mnt/
cd /mnt/
rpm2cpio kernel-3.10.0-514.el7.x86_64.rpm | cpio -id ##从rpm包中提取文件
cd boot/
cp vmlinuz-3.10.0-514.el7.x86_64 /boot/ ##复制缺失的内核文件到/boot/下
force off the virtual machine, change the boot from the disk, you can return to normal
模拟问题:系统初始化镜像文件丢失
(1)系统初始化镜像文件
/boot/initramfs-3.10.0-514.el7.x86_64.img
(2)模拟问题
rm -rf /boot/initranfs-3.10.0-514.el7.x86_64.img
解决方法
进入挽救模式:
在命令行输入:
chroot /mnt/sysimage/
mkinitrd /boot/initramfs-$(uname -r).img $(uname -r)
然后reboot虚拟机即可恢复
#模拟问题:/boot/分区丢失
rm -rf /boot/* ##删除/boot/分区所有文件
解决方法:
进入挽救模式:
同上面解决MBR丢失相同的方法
出现命令行后:
在命令行输入:
chroot /mnt/sysimage
mkdir /boot ##建立boot分区
grub2-install /dev/sda ##启动分区所在的硬盘
mount /dev/cdrom /mnt
rpm -ivh /mnt/Packages/kernel-3.10.0-123.el7.x86_64.rpm --force ##安装内核文件
grub2-mkconfig > /boot/grub2/grub.cfg ##引导文件
exit
exit
退出后强制停止虚拟机,取消cdrom启动,再正常启动即可。
##模拟问题:启动级别被篡改##
错误形成:
ln -s /lib/systemd/system/reboot.target /etc/systemd/system/default.target
启动级别修改,造成一直重复开机操作
解决方案:
开机按上下键停止读秒
按“E”进入编辑模式
Row select kernel boot
linux16 / vmliunz-xxxxxx ro xxxxxxxxxxxxxx
read:
linux16 / vmliunz-xxxxxx ro xxxxxxxxxxxxxx. 5
Ctrl + X activation system
The above operation allows the system to start normally, but is temporary, so access to the system still need to do the following:
The start level linked to graphics
Solution root password forgotten
1. Select the Power System page by e, in order to find the line that starts linux16 to delete the contents of the back ro, ro and changed rw rd.break
Press ctrl + x to enter save mode
2. In the command input interface
chroot /sysroot/ ##从内核模式切换到shell模式
echo westos | passwd --stdin root ##设置密码为westos
touch /.autorelabel ##建立密码认证文件