Unable to GPT format the disk

Nemock

Dabbler
Joined
Jan 8, 2017
Messages
16
Hello all,

The Error:
"Unable to GPT format the disk" when attempting to create a Volume

I'm not entirely new to FreeNAS, but encountered this problem recently when trying to setup a new volume with a few older drives from me desktop. The drives in question used to be part of a RAID10 on said desktop. I'm unsure how to correct this error, and everywhere I search seems to tell me to do more and more convoluted solutions. I'm hoping there is a relatively simple console command I can apply to these drive to get them formatted correctly to allow the creation of a volume.

Any help is greatly appreciated.
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
Hello all,

The Error:
"Unable to GPT format the disk" when attempting to create a Volume

I'm not entirely new to FreeNAS, but encountered this problem recently when trying to setup a new volume with a few older drives from me desktop. The drives in question used to be part of a RAID10 on said desktop. I'm unsure how to correct this error, and everywhere I search seems to tell me to do more and more convoluted solutions. I'm hoping there is a relatively simple console command I can apply to these drive to get them formatted correctly to allow the creation of a volume.

Any help is greatly appreciated.
Welcome to the forums!

Yeah, I dimly recall having this problem when I tried to use drives that already had 'foreign' partitions. Seems like I had to wipe the drive, using badblocks or dd.

After a little digging, I found a forum post that explains the problem in detail and includes a fix: Unable to GPT format the disk ada0; unable to wipe ada0. Just be sure you wipe the right drive...

Good luck!
 

Nemock

Dabbler
Joined
Jan 8, 2017
Messages
16
Welcome to the forums!

Yeah, I dimly recall having this problem when I tried to use drives that already had 'foreign' partitions. Seems like I had to wipe the drive, using badblocks or dd.

After a little digging, I found a forum post that explains the problem in detail and includes a fix: Unable to GPT format the disk ada0; unable to wipe ada0. Just be sure you wipe the right drive...

Good luck!

So, I just want to be sure on this.

My Disks:
ada0 - 3TB (GPT Error)
ada1 - 3TB (GPT Error)
ada2 - 3TB (GPT Error)
ada3 - 3TB (GPT Error)
da0 - 4TB Z2 (Healthy Pool)
da1 - 4TB Z2 (Healthy Pool)
da2 - 4TB Z2 (Healthy Pool)
da3 - 4TB Z2 (Healthy Pool)
da4 - 4TB Z2 (Healthy Pool)
da5 - 4TB Z2 (Healthy Pool)
da6 - 4TB Z2 (Healthy Pool)
da7 - 4TB Z2 (Healthy Pool)
da8 - Flashdrive (Boot Drive)


Shell execute:
Code:
# dd if=/dev/zero of=/dev/ada0 bs=512 count=1000

Followed by:
Code:
# dd if=/dev/zero of=/dev/ada0 bs=512 seek=7814037000

for each drive?
 

wblock

Documentation Engineer
Joined
Nov 14, 2014
Messages
1,506
The seek parameter in the second command depends on the size of the drive. The idea is to seek to just before the end of the disk before beginning writing, because it's only a small part that needs to be erased. Really, erasing the last megabyte should be enough to get rid of most RAID metadata, and certainly the secondary GPT table.

Make very, very certain that the drives to be erased have been correctly identified. Make a full backup first, also. Paranoid people--or those with bad experiences--might also shut down and physically disconnect everything except the drives to be erased.

It looks like ada0 through ada3 are the drives in question here. Four 3TB drives. Make sure! The examples below use these drives, be warned! Do not lose track and start doing this to any of the working drives, only those four.

Use gpart destroy -F ada0 to try to remove any corrupted GPT data. Then use dd to erase any other metadata.

dd does not understand negative offsets, so the part at the end of the disk has to be worked out with, gasp, math. Use diskinfo -v ada0 | grep 'mediasize in sectors' to get the size in blocks/sectors. Subtract 2048 from that (2048*512=1M), then use that for the seek value. dd will skip to 1M before the end of the disk and write until it hits the end of the disk.
 
Last edited:

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
So, I just want to be sure on this.

My Disks:
ada0 - 3TB (GPT Error)
ada1 - 3TB (GPT Error)
ada2 - 3TB (GPT Error)
ada3 - 3TB (GPT Error)
da0 - 4TB Z2 (Healthy Pool)
da1 - 4TB Z2 (Healthy Pool)
da2 - 4TB Z2 (Healthy Pool)
da3 - 4TB Z2 (Healthy Pool)
da4 - 4TB Z2 (Healthy Pool)
da5 - 4TB Z2 (Healthy Pool)
da6 - 4TB Z2 (Healthy Pool)
da7 - 4TB Z2 (Healthy Pool)
da8 - Flashdrive (Boot Drive)


Shell execute:
Code:
# dd if=/dev/zero of=/dev/ada0 bs=512 count=1000

Followed by:
Code:
# dd if=/dev/zero of=/dev/ada0 bs=512 seek=7814037000

for each drive?
Yes, these are the correct commands. To make doubly sure, open a shell and use the camcontrol devlist and gpart show commands to list your drives and the partitions on them, like this:
Code:
camcontrol devlist
gpart show
Here is a screenshot of these commands from one of my systems:
camcontrol-output.jpg


Then be absolutely certain you only run the 'dd' command on the correct drives! On your system these seem to be ada0, ada1, ada2, and ada3.

Good luck!
 

Nemock

Dabbler
Joined
Jan 8, 2017
Messages
16
Use gpart destroy -F ada0 to try to remove any corrupted GPT data. Then use dd to erase any other metadata.

This command ( gpart destroy -f ada0) results in error:
Code:
gpart: Invalid number of arguments.
(was having this problem last night when attempt one of the fixes)

Additional information: when I do for instance gpart show ada0 (or any of the 4 drives in question) I get:
Code:
gpart: No such geom: ada0


However this command correctly shows data for any other working drive da0-da8:
Code:
[root@Vanaheim ~]# gpart show da0																								  
=>		34  7814037101  da0  GPT  (3.6T)																						  
		  34		  94	   - free -  (47K)																					  
		 128	 4194304	1  freebsd-swap  (2.0G)																				
	 4194432  7809842696	2  freebsd-zfs  (3.6T)																				  
  7814037128		   7	   - free -  (3.5K)  


I suspect if gpart fails to get the drive, so will dd... But the system still sees the drives correctly:
Code:
[root@Vanaheim ~]# camcontrol devlist																							  
<ATA WDC WD40EFRX-68W 0A82>		at scbus0 target 0 lun 0 (pass0,da0)															
<ATA WDC WD40EFRX-68W 0A82>		at scbus0 target 1 lun 0 (pass1,da1)															
<ATA WDC WD40EFRX-68W 0A82>		at scbus0 target 2 lun 0 (pass2,da2)															
<ATA WDC WD40EFRX-68W 0A82>		at scbus0 target 3 lun 0 (pass3,da3)															
<ATA WDC WD40EFRX-68W 0A82>		at scbus0 target 4 lun 0 (pass4,da4)															
<ATA WDC WD40EFRX-68W 0A82>		at scbus0 target 5 lun 0 (pass5,da5)															
<ATA WDC WD40EFRX-68W 0A82>		at scbus0 target 6 lun 0 (pass6,da6)															
<ATA WDC WD40EFRX-68W 0A82>		at scbus0 target 7 lun 0 (pass7,da7)															
<WDC WD30EURS-63R8UY0 80.00A80>	at scbus3 target 0 lun 0 (pass8,ada0)															
<WDC WD30EURS-63R8UY0 80.00A80>	at scbus4 target 0 lun 0 (pass9,ada1)															
<WDC WD30EZRX-00D8PB0 80.00A80>	at scbus5 target 0 lun 0 (pass10,ada2)														  
<WDC WD30EZRX-00D8PB0 80.00A80>	at scbus6 target 0 lun 0 (pass11,ada3)														  
<SanDisk Cruzer Fit 1.26>		  at scbus8 target 0 lun 0 (pass12,da8) 


Note: I have not attempted to run the "dd" command set yet.
 

SweetAndLow

Sweet'NASty
Joined
Nov 6, 2013
Messages
6,421
Nvm
 

wblock

Documentation Engineer
Joined
Nov 14, 2014
Messages
1,506
This command ( gpart destroy -f ada0) results in error:
Yes, the command is case sensitive, so it has to be capital -F.
 

wblock

Documentation Engineer
Joined
Nov 14, 2014
Messages
1,506
Additional information: when I do for instance gpart show ada0 (or any of the 4 drives in question) I get:
Code:
gpart: No such geom: ada0
Yes, there is corrupt GPT information on it, so it's not a valid GEOM. Not a problem, at worst the gpart destroy -F will error out, but dd will not care.
 

Nemock

Dabbler
Joined
Jan 8, 2017
Messages
16
Yes, the command is case sensitive, so it has to be capital -F.

It was a copy paste error on this forum that put it as lower case. I implemented upper case:

Code:
[root@Vanaheim ~]# gpart destroy -F ada0																							
gpart: arg0 'ada0': Invalid argument																								
[root@Vanaheim ~]#	
 

Nemock

Dabbler
Joined
Jan 8, 2017
Messages
16
Yes, there is corrupt GPT information on it, so it's not a valid GEOM. Not a problem, at worst the gpart destroy -F will error out, but dd will not care.
From above:
If I use the first dd command:
# dd if=/dev/zero of=/dev/ada0 bs=512 count=1000
will that allow a gpart show to give me the correct parameters for:
# dd if=/dev/zero of=/dev/ada0 bs=512 seek=7814037000
?
 

wblock

Documentation Engineer
Joined
Nov 14, 2014
Messages
1,506
Use diskinfo -v ada0 | grep 'mediasize in sectors'. Subtract 2048 from that. That is the number to use as the seek= value.

There is no point in saying bs=512, that is the default. So here, let's show the correct commands. Note that these require the disk to not be in used, or it will refuse to write.

To erase the first megabyte of a disk we will call ada9:
dd if=/dev/zero of =/dev/ada9 count=2048

To erase the last megabyte of the same disk:
diskinfo -v ada0 | grep 'mediasize in sectors
Subtract 2048 from the number shown. This is the number of 512-byte blocks in a megabyte. So the dd will seek to a spot one megabyte before the end of the disk before it begins writing zeros.
dd if=/dev/zero of=/dev/ada9 seek=calculated-number[/cmd]
 

Nemock

Dabbler
Joined
Jan 8, 2017
Messages
16
To erase the first megabyte of a disk we will call ada9:
dd if=/dev/zero of =/dev/ada9 count=2048


Grrrrrr:


Code:
[root@Vanaheim ~]# dd if=/dev/zero of=/dev/ada0 count=2048																		  
dd: /dev/ada0: Operation not permitted																							  
[root@Vanaheim ~]# ^C																											  
[root@Vanaheim ~]# dd if=/dev/zero of=/dev/ada0 bs=512 count=2048																  
dd: /dev/ada0: Operation not permitted																							  
[root@Vanaheim ~]# dd if=/dev/zero of=/dev/ada0 bs=512 count=1000																  
dd: /dev/ada0: Operation not permitted  


After the first one failed, decided to try the other variants because sometimes stupid stuff happens.
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
If by root you mean signed in as root and after executing su then yes.
Perhaps it won't let you write to the device because it's mounted?
I would try umount /dev/ad0 and give it another whirl.
 

Nemock

Dabbler
Joined
Jan 8, 2017
Messages
16
Perhaps it won't let you write to the device because it's mounted?
I would try umount /dev/ad0 and give it another whirl.

Code:
[root@Vanaheim] ~# umount /dev/ada0																								
umount: /dev/ada0: unknown file system 


Why can't it just be simple! GAH
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
Crikey! Do you have another PC? Perhaps you could stick the disks in a Windows box and delete any partition(s) on them that way.
 

Nemock

Dabbler
Joined
Jan 8, 2017
Messages
16
Crikey! Do you have another PC? Perhaps you could stick the disks in a Windows box and delete any partition(s) on them that way.

yes... technically... I was hoping to avoid this because the box they are in it's a retro-fit. The other volume takes up all 8 drive bays, so these 4 sit like this:
gV0ATAA.jpg


They're velcroed down. The one you see sits on a 3-bay cage that's velcroed to the bottom of the case. If that's what I have to do to clear the problem, well that's what I have to do. It's just gonna be a PITA.
 
Top