When you troubleshoot disks, you may encounter the loss of data disk partitions. This topic describes data disk partition loss in Linux and the solutions. This topic also describes the common mistakes and best practices for using disks to avoid the risk of data loss.
Prerequisites
- A snapshot is created for the data disk that lost a partition. If errors occur during data restoration, you can use the snapshot to roll back the data disk to the state before the restoration. For more information, see Create a normal snapshot and Roll back a disk by using a snapshot.
- An Alibaba Cloud account is created. To create an Alibaba Cloud account, go to the Alibaba Cloud official website.
Background information
- fdisk: a tool provided by Linux for partitioning disks.
- testdisk: a tool used to restore disk partitions or data in Linux. By default, the tool is not provided in Linux. You must install it on your own. For example, you can run the yum install -y testdisk command to install testdisk in CentOS.
- partprobe: a tool provided by Linux. The tool is used to enable the kernel to re-read partitions without restarting the system.
Methods
Restore a partition by using fdisk

If the preceding operation cannot restore the partition, you can use testdisk to restore the partition.
Restore a partition by using testdisk
A disk device named /dev/xvdb is used in this example. To use testdisk to restore a partition, follow these steps:
Restore data by using testdisk
In some cases, you can scan and locate a disk partition by using testdisk. However, you cannot save the partition. In this case, you can directly restore the data. Follow these steps:
Common mistakes and best practices
Data is the core asset of users. A large number of users build websites and databases such as MySQL, MongoDB, and Redis on ECS instances. Data loss may cause huge risks to businesses. This section describes the common mistakes and best practices in data security.
- Common mistakes
The underlying storage of Alibaba Cloud is based on triplicate technology. Therefore, some users consider that no risk of data loss in the operating system exists. This is a misunderstanding. The three copies of data stored in the underlying layer provide physical layer protection for data disks. However, if errors occur to the cloud disk logic in the system, such as infection with viruses, accidental data deletion, and file system damage, the data may still be lost. You must use technologies such as snapshots and geo-redundancy to ensure data security. For more information about three copies, see Triplicate storage.
- Best practices
Data disk partition restoration and data restoration are the final solutions to data loss problems, but they may not restore data as expected. We recommend that you follow the best practices to create automatic or manual snapshots for data and run different backup schemes to maximize your data security.
- Apply automatic snapshot policies
Automatic snapshot policies are applied to system and data disks to create automatic snapshots for the disks. Note that after the system disk is replaced, the instance expires, or the disk is manually released, the corresponding automatic snapshots may be released.
If you want automatic snapshots of a disk to be released along with the disk, you can select Delete Automatic Snapshots While Releasing Disk in the Modify Disk Property dialog box in the ECS console. If you want to retain the automatic snapshots, you can clear this option.
For more information, see Snapshot FAQ and Create an automatic snapshot policy.
- Create manual snapshots
Before you perform important or high-risk operations, you must manually create snapshots for the disk. These operations include:
- Update the kernel.
- Upgrade or change applications.
- Restore data on disks.
Before you restore a disk, you must create a snapshot for the disk. After the snapshot is created, you can perform other operations.
- OSS backup, offline backup, and geo-redundancy
You can back up important data by using OSS backup, offline backup, or geo-redundancy.
- Apply automatic snapshot policies