Backup and restore partition table

Posted by Xiping Hu on April 1, 2023

To backup /dev/sda partition table, enter:

1
sfdisk -d /dev/sda > sda.partition.table.12-30-2015.txt

To restore:

1
sfdisk -f /dev/sda < sda.partition.table.12-30-2015.txt

To change the part UUID of the first partition of sdc:

1
sgdisk -u 1:BC87D91A-02F3-4C52-87CD-536A3DF2A074 /dev/sdc

To change UUID of FAT32 partition:

1
mkdosfs -i ABCD1234 /dev/sdc1

References

https://www.cyberciti.biz/faq/linux-backup-restore-a-partition-table-with-sfdisk-command/