#ESXI #Centos business server failure how to restore disk

1. Environmental description

There is a centos7 business server, because the operator made a major mistake, which caused the business server to go down. Since there is no backup and snapshot, it cannot be restored. It is considered to re-acquire the data by mounting the hard disk on other virtual machines.

The device environment is ESXI of VMWARE.

2. Repair steps

1. Create a new operating system and mount the corresponding disk (the original business server is shut down)

(slightly)

2. Enter the operating system (remember, the virtual machine cannot be restarted in subsequent operations, otherwise it cannot be started)

Use fdisk -l to check whether the hard disk is queried

fdisk -l

It is found that there are only system disks, but no mounted business server disks

3. Enter the /sys/class/scsi_host directory, and then check

cd /sys/class/scsi_host
fidsk -l

There is still no result, check the files in the current path through ll

ll

Enter the following command to scan all host files

echo "- - -" > host0/scan
fdisk -l
##按顺序输入,直到查询到新加载的盘

 As you can see, there is already a sdb disk

4. Query the UUID of sdb

blkid

Some friends will say that it is enough to modify the /etc/fstab file and mount it in this way. I have tried it, and there will be problems

I modified the file in /etc/fstab and made it effective through mount -a, and an error was reported

 After confirmation, the format of LVM2_member must be mounted through the logical disk

5. View the current lv

lvdisplay

Through the lvdisplay command, you can see two lvs with the same logical disk name, which are the swap, home, and root directories.

 

Since the names of the logical disks are the same, and the three lvs are in the inactive state, the next step is to modify the name of the vg and activate the lv

6. Modify the configuration of vg and lv

Modify the name of vg

vgdisplay

 View the uuid of vg and modify it according to uuid

Determine which is the disk of the business server based on the capacity

vgrename sWlyNW-rY1F-wDw1-s9Ix-BR7n-PcVU-ezPeDq centos_2

Modify the name of vg to centos_2 through vgrename

The modification is complete, view lv through lvscan

lvscan

Activate vg as centos_2's lv

vgchange -ay /dev/centos_2

7. Mount the logical partition

In the /mnt directory, create a tmp directory, and create a home directory and a root directory in the tmp directory

 Enter the root directory and have been able to successfully see the old server files

 8. Black disk problem

During the mounting process, if it is found that vg is mounted directly, an error will be reported and a black disk will be displayed

By adding the -B parameter later, it can be mounted. It means: -B, --bind mount subtrees in other locations (same as -o bind).

mount /dev/centos_2 /mnt/tmp_1 -B

Guess you like

Origin blog.csdn.net/jiuyou91/article/details/128250119