System Error Removal in Linux

1. Hard Disk Boot Phase

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

chroot /mnt/sysimage
grub2-install The hard disk where the boot partition is located
grub2-install /dev/vda
exit
exit

2. File boot phase

1. Loss of boot file
Simulation problem: rm-fr/boot/grub2/grub.cfg
When the system is not restarted

grub2-mkconfig > /boot/grub2/grub.cfg


When the system restarts

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

grub2-mkconfig > /boot/grub2/grub.cfg

2. Loss of Kernel Files
Simulation problems: rm-fr/boot/vmlinuz-3.10.0-123.el.x86_64
Solve:
Enter rescue mode

chroot /mnt/sysimage
mkdir /rhel7
mount /dev/sr0 /rhel7
cd /rhel7/Packages
cp kernel-3.10.0-123.el7.x86_64.rpm /mnt
cd /mnt
rpm2cpio kernel-3.10.0-123.el7.x86_64.rpm | cpio -id
cd boot
cp vmlinuz-3.10.0-123.el7.x86_64 /boot
exit
exit


Start the virtual machine in normal mode
3. Initial Mirror File Loss
Simulation problems: rm-fr/boot/initramfs-3.10.0-123.el7.x86_64.img
When the system is not restarted

mkinitrd /boot/initramfs-$(uname -r).img $(uname -r)


When the system restarts
Enter rescue mode

chroot /mnt/sysimage
mkinitrd /boot/initramfs-$(uname -r).img $(uname -r)
exit
exit


Enter normal mode to start virtual machine
4. When / boot partition is deleted
Enter rescue mode

chroot /mnt/sysimage
mkdir /boot
grub2-install /dev/vda
mount /dev/sr0 /mnt
rpm -ivh /mnt/Packages/kernel-3.10.0-123.el7.x86_64.rpm --force
grub2-mkconfig > /boot/grub2/grub.cfg

3. When boot-up level is tampered with

Simulation problem: system CTL set-default reboot.target
Solve:

1).Boot up and press the upper and lower buttons to stop reading seconds
2).Press e edit
3).Select the kernel startup line
linux16 /vmlinuz-xxxxx ro xxxxx Changed to:
linux16 /vmlunuz-xxxxx rw rd.break
4).ctel+x
5).chroot /sysroot
6).rm -fr /etc/systemd/system/default.target
7).ln -s /lib/systemd/system/graphical.target /etc/systemd/system/default.target
8).exit
9).exit

Tags: RPM

Posted on Thu, 10 Oct 2019 07:50:54 -0700 by luv2sd