Bug 202764

Summary: GPART corruption on Seagate ST9640423AS
Product: Base System Reporter: philk
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: New ---    
Severity: Affects Some People    
Priority: ---    
Version: 10.2-RELEASE   
Hardware: amd64   
OS: Any   

Description philk 2015-08-30 05:10:17 UTC
Every reboot causes the secondary GPT header to become corrupt.

dmesg snip...

Copyright (c) 1992-2015 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
        The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 10.2-RELEASE #0 r286666: Wed Aug 12 15:26:37 UTC 2015
    root@releng1.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC amd64
FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512
CPU: Intel(R) Core(TM) i7 CPU       M 620  @ 2.67GHz (2660.06-MHz K8-class CPU)
  Origin="GenuineIntel"  Id=0x20652  Family=0x6  Model=0x25  Stepping=2
  Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,
HTT,TM,PBE>
  Features2=0x298e3ff<SSE3,PCLMULQDQ,DTES64,MON,DS_CPL,VMX,SMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,SSE4.1,SSE4.2,POPCNT,AESNI>
  AMD Features=0x28100800<SYSCALL,NX,RDTSCP,LM>
  AMD Features2=0x1<LAHF>
  VT-x: PAT,HLT,MTF,PAUSE,EPT,UG,VPID
  TSC: P-state invariant, performance statistics
real memory  = 8589934592 (8192 MB)
avail memory = 8256385024 (7873 MB)
Event timer "LAPIC" quality 600
ACPI APIC Table: <DELL   E2     >
FreeBSD/SMP: Multiprocessor System Detected: 4 CPUs
FreeBSD/SMP: 1 package(s) x 2 core(s) x 2 SMT threads
 cpu0 (BSP): APIC ID:  0
 cpu1 (AP): APIC ID:  1
 cpu2 (AP): APIC ID:  4
 cpu3 (AP): APIC ID:  5
ACPI BIOS Warning (bug): 32/64X FACS address mismatch in FADT: 0xCF36BF40/0x00000000CF36ED40, using 64-bit address (20150515/tbfadt-
305)

ada0 at ahcich0 bus 0 scbus0 target 0 lun 0
ada0: <ST9640423AS 0001SDM1> ATA8-ACS SATA 2.x device
ada0: Serial Number 5WS0JWSP
ada0: 300.000MB/s transfers (SATA 2.x, cd0 at ahcich1 bus 0 scbus1 target 0 lun 0

ada0: Command Queueing enabled
ada0: 610480MB (1250263728 512 byte sectors: 16H 63S/T 16383C)
ada0: quirks=0x1<4K>
ada0: Previously was known as ad4

GEOM: ada0: the secondary GPT table is corrupt or invalid.
GEOM: ada0: using the primary only -- recovery suggested.
GEOM: diskid/DISK-5WS0JWSP: the secondary GPT table is corrupt or invalid.
GEOM: diskid/DISK-5WS0JWSP: using the primary only -- recovery suggested.

# uname -a
FreeBSD catbert.rotfl.com.au 10.2-RELEASE FreeBSD 10.2-RELEASE #0 r286666: Wed Aug 12 15:26:37 UTC 2015     root@releng1.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC  amd64

# gpart show
=>        34  1250263661  ada0  GPT  (596G) [CORRUPT]
          34           6        - free -  (3.0K)
          40        1024     1  freebsd-boot  (512K)
        1064  1241512952     2  freebsd-ufs  (592G)
  1241514016     4194304     3  freebsd-swap  (2.0G)
  1245708320     4555375        - free -  (2.2G)

# gpart status
  Name   Status  Components
ada0p1  CORRUPT  ada0
ada0p2  CORRUPT  ada0
ada0p3  CORRUPT  ada0

# gpart recover ada0
ada0 recovered

# gpart status
  Name  Status  Components
ada0p1      OK  ada0
ada0p2      OK  ada0
ada0p3      OK  ada0

But after a reboot, it will be corrupt again.

Either the gpart recover command isn't actually rewriting the secondary GPT header, or something in the shutdown process is corrupting it.