Lubos Rendek

The only solution is determination.

Save and Recover Disk Partition Table and Geometry With Sfdisk

| Comments

Before you start play with your brand new hard-disk it is a good idea to same some specs regarding its original partitioning and geometry alignment. The tool which comes handy in this case is sfdisk. Let’s take a partitioning and geometry alignment of /dev/sdb block device:

1
2
# sfdisk -g /dev/sdb
/dev/sdb: 21269 cylinders, 35 heads, 21 sectors/track

Now, save partition table:

1
2
3
4
5
6
7
8
9
# sfdisk -d /dev/sdb > partition.txt
# cat partition.txt
# partition table of /dev/sdb
unit: sectors

/dev/sdb1 : start=       21, size=  6836214, Id= 7
/dev/sdb2 : start=        0, size=        0, Id= 0
/dev/sdb3 : start=        0, size=        0, Id= 0
/dev/sdb4 : start=        0, size=        0, Id= 0

To restore your disk geometry and partition run a following command:

1
sfdisk -C 21269 -H 35 -S 21 --force /dev/sdb < partition.txt

All done. Make sure to create a new filesystem!

Comments