Skip to content

tst2005sh/sfdisk-json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

partition table utility

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

export to text

sfdisk -d /dev/sda > /tmp/sda.txt

import from text

sfdisk /dev/sdNEW < /tmp/sda.txt

export to json

sfdisk --json /dev/sda > /tmp/sda.json

import from json

It is not supported by sfdisk.

$ man sfdisk | grep -i json | grep input                          
              sfdisk is not able to use JSON as input format.

convert json to text

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

Summary

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published