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

How to carry out the emergency rescue of virtual redhat linux

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

How to carry out the emergency rescue of virtual redhat linux, in view of this problem, this article introduces the corresponding analysis and answer in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.

Because the virtual machine cannot be started, vmware vcenter can no longer monitor the heartbeat of the virtual machine vmware tools. Login VC checks through the virtual machine console and finds that the virtual machine REDHAT Linux card is in the following interface:

From the screenshot:

Show that chmod, chgrp, chown and awk were not found (possibly mistakenly deleted). Because the rc.sysinit script needs to be executed when the system starts, the script will execute some permission control commands, so these files must be used. The system initialization failed because the files could not be found.

After communication, we learned that the customer installed apache and mysql, and modified the / etc/profile file to configure the application's environment variables, resulting in the above problems.

Resolve the problem:

Load the iso of redhat linux to the virtual machine, set the virtual machine bios,CD optical drive as the first boot sequence, restart the virtual machine, and select the rescue mode for emergency rescue.

Because the files are missing, you need to turn on the network function here to facilitate copying related files from other hosts.

Enter the IP and gateway of the virtual machine here

Mount system to sysimage

After clicking OK, enter the repair mode under shell

Then chroot / mnt/sysimage

After entering / bin, we really did not find these commands such as chmod, chown and awk. We can consider copying these files from a good redhat linux system and executing them under the command line.

# scp-r root@11.11.165.177:/usr/bin/* / bin/

As a result, the command was not found, and there should be no client software, resulting in the SCP command not being recognized. Then set up the local yum source and install the openssh client

# yum install openssh-clients

Execute # scp-r root@11.11.165.177:/usr/bin/* / bin/ again, prompt for the password, and start the copy command.

Restart the system after the copy is completed, initialize smoothly and enter the system successfully.

Summary

Rescue repair should pay attention to the relationship between system initial file and system command file, and restore system integrity.

Add another test example:

Modify the files grub.conf and fstab of the linux system. I won't delete them here, just change the name so that the system can't find it.

Bootstrap program (the first 446 bytes of the 512 bytes of the MBR are the bootstrap, followed by the partition table of the next 64 bytes, and the last 2 bytes are the closing mark)

Use the following command to overwrite bootloader (446 words in the boot loader MBR)

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

And then enter rescue mode.

Use fsdisk-l to view the partition

Create a directory in the current directory to mount the root

Mkdir a

Mount / dev/sda2 / a mounts the root directory to a

Mount / dev/sda1 / a/boot mounts the boot directory because it is a separate partition

After the mount is successful, you can see all the system files, and you can repair and modify them.

Restore the files that we modified

The next step is to install the 446-byte bootstrap in MBR

To install grub is to install / boot/grub/stage1. Enter # grub in rescue mode to enter grub command mode.

1. Root (hd0,0) here refers to a partition of the first block, that is, to specify the partition where / boot is located

2. Setup (hd0) here means to install grub. When successed appears, the installation is successful.

3. Quit retreats to shell mode

4. Restart exit

After restart, you will automatically enter the grub > mode. Here, the manual boot system will first take a look at the manual boot system.

Root (hd0,0) specify the location of the kernel file or the partition where the / boot directory is located

Kernel/vmlinuz-2...ro root=/dev/sda2 specific kernel file and mount it as read-only

Initrd/initrd. Specific memory boot image

Boot loading system

As shown below:

After the above operations are completed, enter the system. At this time, the grub.conf of the system has not been restored. You need to go to the directory to restore the system files before the system repair is completed.

Note: the root partition and / boot are preferably partitioned separately, while the other ones are made into LVM volumes, which will be more convenient in rescue mode.

Sometimes the root is read-only and requires mount-o remount rw / to remount the root directory to be read-writable.

This is the answer to the question about how to carry out the emergency rescue of virtual redhat linux. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.

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: 256

*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