gpart restore -> Invalid argument

Hello All,

I'm trying to restore my boot mirror (2 identical USB sticks) using gpart backup and gpart restore but getting an error.

Code:
# gpart list da0
Geom name: da0
modified: false
state: OK
fwheads: 255
fwsectors: 63
last: 31260638
first: 34
entries: 128
scheme: GPT
Providers:
1. Name: da0p1
   Mediasize: 524288 (512K)
   Sectorsize: 512
   Stripesize: 0
   Stripeoffset: 17408
   Mode: r0w0e0
   efimedia: HD(1,GPT,2036be0c-1fcb-11ea-aa95-00e081b26276,0x22,0x400)
   rawuuid: 2036be0c-1fcb-11ea-aa95-00e081b26276
   rawtype: 83bd6b9d-7f41-11dc-be0b-001560b84f0f
   label: (null)
   length: 524288
   offset: 17408
   type: freebsd-boot
   index: 1
   end: 1057
   start: 34
2. Name: da0p2
   Mediasize: 16004898816 (15G)
   Sectorsize: 512
   Stripesize: 0
   Stripeoffset: 544768
   Mode: r1w1e1
   efimedia: HD(2,GPT,20a65a70-1fcb-11ea-aa95-00e081b26276,0x428,0x1dcfbb0)
   rawuuid: 20a65a70-1fcb-11ea-aa95-00e081b26276
   rawtype: 516e7cba-6ecf-11d6-8ff8-00022d09712b
   label: (null)
   length: 16004898816
   offset: 544768
   type: freebsd-zfs
   index: 2
   end: 31260631
   start: 1064
Consumers:
1. Name: da0
   Mediasize: 16005464064 (15G)
   Sectorsize: 512
   Mode: r1w1e2

# gpart backup da0 > da0.backup

# cat da0.backup
GPT 128
1   freebsd-boot       34     1024 
2    freebsd-zfs     1064 31259568 

# gpart list da1
gpart: No such geom: da1.

# gpart restore da1 < da0.backup
gpart: start '34': Invalid argument

What am I doing wrong?
 
# gpart list da1 gpart: No such geom: da1.
This is quite normal if there is no partitioning scheme (GPT, MBR, ...) on the disk, yet. You can see these disks here: sysctl kern.disks, or with geom disk list da1.

But I am not sure why you can't start at sector 34..
 
Might be due to 4K alignment. It starts at 40 nowadays.
 
This is quite normal if there is no partitioning scheme (GPT, MBR, ...) on the disk, yet. You can see these disks here: sysctl kern.disks, or with geom disk list da1.

Right. I wanted to show that there was no partitioning on the stick before I tried to restore from backup.
 
Did you also try with gpart restore -F?

Just tried it - didn't work.

I got a pair of 32 GB USB sticks and added one of them to the existing 16 GB stick to restore the mirror:

# zpool status
pool: freenas-boot
state: ONLINE
scan: resilvered 3.37G in 0 days 00:19:14 with 0 errors on Sat Jul 4 01:24:34 2020
config:

NAME STATE READ WRITE CKSUM
freenas-boot ONLINE 0 0 0
mirror-0 ONLINE 0 0 0
da0p2 ONLINE 0 0 0
da1p2 ONLINE 0 0 0

errors: No known data errors


The mirror now consists of 1 16GB and 1 32GB sticks. As SirDice noted on the new stick da1p1 starts at 40 while on the old 16GB stick da0p1 starts at 34.
 
This is just guessing: grep dmesg for any USB quirks activated on this stick. There might be some subtle consequence, i.e. the stick refuses to write before sector 40.
 
Back
Top