Data Recovery Process of mv root partition due to misoperations
Misoperation recovery records (how to mount lvm volumes on other hard disks)
Production Environment CentOS7
Misoperation Process
Run the mv */mysql_back command because the database files automatically backed up by mysql are moved to the corresponding folder. However, when the command is executed, the path is/root directory, causing the system to move all the system files to the/mysqlbak folder, and the system crashes, in addition to the bash built-in command cd, the/usr/bin system commands such as ls cannot be found.
Recovery ideas
- The VM on the hard disk cannot be started after the system is restarted.
- The data on the hard disk is only moved to the/mysqlbak folder by mv, and should not be deleted
- It needs to be started through the linux System in the media (CD or USB flash disk) (in non-rescue mode, the rescue cannot re-organize the file structure of the entire operating system, and may cause data loss)
- Attach the hard disk to the micro-Linux system started on the CD and copy it from the network.
Configure the linux environment on the CD
Start with the CD and choose to install Centos7
After selecting the language, go to the installation and configuration page, do not configure the hard disk, only configure the network (convenient to copy data through the network)
Configure the IP address to ensure that the machine that receives the data can be accessed.
Check the file system on the old hard disk. The default value is LVM.
Press Ctrl + Alt + Win + F2 to switch to the Linux background Terminal interface of the installation CD.
By viewing the/dev/mapper and mount commands, we can see that the linux System of the CD does not automatically identify and load the hard disk lvm, /dev/mapper only contains the lvm logical volume of the disc starting with live.
Through the pvscan lvscan vgscan command, we can see that the lvm volume group can be retrieved, but the current status is inactive. to activate the lvm volume group, see: Moving a volume group to another system.
I do not know how to paste a Virtual Machine Simulation Environment
Execute the command to activate the lvm volume group and use lvscan to check that the logical volume is active. Check that/dev/has an additional centos directory, and the root logical volume of the old hard disk also appears.
Production can be seen in/dev/mapper.
Lvm volume group attached to the old hard disk
Use the-o ro parameter to access hard disk data in read-only mode to avoid data loss.
Check the integrity of old data and migrate old data
You can see that the mv command moves most of the data to the/mysqlbak directory, and some of the data files may not be lost due to permission or shutdown, but may be damaged.
Check whether the data files to be copied are transferred to the new environment through scp or sftp, and import the new machine to check whether the test data is complete.
Migrate old mysql database files to new machines
Refer to MySQL database migration
/Var/lib/mysql All files (except ib_logfile * and *. err) to the/var/lib/mysql/folder under the new machine
Pay attention to modifying permissions. Otherwise, it will fail to be started.
chown -R mysql:mysql /var/lib/mysql/*
This article permanently updates the link address: