Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Solution when failure occurs in CentOS-6 or CentOS-7

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Troubleshooting and configuration of CentOS 6x7 system

Actual inspection report

Experimental project name: CentOS6&7 system troubleshooting and configuration

Class: 0715linux Cloud Computing

Student number: 001

Name: yuan Lei

Instructor: Mr. Wang

Experiment time: 2019-8-21

I.

Experimental purpose

Skillfully master the solutions when CentOS-6 and CentOS-7 break down

2. Content of the experiment

1:centos-7 recovers root password

2:centos-7 grub damage and repair (one way to do it)

3: boot and run in centos-6, and flexibly configure to enter user mode (while entering single-user mode to recover root password)-> e2e space 1 # b

4: encrypt the grub boot menu (password can be set by yourself, based on the grub-md5-crypt command to make it ciphertext)

5:centos-6 mbr destroys it and repairs it (using one method, note that the experiment report must be screenshot)

6:centos-6 grub bootstrapper destroys and repairs (one method is fine)

III. Experimental environment and preparation

Centos-6 virtual machine, one centos-7 virtual machine.

Fourth, experimental analysis and design ideas

(1) centos-7 recovers root password

1. Any key to pause startup at startup

two。 Press the e key to enter edit mode and move the cursor to the line at the beginning of linux16 to add the parameter rw re

Init=/sysroot/bin/sh ctrl+x saves and exits editing

3. Enter the new shell environment and operate chroot / sysroot

4. Change the superuser password

Passwd root

5. Use selinux with activation, exit the current shell and finish it, and restart the system.

Touch /. Autorelabel exit reboot

(2) centos-7 grub is destroyed and repaired.

If the GRUB boot fails, you can reinstall grub in rescue mode as with centos-6.

1. Simulated destruction of the first 446 bytes of the hard disk

Hexdump-C-n 512 / dev/sda View / dev/sda the first 512-byte binary file, shown in hexadecimal code

Dd if=/dev/zero of=/dev/sda bs=1 count=446

Hexdump-C-n 512 / dev/sda has been broken

two。 Restart the computer and use the shell environment in rescue mode to reinstall grub for repair

(1) chroot / mnt/sysimage/

(2) grub2-install / dev/sda

(3) hexdump-C-n 512 / dev/sda to check whether the repair is successful

3. Repair completed, restart verification

Fifth, the main experimental process

(1) centos-7 recovers root password:

1. Any key to pause startup at startup

two。 Press the e key to enter edit mode and move the cursor to the line at the beginning of linux16 to add the parameter re

Init=/sysroot/bin/sh ctrl+x saves and exits editing

3. Enter the new shell environment and operate chroot / sysroot

4. Change the superuser password

Passwd root

5. Use selinux with activation, exit the current shell and finish it, and restart the system.

Touch /. Autorelabel exit reboot

(2) centos-7 grub damage and repair:

1. Simulate and destroy the first 446 bytes of the hard disk

View the first 512-byte binary file of / dev/sda and show it in hexadecimal code

2 、 dd if=/dev/zero of=/dev/sda bs=1 count=446

Grub has been broken.

4. Enter the bios firmware and start with CD-ROM as the first choice

5. Select the Troubleshooting option

8. Select the second rescue mode (Rescue a CentOS system)

9. Option 1) continue

10. Restart the computer and use the shell environment in rescue mode to reinstall grub for repair

Exit the bash environment, enter the shell environment, shut down and restart, and restore the boot entry to its original state

(3) run on centos-6 and flexibly configure to enter user mode (and at the same time enter single-user mode to recover root password

1. Press any key to pause, then press e to enter edit mode (GRUB mode)

two。 Select the second option and press e to enter kernel mode (kernel / vmlinuz-xxx.xxx)

3. Press 1 in the space, return to the previous level, press the b key, restart the host and enter single-user mode.

4. Enter passwd to change the password and restart takes effect (log in to the root& password first)

(4) centos-7 mbr damage and repair

1. Create a new disk sdb + 2G, create a new partition sdb1 + 20m, format a new partition sdb1, mount the partition to / backup

two。 Back up the first 512 bytes of mbr to the new partition sdb1

3. Destroy the first 512 bytes of mbr and view the result of the damage

4. Shut down the computer and enter bios. Select CD-ROM as the first startup item.

5. Restart the system to enter the shell environment in rescue mode

6. Copy the sda.mbr.bak files back in the shell environment in rescue mode, restart will take effect, and restore the boot to its original state

(5) centos-6 grub bootstrapper is destroyed and repaired.

1. Create a new disk sdb + 2G, create a new partition sdb1 + 32m, format a new partition sdb1, mount the partition to / backup

two。 Back up the first 446 bytes of grub to the new partition sdb1

3. Destroy the first 446 bytes of grub and view the result of the damage

4. Shut down the computer and enter bios, select CD-ROM as the second startup item

5. Restart the system to enter the shell environment in rescue mode, as in (4) .5

6. Copy the sda.grub.bak files back in the shell environment in rescue mode, restart will take effect, and restore the boot

(6) encrypt the grub boot menu

1. Enter the grub-md5-crypt command to encrypt the grub bootstrapper

two。 Enter vim editing mode, path / boot/grub/grub.conf

3.rebootmusic-> > restart the host to verify whether the password is valid.

VI. Experimental results and analysis

1. Centos-7 recovery root password and centos-6 grub boot menu encryption experiment is successful, mainly remember the operation steps and commands

2. Successful destruction and recovery experiments of centos6 / 7 grub and mrb, how to backup mbr and grub files in real shell environment and how to restore configuration of mbr and grub files in virtual shell environment and how to enter system rescue mode in two disks

3. Centos-6 single user recovers root password, same as 1

VII. Summary

In this experiment, the process of the experiment is not very smooth, and the correct results are made many times. The key of this experiment is how to do the backup of mbr and grub files in the real shell environment and the configuration of the virtual shell environment mbr and grub recovery files in the two disks, and how to enter the system rescue mode (key point). Centos-6 encrypts the grup boot menu and centos-7 to recover the root password is relatively simple. As long as we remember the experimental steps and commands, we can basically produce results. Through these large and small experiments, we have exercised our ability to discover, analyze and solve problems, and have a more comprehensive and in-depth understanding of the Linux system.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report