HOW TO: mountroot - corrupt GPT and how to fix it

Status
Not open for further replies.

IonutZ

Contributor
Joined
Aug 17, 2014
Messages
108
So... if you dabble long enough with the FreeBSD and reinstalling the OS, you will most likely get the error in the title at some point "corrupt or invalid GPT detected". I just had to deal with this. In order to fix this, you basically have to wipe the GPT of the SD/Flashdrive/HDD that you installed FreeNAS to. You will soon find out that no matter what you do through regular means (which to me consisted of trying to format the disk in multiple ways), you will not be able to get past this error.

In order to fix this error, you will have to use the FreeNAS install disk and boot into the shell.

Once inside the shell, you can run the following command in order to figure out what device you are trying to install FreeNAS to:

camcontrol devlist
Once you've identified the name of the device, which is probabl da followed by a number, you can do the following steps:

1. cd tmp
2. vi wipe.sh
3. Use vi to write the following script

#!/bin/sh
echo "What disk do you want"
echo "to wipe? For example - da0: "
read disk

diskinfo ${disk} | while read disk sectorsize size sectors other
do
/bin/dd if=/dev/zero of=/dev/${disk} bs=${sectorsize} count=8
/bin/dd if=/dev/zero of=/dev/${disk} bs=${sectorsize} oseek=`expr $sectors - 8` count=8
done
4. Save the script
5. chmod 0777 wipe.sh
6. ./wipe.sh​
A couple of warnings would be, DON'T use this if you're trying to recover data because you won't be able to. ONLY use this on the disk you're installing FreeNAS to.

I hope you find this helpful.
 
Last edited:
Status
Not open for further replies.
Top