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

What is the method to deal with the partition loss of Linux data disk

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article analyzes "what is the way to deal with the partition loss of Linux data disk". The content is detailed and easy to understand, "what is the way to deal with the loss of Linux data disk partition?" interested friends can follow the editor's train of thought to read it slowly and deeply. I hope it will be helpful to everyone after reading. Let's follow the editor to learn more about "what is the way to deal with the loss of partitions on Linux data disks".

When dealing with disk-related problems, you may encounter a loss of data disk partitions in the operating system. The following describes the common problem of partition loss of data disk under Linux system and the corresponding treatment methods, and provides common misunderstandings and best practices of using cloud disk to avoid the risk of possible data loss.

prerequisite

Before you can repair the data, you must first create a snapshot of the missing data disk of the partition, and then try to repair it after the snapshot is created. If there is a problem during the repair process, you can restore the data disk to the state it was before the repair by rolling back the snapshot.

Background information

In a Linux instance, you can choose any of the following tools to repair disk partitions and restore data:

The partition tool installed by default on the fdisk:Linux system.

Testdisk: mainly used to recover disk partitions or data of Linux systems. The Linux system is not installed by default, so you need to install this software yourself. For example, on a CentOS system, you can run yum install-y testdisk online installation.

Tools installed by default on the partprobe:Linux system. It is mainly used to let kernel read the partition again when the system is not rebooted.

Data recovery method

In a Linux instance, data disk partition loss or data loss may occur after you restart the system. This may be because you did not set up automatic mounting in the etc/fstab file. At this point, you can manually mount the data disk partition. If you lose the manual mount of the Times partition table, you can try the following three ways:

Restore a partition through fdisk

Restore a partition through testdisk

Restore data directly through testdisk

Restore a partition through fdisk

When partitioning a data disk, the start and end sectors of the partition disk generally use the default value, so you can first try to directly use the fdisk command to create a new partition for recovery.

If the above does not work, you can use the testdisk tool to try to fix it.

Restore a partition through testdisk

It is assumed that the device name of the cloud disk is / dev/xvdb. Follow these steps to restore the partition using the testdisk tool:

Run testdisk / dev/xvdb (replace the device name according to the actual situation), then select Proceed (default) and press enter.

Select the partition table type to scan: generally choose Intel (default). If your data disk is partitioned with GPT, select EFI GPT.

Press enter after selecting Analyse.

If you do not see any partition information, select Quick Search and press enter to quickly search.

The partition information is displayed in the returned results, as shown in the following figure.

With the partition selected, press enter.

Select Write to save the partition.

If it is not the partition you need, you can choose Deeper Search to continue the search.

Press Y to confirm that the partition is saved.

Run partprobe / dev/xvdb (replace the device name according to the actual situation) to manually refresh the partition table.

Remount the partition to check the data on the data disk.

Restore data directly through testdisk

In some cases, you can scan out the disk partition with testdisk, but the partition cannot be saved, and you can try to recover the file directly. The specific steps are as follows:

Scan the disk partition with testdisk.

Press the P key to list the files.

The result is as shown in the following figure.

Select the file you want to restore, and then press C.

Select the destination directory. In this example, restore to / home is an example.

If you see Copy done! 1 ok, 0 failed, the replication is successful, as shown in the following figure.

Change to the / home directory to view.

If you can see the file, the file was restored successfully.

Common misunderstandings and best practices

Data is the core asset of users, and many users build websites and self-built databases (MYSQL/MongoDB/Redis) on ECS instances. Data loss will bring great risk to users' business. This section describes common misunderstandings and best practices in data security.

Common misunderstandings

Aliyun's underlying storage is based on three copies, so some users believe that there is no risk of data loss in the operating system. Actually, this is a misunderstanding. The three copies of the underlying storage provide physical layer protection to the data disk, but data loss may occur if there are logical problems with the use of cloud disk within the system, such as poisoning, mistakenly deleting data, corrupted file system and so on. At this point, you need to maximize the security of your data through snapshots, remote backup and other related technologies.

Best practic

Data disk partition recovery and data recovery are the last line of defense to deal with data loss, but they may not be able to recover data. It is strongly recommended that you refer to the following best practices to maximize the security of your data by creating snapshots of the data (automatic or manual) and various backup scenarios.

System upgrade kernel

Apply upgrade changes

Disk data recovery

Enable automatic snapshot

According to the actual business, create automatic snapshots of system disk and data disk. Note that automatic snapshots may be released when the system disk is replaced, after the instance expires, or when the disk is released manually.

You can select automatic snapshot release with the disk on the ECS console by modifying the disk properties. If you want to keep automatic snapshots, you can remove this option manually.

Create a manual snapshot

Manually create a snapshot of the disk before doing the following important or risky actions. For example:

When restoring the disk, be sure to create a snapshot of the disk first, and do the appropriate action after the snapshot is completed.

OSS, offline, remote backup

You can use OSS, offline, remote and other methods to back up important data as appropriate.

About the Linux data disk partition lost processing method is shared here, I hope that the above content can make you improve. If you want to learn more knowledge, please pay more attention to the editor's updates. Thank you for following the website!

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

*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

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report