linux system troubleshooting

The system boot process is
powered on > bios initialization > grub2 disk boot phase > grub2 file boot phase > specify the partition where the boot is located > start the kernel, read-only mount the device > start the init program to enter the initialization phase > start the systemctl initialization process > read /etc/systemd / in File>Launch Programs>Launch Login Environment

1. BIOS initialization

1. The basic input/output system (bios) is a fixed interface built into standard x86/x86-64 hardware. Put the hardware in a known state and prepare the system to load. Check and initialize the hardware after problems occur at
this stage, and determine to boot from it. devices, usually pressing F12 can perform a boot sequence override

Second, the disk boot stage

1、MBR

The function of mbr is to upgrade the first 446 bytes of the disk 0 track 1 sector where the partition where the /boot directory is located is only the first 446 bytes of the damaged command: restart the error after damage to repair demo Select the second item to enter Select 1 to enter
dd if=/dev/zero of=/dev/xda bs=446 count=1
write picture description here

write picture description here

Add CD-ROM and boot CD-ROM

write picture description here

write picture description here

write picture description here

write picture description here

write picture description here
chroot /mnt/sysimagerun as root

grub2-install  /dev/vda 

Install grub2 disk boot, enter exit twice to continue booting after installation,
force , cancel the CD-ROM boot in the settings in the virtual machine, boot again,
write picture description here
boot normally
write picture description here

2, grub file boot stage

/boot/grub2/grub.cfg
Boot sequence:
specify the location of the /boot partition,
load the kernel, and
start the system initialization process
write picture description here

[root@localhost ~]# cd /boot/       
[root@localhost boot]# ls
config-3.10.0-123.el7.x86_64    当前内核的配置文件,用于内核编译使用
grub
grub2          里面存放grub引导管理其所必须的配置文件,各种文件系统的驱动文件
initramfs-0-rescue-946cb0e817ea4adb916183df8c4fc817.img
initramfs-3.10.0-123.el7.x86_64.img   当前内核的initrd,即初始化ramdisk文件,里面包含一切启动时候要加载的驱动
initrd-plymouth.img
symvers-3.10.0-123.el7.x86_64.gz   系统设备映射
System.map-3.10.0-123.el7.x86_64
vmlinuz-0-rescue-946cb0e817ea4adb916183df8c4fc817
vmlinuz-3.10.0-123.el7.x86_64  内核文件

Corrupted file rm -fr /boot/grub2/grub.cfg
Reboot interface displays:
write picture description here
Solution
Need to manually enter the boot content of the grub2
write picture description here
file After booting, you need to manually generate the grub.cfg file

[root@localhost ~]# 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

grub2-mkconfig ##The output is the file content of /boot/grub2/grub.cfg
grub2-mkconfig > /boot/grub2/grub.cfg ##Import all the output content into the specified grub2 file for booting, it is not necessary to boot again manual boot

3. The img file is lost

missing files initramfs-3.10.0-123.el7.x86_64.img
boot demo
write picture description here

Repair method:

1. Start the virtual machine from the CD-ROM and select Repair

write picture description here

2. Create a new img file

write picture description here

3. Normal startup

write picture description here

Fourth, the vmlinux file is missing

Example: Delete the vmlinz file After
write picture description here
restart :
write picture description here
Repair method
1. Open the virtual machine from the CD-ROM mode
2. Enter the repair interface
chroot /mnt/sysimage
mount /dev/cdrom /mnt ##Mount cdrom to /mnt
cp /mnt/Packages/ kernel-3.10.0-123.el7.x86_64.rpm /opt/ ##Copy the kernel files in /mnt to any directory
rpm2cpio kernel-3.10.0-327.el7.x86_64.rpm | cpio -id ## After this command is executed, it will be found that there is a boot directory in /opt, and when you enter the boot directory, you will see the required vmlinuz-3.10.0-327.el7.x86_64 file
cp boot/vmlinuz-3.10.0-123.el7.x86_64 /boot ##Copy the new file to the virtual machine under /boot Exit the current interface
twice ,
write picture description here
cancel the CD-ROM drive, and start normally
write picture description here

Five, systemd initialization

enable selinux and systemd-tools
load kernel parameters
load system clock, keyboard, hostname read-
write mounts/filesystems
activate raid , lvm devices
activate system quotas
start all service scripts in multi-user.target.wants
enable virtual console
start graphics

6. Startup level

runlever0.target -> poweroff.target
runlever1.target -> rescue.target
runlever2.target - > multi-user.target runlever3.target ->
multi-user.target runlever4.target -
>
multi-user.target runlever5.target - > grapical.target
runlever6.target -> reboot.target
set boot level
• systemctl set-default + boot level
• /etc/systemd/system/default.target

Damage method:
You can change the default graphical interface to the shutdown interface, and it will be like this
write picture description here
when restarting .
write picture description here
Problem solving:
Problem solving:
1. Press the up and down keys to stop the countdown
2. Press 'E' to enter the editing mode
3. Select the kernel startup line
1.linux16 /vmlinuz-xxxxxx ro xxxxxxxxxxxx
write picture description here

Modified to
2, linux16 /vmlinuz-xxxxxx rw rd.break
write picture description here
3. Start
ctrl +x## Start
4. Enter the command line "`
chroot /sysroot ##Super user
rm -fr /etc/systemd/system/default.target ##Delete the link displayed on the default shutdown interface
ln -s /lib/systemd/system/graphical.target /etc/systemd/system/default.target ##Set the interface of the graphical interface as the default interface
exit ##Exit

![这里写图片描述](https://img-blog.csdn.net/20180501212439407?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MTc4OTAwMw==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70)

七、root用户密码忘记修改方式
================
1.开机按上下键停止读秒
2.按‘E’进入编辑模式
3.选择内核启动行
1、`linux16 /vmlinuz-xxxxxx ro xxxxxxxxxxxx`改为
2、 `linux16 /vmlinuz-xxxxxx rw rd.break`

3. ctrl+xRun
4. Enter the command line

chroot /sysroot
passwd
touch /.autorelabel
exit

If selinux is not enabled, the .autorelabelfile can be created without application
write picture description here

Guess you like

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