It is recommended to save the layout of your devices. sfdisk
supports two ways.
Use the --dump
option to save a description of the device layout
to a text file. The dump format is suitable for later sfdisk
input. For example:
sfdisk --dump /dev/sda > sda.dump
This can later be restored by:
sfdisk /dev/sda < sda.dump
If you want to do a full (binary) backup of all sectors where the
partition table is stored, then use the --backup
option. It
writes the sectors to ~/sfdisk-<device>-<offset>.bak files. The
default name of the backup file can be changed with the
--backup-file
option. The backup files contain only raw data from
the device. Note that the same concept of backup files is used by
wipefs(8). For example:
sfdisk --backup /dev/sda
The GPT header can later be restored by:
dd if=~/sfdisk-sda-0x00000200.bak of=/dev/sda \
seek=$0x00000200 bs=1 conv=notrunc
Note that sfdisk
since version 2.26 no longer provides the -I
option to restore sectors. dd(1) provides all necessary
functionality.