Restoring Linux ECS Data
If an ECS fails to start because files were accidentally deleted and the system disk data is lost, you can restore data using another Linux ECS that starts normally or using a snapshot.
Background
During data restoration, the fdisk, TestDisk, and partprobe tools are mainly used.
| Data Restoration Tool | Installed by Default | Difference |
|---|---|---|
| fdisk | Yes | Used for partition management, including routine management and rebuilding. |
| TestDisk | No | Used to restore disk partitions or data, and perform investigation and in-depth repair. It is required when partitions cannot be identified. |
| partprobe | Yes | Used to enable the kernel re-read disk partitions without a restart. It is responsible for updating and validating the information. |
The overall process is to attach the system disk as a common data disk to another available Linux ECS and use data restoration tools to restore data.

Procedure
Preparations
- Stop the ECS. For details, see Stopping ECSs.
- Detach the system disk whose data needs to be restored. For details, see Detaching an EVS Disk.
Wait until the system disk is detached from the ECS and go to the next step.
- Attach the system boot disk of the ECS as a data disk to an available Linux ECS that can start properly. You can select either of the following methods: Method 1: Use another Linux ECS that can start properly.
- Attach the disk detached in 2 to another Linux ECS. For details, see Attaching a Non-Shared Disk. Initialization is not required after the disk is attached.
- Log in to the prepared available Linux ECS.
Method 2: Use a snapshot.- Create a snapshot for the system disk whose data needs to be restored. For details, see Creating an EVS Snapshot.
- Attach the system disk detached in 2 back to the original ECS as the system disk.
- Reinstall the OS on the original ECS. For details, see Reinstalling the OS.
- Create a disk from the snapshot. For details, see Creating a Disk from a Snapshot.
- Wait until operations in 3.c and 3.d are complete. Attach the disk created in 3.d back to the original ECS. For details, see Attaching a Non-Shared Disk.
- Log in to the original Linux ECS
To ensure data security, create a snapshot for the original disk before restoring data. If data cannot be restored using the preceding methods, restore the disk using the snapshot and then use professional data restoration software to restore data.
Restore data
- Run the lsblk and fdisk -lu commands to view disk information. In the following figure, /dev/vdb is the EVS disk whose data needs to be restored. If /dev/vdb1 is displayed, the disk partition information is normal. The disk device name to be restored varies depending on the actual situation.

- Run the mount /dev/vdb1 /mnt command to attach the disk to the /mnt directory.

Run the cd /mnt command to view the data on the system disk of the original ECS. In the corresponding path, find the data to be restored and restore it as required.

- Run the lsblk and fdisk -lu commands again to view the disk information. In the following figure, /dev/vdb is the disk to be restored. However, /dev/vdb1 is not displayed because the partition information is damaged or lost.

- Run the fdisk /dev/vdb command to partition the disk.
If the message "Do you want to remove the signature? [Y]es/[N]o" is displayed during disk partitioning, fdisk has detected an existing partition table.
- If you select No, the existing partition table will be retained. Then, enter w to save the partition table.
- If you select Yes, the existing partition table will be removed and a new partition will be created. Although the data is not overwritten immediately, you may not be able to directly access the original files.

- Run the mount /dev/vdb1 /mnt command to mount the EVS disk to the /mnt mount point.
- In the corresponding path, find the data to be restored and restore it as required.

- Install TestDisk.
- CentOS: sudo yum -y install testdisk
- Ubuntu: sudo apt install -y testdisk

- Go to the TestDisk interface and run the testdisk /dev/vdb command. Replace the device name as required.

On the TestDisk interface, use the arrow keys to select and press Enter to confirm. Other function keys are displayed in the lower part of the interface.
- Select [Proceed] and press Enter.

- Select the type of the partition tables to be scanned. Generally, select [Intel]. For GPT partitions, select [EFI GPT]. Then press Enter.

- Select [Analyse] and press Enter.

- If no partition information is displayed but the message "No partition is bootable" is displayed, select [Quick Search] and press Enter.

After the search is complete, you can view the partition information, as shown in the following figure. The partition is selected by default.

- Select [Write] and press Enter to save the partition.

Press Y to save the partition as instructed.

Retain the default option [OK] and press Enter.

After exiting TestDisk, run partprobe /dev/vdb to update the partition table.

Remount the partition, check the disk data, and find files based on the path.

- Use the arrow keys to select the files or folders to be restored and press C to copy them.

Use the arrow keys to select the target directory. The current path is displayed next to Directory. In this example, the files are restored to the /root directory. Press C in the /root directory.

After the copy is successful, the message "Copy done!" is displayed. The number of files that were successfully copied and those that failed are displayed. If a folder is copied, wait until the copy is complete.

Press Q multiple times until you exit the TestDisk interface. Go to the target path /root and check that the data has been restored.
When you paste the files or folders, the file structure is also copied to the target path. For example, if the root/fake.py file in the original disk file system is successfully copied to the /root directory, the fake.py file path will change to /root/root/fake.py.

If the OS can start properly and only the data disk is deleted by mistake, you can only restore the data as required.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot