ada5: the primary GPT table is corrupt or invalid. using the secondary instead -- recovery strongly

Status
Not open for further replies.

SwisherSweet

Contributor
Joined
May 13, 2017
Messages
139
Hi,

I'm piecing together my FreeNAS rig. Upon creating the volume for the first time, I see that several drives (ada5, and ada6) have this error:

ada5: the primary GPT table is corrupt or invalid. using the secondary instead -- recovery strongly advised.

It's my understanding that if the drive is not blank, and it has been used before, this can happen. I believe I used a few of the drives in a Mac Pro and formatted for macOS with a Guid Partition Table.

  1. Do I need to be concerned with this error?
  2. If so, how do I go about fixing this?
  3. Will I need to recreate my pool after fixing it?

I want to make sure I get this perfect before the data migration process.

Thank you.
 

zoomzoom

Guru
Joined
Sep 6, 2015
Messages
677
Someone else will need to chime in to verify, but I think you'd use gpart recover to copy the good copy of the backup GPT table [end of disk] to the bad primary copy [front of disk], overwriting it.

I'm not sure if a S.M.A.R.T test should be run or not, but since it wouldn't hurt: smartctl -t long /dev/ada5
 

SwisherSweet

Contributor
Joined
May 13, 2017
Messages
139
Someone else will need to chime in to verify, but I think you'd use gpart recover to copy the good copy of the GPT table [end of disk] to the bad copy [front of disk], overwriting it.

I'm not sure if a S.M.A.R.T test should be run or not, but since it wouldn't hurt: smartctl -t long /dev/ada5

Thanks for the prompt reply. I just looked-up that command and my concern is how can be sure this fixed it and won't cause me problems down the line (i.e. data loss).

Since I am just starting fresh, isn't there some kind of "erase all and start over" option? I've read that others zero'd out their drives to fix this. This could take forever since they are so big.
 

zoomzoom

Guru
Joined
Sep 6, 2015
Messages
677
You could zero the drives with dd, however whenever I've used disks that were used prior to, I simply destroy the gpt partition table, write an mbr table to it, create a partition, destroy both, then import the disk via the WebGUI
  • gpart destroy -F ada5 && gpart create -s MBR ada5 && gpart add -t freebsd-zfs ada5 && gpart destroy -F ada5
Whenever I've received that error on a disk, I always backup the partition table to a file once the disk has been imported into the pool. This allows the partition table to be restored to the same, or different disk, should both partition tables become corrupted.
  • Backup: gpart backup ada5 > /path/to/ada5.backup
  • Restore: gpart restore -l ada5 < /path/to/ada5.backup
This thread from @cyberjock was one of the first results I received from duckduckgo and may provide some additional info

See gpart man online or offline via: man gpart
 
Last edited:

SwisherSweet

Contributor
Joined
May 13, 2017
Messages
139
Thanks for the reply. I'm not a Unix expert, so I want to make sure I clearly understand the steps.

Since I don't have any data yet on the pool, I will start fresh. Here are the steps I plan to take:

  1. Detach the volume (Mark the disks as new (destroy data)).
  2. Open Shell in FreeNAS utility.
  3. Run these commands (broken out for clarify and order):
    > gpart destroy -f ada5
    > gpart create -s MBR ada5
    > gpart add -t freebsd-zfs ada5
    > gpart destroy -f ada5
  4. Repeat step 3 for ada6, which also had the error.
  5. Recreate the pool
Is this all correct?

Do I also need to do the part about backing up and restoring the partition table or are the 5 steps above good enough?

Thanks again!
 
Last edited:

zoomzoom

Guru
Joined
Sep 6, 2015
Messages
677
I would try that for the time being until someone else chimes in that may have more experience dealing with corrupted partition tables.
  • I forgot FreeBSD doesn't support ext4, so change that to freebsd-zfs
    • I've updated the command in my prior post to show this correction
Also, have you run short S.M.A.R.T tests on the two drives?
  • smartctl -t short /dev/ada5 & smartctl -t short /dev/ada6 & sleep 65 && smartctl -a /dev/ada5 & smartctl -a /dev/ada6
    • Once the pool has been re-created, I would perform a long test on both
You wouldn't do the backup and restore together, but a backup only, then later on, if both partition tables ever become corrupt, you can then restore the partition table to the same, or a different, disk. I don't know how common it is for both GPT copies to become corrupt, but I've only ever had it happen on one disk, which S.M.A.R.T showed was failing, so I outright replaced it.
 
Last edited:

SwisherSweet

Contributor
Joined
May 13, 2017
Messages
139
  • I forgot FreeBSD doesn't support ext4, so change that to freebsd-zfs
    • I've updated the command in my prior post to show this correction
Also, have you run short S.M.A.R.T tests on the two drives?
  • smartctl -t short /dev/ada5 & smartctl -t short /dev/ada6 & sleep 65 && smartctl -a /dev/ada5 & smartctl -a /dev/ada6
    • Once the pool has been re-created, I would perform a long test on both
I would try that for the time being until someone else chimes in that may have more experience dealing with corrupted partition tables.
  • I forgot FreeBSD doesn't support ext4, so change that to freebsd-zfs
    • I've updated the command in my prior post to show this correction
Also, have you run short S.M.A.R.T tests on the two drives?
  • smartctl -t short /dev/ada5 & smartctl -t short /dev/ada6 & sleep 65 && smartctl -a /dev/ada5 & smartctl -a /dev/ada6
    • Once the pool has been re-created, I would perform a long test on both
You wouldn't do the backup and restore together, but a backup only, then later on, if both partition tables ever become corrupt, you can then restore the partition table to the same, or a different, disk. I don't know how common it is for both GPT copies to become corrupt, but I've only ever had it happen on one disk, which S.M.A.R.T showed was failing, so I outright replaced it.

.


I will make that change (freebsd-zfs).

Here's the output of the S.M.A.R.T. tests:

Code:
[root@freenas] ~# smartctl -t short /dev/ada5 & smartctl -t short /dev/ada6 & sleep 65 && smartctl -a /dev/ada5 & smartctl -a /dev/ada6
[1] 5830
[2] 5831
[3] 5832
smartctl 6.5 2016-05-07 r4318 [FreeBSD 10.3-STABLE amd64] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org

smartctl 6.5 2016-05-07 r4318 [FreeBSD 10.3-STABLE amd64] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org

smartctl 6.5 2016-05-07 r4318 [FreeBSD 10.3-STABLE amd64] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Device Model:	 TOSHIBA HDWD130
Serial Number:	X6IEDGSAS
LU WWN Device Id: 5 000039 fe6c617a8
Firmware Version: MX6OACF0
User Capacity:	3,000,592,982,016 bytes [3.00 TB]
Sector Sizes:	 512 bytes logical, 4096 bytes physical
Rotation Rate:	7200 rpm
Form Factor:	  3.5 inches
Device is:		Not in smartctl database [for details use: -P showall]
ATA Version is:   ATA8-ACS T13/1699-D revision 4
SATA Version is:  SATA 3.0, 6.0 Gb/s (current: 3.0 Gb/s)
Local Time is:	Mon May 29 14:12:26 2017 PDT
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===
Sending command: "Execute SMART Short self-test routine immediately in off-line mode".
=== START OF READ SMART DATA SECTION ===
=== START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===
Sending command: "Execute SMART Short self-test routine immediately in off-line mode".
SMART overall-health self-assessment test result: PASSED

General SMART Values:
Offline data collection status:  (0x80)	Offline data collection activity
					was never started.
					Auto Offline Data Collection: Enabled.
Self-test execution status:	  (   0)	The previous self-test routine completed
					without error or no self-test has ever 
					been run.
Total time to complete Offline 
data collection:		 (21935) seconds.
Offline data collection
capabilities:			 (0x5b) SMART execute Offline immediate.
					Auto Offline data collection on/off support.
					Suspend Offline collection upon new
					command.
					Offline surface scan supported.
					Self-test supported.
					No Conveyance Self-test supported.
					Selective Self-test supported.
SMART capabilities:			(0x0003)	Saves SMART data before entering
					power-saving mode.
					Supports SMART auto save timer.
Error logging capability:		(0x01)	Error logging supported.
					General Purpose Logging supported.
Short self-test routine 
recommended polling time:	 (   1) minutes.
Extended self-test routine
recommended polling time:	 ( 366) minutes.
SCT capabilities:			(0x003d)	SCT Status supported.
					SCT Error Recovery Control supported.
					SCT Feature Control supported.
					SCT Data Table supported.

SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME		  FLAG	 VALUE WORST THRESH TYPE	  UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate	 0x000b   100   100   016	Pre-fail  Always	   -	   0
  2 Throughput_Performance  0x0005   139   139   054	Pre-fail  Offline	  -	   71
  3 Spin_Up_Time			0x0007   160   160   024	Pre-fail  Always	   -	   397 (Average 319)
  4 Start_Stop_Count		0x0012   100   100   000	Old_age   Always	   -	   1524
  5 Reallocated_Sector_Ct   0x0033   100   100   005	Pre-fail  Always	   -	   0
  7 Seek_Error_Rate		 0x000b   100   100   067	Pre-fail  Always	   -	   0
  8 Seek_Time_Performance   0x0005   124   124   020	Pre-fail  Offline	  -	   33
  9 Power_On_Hours		  0x0012   100   100   000	Old_age   Always	   -	   3339
 10 Spin_Retry_Count		0x0013   100   100   060	Pre-fail  Always	   -	   0
 12 Power_Cycle_Count	   0x0032   100   100   000	Old_age   Always	   -	   49
192 Power-Off_Retract_Count 0x0032   099   099   000	Old_age   Always	   -	   1525
193 Load_Cycle_Count		0x0012   099   099   000	Old_age   Always	   -	   1525
194 Temperature_Celsius	 0x0002   162   162   000	Old_age   Always	   -	   37 (Min/Max 24/48)
196 Reallocated_Event_Count 0x0032   100   100   000	Old_age   Always	   -	   0
197 Current_Pending_Sector  0x0022   100   100   000	Old_age   Always	   -	   0
198 Offline_Uncorrectable   0x0008   100   100   000	Old_age   Offline	  -	   0
199 UDMA_CRC_Error_Count	0x000a   200   200   000	Old_age   Always	   -	   0

Drive command "Execute SMART Short self-test routine immediately in off-line mode" successful.
Testing has begun.
Please wait 1 minutes for test to complete.
Test will complete after Mon May 29 14:13:28 2017

Use smartctl -X to abort test.
Drive command "Execute SMART Short self-test routine immediately in off-line mode" successful.
Testing has begun.
Please wait 1 minutes for test to complete.
Test will complete after Mon May 29 14:13:28 2017

Use smartctl -X to abort test.
SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 1
Num  Test_Description	Status				  Remaining  LifeTime(hours)  LBA_of_first_error
# 1  Short offline	   Completed without error	   00%	  3339		 -

SMART Selective self-test log data structure revision number 1
 SPAN  MIN_LBA  MAX_LBA  CURRENT_TEST_STATUS
	1		0		0  Not_testing
	2		0		0  Not_testing
	3		0		0  Not_testing
	4		0		0  Not_testing
	5		0		0  Not_testing
Selective self-test flags (0x0):
  After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.

[2]  - Done						  smartctl -t short /dev/ada6
[1]  - Done						  smartctl -t short /dev/ada5
[root@freenas] ~# smartctl 6.5 2016-05-07 r4318 [FreeBSD 10.3-STABLE amd64] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Device Model:	 TOSHIBA HDWD130
Serial Number:	X6IEDGBAS
LU WWN Device Id: 5 000039 fe6c6179c
Firmware Version: MX6OACF0
User Capacity:	3,000,592,982,016 bytes [3.00 TB]
Sector Sizes:	 512 bytes logical, 4096 bytes physical
Rotation Rate:	7200 rpm
Form Factor:	  3.5 inches
Device is:		Not in smartctl database [for details use: -P showall]
ATA Version is:   ATA8-ACS T13/1699-D revision 4
SATA Version is:  SATA 3.0, 6.0 Gb/s (current: 3.0 Gb/s)
Local Time is:	Mon May 29 14:13:32 2017 PDT
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

General SMART Values:
Offline data collection status:  (0x85)	Offline data collection activity
					was aborted by an interrupting command from host.
					Auto Offline Data Collection: Enabled.
Self-test execution status:	  (   0)	The previous self-test routine completed
					without error or no self-test has ever 
					been run.
Total time to complete Offline 
data collection:		 (21791) seconds.
Offline data collection
capabilities:			 (0x5b) SMART execute Offline immediate.
					Auto Offline data collection on/off support.
					Suspend Offline collection upon new
					command.
					Offline surface scan supported.
					Self-test supported.
					No Conveyance Self-test supported.
					Selective Self-test supported.
SMART capabilities:			(0x0003)	Saves SMART data before entering
					power-saving mode.
					Supports SMART auto save timer.
Error logging capability:		(0x01)	Error logging supported.
					General Purpose Logging supported.
Short self-test routine 
recommended polling time:	 (   1) minutes.
Extended self-test routine
recommended polling time:	 ( 364) minutes.
SCT capabilities:			(0x003d)	SCT Status supported.
					SCT Error Recovery Control supported.
					SCT Feature Control supported.
					SCT Data Table supported.

SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME		  FLAG	 VALUE WORST THRESH TYPE	  UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate	 0x000b   100   100   016	Pre-fail  Always	   -	   0
  2 Throughput_Performance  0x0005   139   139   054	Pre-fail  Offline	  -	   70
  3 Spin_Up_Time			0x0007   149   149   024	Pre-fail  Always	   -	   375 (Average 392)
  4 Start_Stop_Count		0x0012   100   100   000	Old_age   Always	   -	   1521
  5 Reallocated_Sector_Ct   0x0033   100   100   005	Pre-fail  Always	   -	   0
  7 Seek_Error_Rate		 0x000b   100   100   067	Pre-fail  Always	   -	   0
  8 Seek_Time_Performance   0x0005   124   124   020	Pre-fail  Offline	  -	   33
  9 Power_On_Hours		  0x0012   100   100   000	Old_age   Always	   -	   3314
 10 Spin_Retry_Count		0x0013   100   100   060	Pre-fail  Always	   -	   0
 12 Power_Cycle_Count	   0x0032   100   100   000	Old_age   Always	   -	   49
192 Power-Off_Retract_Count 0x0032   099   099   000	Old_age   Always	   -	   1521
193 Load_Cycle_Count		0x0012   099   099   000	Old_age   Always	   -	   1521
194 Temperature_Celsius	 0x0002   150   150   000	Old_age   Always	   -	   40 (Min/Max 24/49)
196 Reallocated_Event_Count 0x0032   100   100   000	Old_age   Always	   -	   0
197 Current_Pending_Sector  0x0022   100   100   000	Old_age   Always	   -	   0
198 Offline_Uncorrectable   0x0008   100   100   000	Old_age   Offline	  -	   0
199 UDMA_CRC_Error_Count	0x000a   200   200   000	Old_age   Always	   -	   0

SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 1
Num  Test_Description	Status				  Remaining  LifeTime(hours)  LBA_of_first_error
# 1  Short offline	   Completed without error	   00%	  3314		 -
# 2  Short offline	   Completed without error	   00%	  3314		 -
# 3  Short offline	   Completed without error	   00%	  3314		 -

SMART Selective self-test log data structure revision number 1
 SPAN  MIN_LBA  MAX_LBA  CURRENT_TEST_STATUS
	1		0		0  Not_testing
	2		0		0  Not_testing
	3		0		0  Not_testing
	4		0		0  Not_testing
	5		0		0  Not_testing
Selective self-test flags (0x0):
  After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.

 

