Recently one of my servers that runs FreeBSD 11.1 keeps hanging on boot. Usually, the 2nd hard reboot will fix it. The root file system on this server is using ZFS and the ZFS pool report it as healthy.
nas:~ # zpool status [136/462]
pool: zroot
state: ONLINE
scan: scrub repaired 0 in 0h0m with 0 errors on Tue Jan 23 23:54:42 2018
config:
NAME STATE READ WRITE CKSUM
zroot ONLINE 0 0 0
gpt/zfs0 ONLINE 0 0 0
errors: No known data errors
So I’ve been reluctant to do anything about it. Until tonight, when I accidentally list the partition of that drive (ada4):
root@nas:~ # gpart show
=> 34 125045357 ada4 GPT (233G) [CORRUPT]
34 1024 1 freebsd-boot (512K)
1058 4194304 2 freebsd-swap (2.0G)
4195362 120850029 3 freebsd-zfs (58G)
Ahh.. [CORRUPT] partition table it seems. I think the reason the server can still boot because GPT keeps the partition tables in two places (yes, one of the more reason to use GPT over MBR).
as:~ # gpart list ada4
Geom name: ada4
modified: false
state: CORRUPT
fwheads: 16
fwsectors: 63
last: 125045390
first: 34
entries: 128
scheme: GPT
Providers:
1. Name: ada4p1
Mediasize: 524288 (512K)
Sectorsize: 512
Stripesize: 4096
Stripeoffset: 1024
Mode: r0w0e0
rawuuid: 75e6513c-11a2-11e4-a8f9-441ea13cabe8
rawtype: 83bd6b9d-7f41-11dc-be0b-001560b84f0f
label: gptboot0
length: 524288
offset: 17408
type: freebsd-boot
index: 1
end: 1057
start: 34
2. Name: ada4p2
Mediasize: 2147483648 (2.0G)
...
In my case, I fixed the corrupt partition by running this command:
nas:~ # gpart recover /dev/ada4
To verify it:
nas:~ # gpart recover /dev/ada4
ada4 recovered
root@nas:~ # gpart list ada4
Geom name: ada4
modified: false
state: OK
fwheads: 16
fwsectors: 63
last: 488397127
first: 34
entries: 128
scheme: GPT
Providers:
1. Name: ada4p1
Mediasize: 524288 (512K)
Sectorsize: 512
Stripesize: 4096
Stripeoffset: 1024
Mode: r0w0e0
rawuuid: 75e6513c-11a2-11e4-a8f9-441ea13cabe8
rawtype: 83bd6b9d-7f41-11dc-be0b-001560b84f0f
label: gptboot0
length: 524288
offset: 17408
type: freebsd-boot
index: 1
end: 1057
start: 34
...
Ref: