The partition table on a Linux system can be backed up and restored using various tools and methods. Here’s one way to do it using the “sfdisk” command:
To backup the partition table:
- Open a terminal and log in as root or with superuser privileges.
- Run the following command to backup the partition table of the specified disk (replace “device” with the name of your disk, such as “/dev/sda”):
sfdisk -d /dev/device > partition_table_backup.txt
This will create a backup of the partition table in the form of a text file named “partition_table_backup.txt”.
To restore the partition table:
- Open a terminal and log in as root or with superuser privileges.
- Run the following command to restore the partition table from the backup file (replace “device” with the name of your disk, such as “/dev/sda”):
sfdisk /dev/device < partition_table_backup.txt
This will restore the partition table to the state it was in when the backup was created.
Note: Before restoring the partition table, it’s important to make sure that the disk is not in use and that there is no data on the disk that you need to keep, as restoring the partition table will erase all data on the disk.
Also, keep in mind that the above method assumes that the partition table is not corrupted. If the partition table is corrupted, it may not be possible to restore it using this method. In such cases, you may need to use other tools and methods to recover the data or repair the partition table.