SwisherSweet

Contributor
Joined
May 13, 2017
Messages
139
When I run this command:

gpart destroy -f ada5 && gpart create -s MBR ada5 && gpart add -t freebsd-zfs ada5 && gpart destroy -f ada5


I get this error:

gpart: Invalid number of arguments.

I looked up man pages, but it was not obvious to me what is missing. Do you know what is missing for the command?
 

zoomzoom

Guru
Joined
Sep 6, 2015
Messages
677
My bad... change -f to -F

There's nothing of concern in either and both drives are fairly new (~4.5 months of usage).
  • While off-topic, I would recommend checking out this thread, which has S.M.A.R.T and zpool scripts to email you the results of those and others. It's also highly recommended to configure S.M.A.R.T tests via the WebGUI -> Tasks -> S.M.A.R.T Tests. I utilize the same schedule @Bidule0hm utilizes in the aforementioned link
 
Last edited:

SwisherSweet

Contributor
Joined
May 13, 2017
Messages
139
Ah
My bad... change -f to -F

There's nothing of concern in either and both drives are fairly new (~4.5 months of usage).
  • While off-topic, I would recommend checking out this thread, which has S.M.A.R.T and zpool scripts to email you the results of those and others. It's also highly recommended to configure S.M.A.R.T tests via the WebGUI -> Tasks -> S.M.A.R.T Tests. I utilize the same schedule Bidule0hm

Ah, thanks for the clarification. I will also setup the tests in the UI.

Curious, there's a feature in the UI to "Wipe" a disk with three options:

  1. Quick
  2. Full with zeros
  3. Full with random data

Would performing a "Quick" wipe solve my problem as well?
 

SwisherSweet

Contributor
Joined
May 13, 2017
Messages
139
Out of curiosity, I executed the Wipe command with the "Quick" setting on all my drives, and then recreated the pool. There were no errors this time.

I have not yet executed the corrected command you provided. Since there were no errors, do you think it is now needed?

Appreciate your help.
 

zoomzoom

Guru
Joined
Sep 6, 2015
Messages
677
That would be a question for someone more knowledgeable than I, as I don't know what commands the GUI calls to perform it's quick wipe, and whether it destroys the partition table or not... My guess would be that for this specific issue, gpart should be used via cli.
  • #2 likely uses dd to zero out the drive
  • #3 likely uses dd to overwrite the entire drive with random characters
I have not yet executed the corrected command you provided. Since there were no errors, do you think it is now needed?
That's something I also don't know, but if it was my disk, I would do so since it only takes a few seconds to run.
 

SwisherSweet

Contributor
Joined
May 13, 2017
Messages
139
That would be a question for someone more knowledgeable than I, as I don't know what commands the GUI calls to perform it's quick wipe, and whether it destroys the partition table or not... My guess would be that for this specific issue, gpart should be used via cli.
  • #2 likely uses dd to zero out the drive
  • #3 likely uses dd to overwrite the entire drive with random characters

That's something I also don't know, but if it was my disk, I would do so since it only takes a few seconds to run.

Cool, I agree. I'll do both. Thanks again.
 

zoomzoom

Guru
Joined
Sep 6, 2015
Messages
677
No problem at all. I also realized one of my prior posts were incomplete... this is the link for the S.MA.R.T. email report from @Bidule0hm I mentioned before
 

SwisherSweet

Contributor
Joined
May 13, 2017
Messages
139
ZoomZoom, I'm getting a new error when I run your updated command:

gpart destroy -F ada5 && gpart create -s MBR ada5 && gpart add -t freebsd-zfs ada5 && gpart destroy -F ada5

Error:

gpart: arg0 'ada5': Invalid argument
 

zoomzoom

Guru
Joined
Sep 6, 2015
Messages
677
Check out the man page I linked to earlier, or issue the man page command in cli: man gpart. I simply copied the commands from the man page, and since I don't have a disk to check them on, I left them as is, with the only thing changed being "da0" to "ada5".
 
Last edited:
Status
Not open for further replies.
Top