gpart restore is different to gpart backup
wblock at wonkity.com
Tue Feb 4 18:59:33 UTC 2014
On Tue, 4 Feb 2014, Chris Whitehouse wrote:
> I have two disks, one with a Windows 7 installation which includes a recovery
> partition. I saved the recovery partition with Clonezilla and then attempted
> to duplicate the partition scheme with gpart backup and restore.
> The original Win7 disk is 160gb, the replacement is 120gb.
> Booting from FreeBSD 10 usb flash drive I did
> # gpart backup ada0 > /mnt/gpart_backup_ada0.txt
> Next I created gpart_restore_ada0.txt from gpart_backup_ada0.txt with the
> size of the last partition reduced to allow for the size difference between
> the disks.
> I swapped disks and did the following
> Script started on Tue Feb 4 17:03:38 2014
> root@:~ # gpart show ada0
> gpart: No such geom: ada0.
> root@:~ # cat /mnt/gpart_show_ada0.txt ## this is the Win7 setup.
> => 63 312581745 ada0 MBR (149G)
> 63 1985 - free - (993K)
> 2048 25165824 1 !39 (12G)
> 25167872 204800 2 ntfs [active] (100M)
> 25372672 287205376 3 ntfs (137G)
> 312578048 3760 - free - (1.8M)
This is a standard Windows setup. The !39 partition starts at block
2048, or 1M. This is a good spot to start the first data partition for
a number of reasons: 4K disks, SSDs, RAID controller metadata.
> root@:~ # cat /mnt/gpart_restore_ada0.txt
> MBR 4
> 1 !39 2048 25165824
> 2 ntfs 25167872 204800 [active]
> 3 ntfs 25372672 209068913
> root@:~ # gpart restore ada0 < /mnt/gpart_restore_ada0.txt
> root@:~ # gpart show ada0 ## this is the restored setup.
> => 63 234441585 ada0 MBR (112G)
> 63 2016 - free - (1.0M)
> 2079 25165791 1 !39 (12G)
> 25167870 63 - free - (32K)
> 25167933 204687 2 ntfs [active] (100M)
> 25372620 63 - free - (32K)
> 25372683 209068902 3 ntfs (100G)
> 234441585 63 - free - (32K)
The MBR standard says that partitions should start on even multiples of
CHS values. 2079 is an even multiple of the standard 63 blocks per
track (S) value. At present, gpart uses kernel routines that enforce
the CHS standards when writing an MBR, and there is no way to override
that (and no warning message). There is a PR for this:
http://www.freebsd.org/cgi/query-pr.cgi?pr=bin/169542 You might want to
add to that.
For a workaround, two ways come to mind.
1: use dd(1) to copy the MBR to the second disk, then edit it with
gpart. gpart may refuse to edit it, because the last partition goes
past the end of the disk. In that case, fdisk(8) might be able to edit
2: use fdisk(8) to create the new MBR from scratch. Bootcode might be
> There's a further issue that on trying to restore Clonezilla thinks the 12G
> partition is 2885MB.
No idea on that.
More information about the freebsd-questions