My goal
# backup the server partitions
sfdisk --json /dev/sda > /tmp/sda.json
# at restore time (on rescue boot)
cat /tmp/sda.json \
| my_json_util --size-ratio 0.5 --drop uuid \
| sfdisk-json-to-text \
| sfdisk /dev/$another_disk
sfdisk -d /dev/sda > /tmp/sda.txt
sfdisk /dev/sdNEW < /tmp/sda.txt
sfdisk --json /dev/sda > /tmp/sda.json
It is not supported by sfdisk.
$ man sfdisk | grep -i json | grep input
sfdisk is not able to use JSON as input format.
With lua script
sfdisk-json-to-text.lua < /tmp/sda.json > /tmp/sda.txt
With shell script (require jq
)
sfdisk-json-to-text.sh < /tmp/sda.json > /tmp/sda.txt
sfdisk --json /dev/sda > /tmp/sda.json
# modify the /tmp/sda.json
sfdisk-json-to-text.lua < /tmp/sda.json > /tmp/sda.txt
sfdisk /dev/sdNEW < /tmp/sda.txt