[FreeNAS] Lost GPT partition table, lost ZFS Pool

Hi everyone I'm creating this thread because my reply on another old thread failed and I've got no answers.

I have the exact same problem as described here :
http://forums.freebsd.org/showthread.php?t=20941

I'm no FreeBSD nor ZFS expert, I've been using FreeNAS 8 for a year now; my set up is the following:

Virtualized FreeNAS on ESXi, FreneNAS is installed on a 8GB vdisk, my storage pool is 3 x 1TB HDD, configured as Raw Direct Access (RDM) so FreeNAS accesses them directly bypassing the vKernel of VmWare.

Explanation of the problem:
Lately I could not reach my CIFS share, tried to reach the webGUI, unreachable, tried to reboot the system within vSphereClient, no luck. So I did a reset in vSphere (the hard way then) and the system went back to normal.

Couple of weeks after that, same symptoms, tried the first two solutions, same results, so I reset the VM, like last time, and I lost my ZFS pool according to the FreeNAS WebGUI.

After some talk on the FreeNAS forum I ended up doing some commands and here's what I got:

Code:
[root@freenas] ~# camcontrol devlist
<NECVMWar VMware IDE CDR10 1.00> at scbus1 target 0 lun 0 (cd0,pass0)
<VMware Virtual disk 1.0> at scbus2 target 0 lun 0 (da0,pass1)
<ATA SAMSUNG HD103SI 1AG0> at scbus2 target 1 lun 0 (da1,pass2)
<ATA SAMSUNG HD103SI 1AG0> at scbus2 target 2 lun 0 (da2,pass3)
<ATA SAMSUNG HD103SI 1AG0> at scbus2 target 3 lun 0 (da3,pass4)

Looks ok to me.

Code:
[root@freenas] ~# sysctl kern.disks
kern.disks: da3 da2 da1 da0 cd0

Also ok.

Code:
[root@freenas] ~# gpart show
=> 63 16777152 da0 MBR (8.0G)
63 1930257 1 freebsd [active] (943M)
1930320 63 - free - (32K)
1930383 1930257 2 freebsd (943M)
3860640 3024 3 freebsd (1.5M)
3863664 41328 4 freebsd (20M)
3904992 12872223 - free - (6.1G)

=> 0 1930257 da0s1 BSD (943M)
0 16 - free - (8.0K)
16 1930241 1 !0 (943M)

My data are of great value (mostly personal, pictures and stuff) and I have to say this thread gave me some hope.

One of the first advices I had on the other forum is to try another ZFSv28 implementation as FreeNAS uses v15. But according to the thread I mention I understand I have to recover or recreate my GPT first, right?

Before going any further, I'm planning to buy a new set of 3 HDDs to make a raw copy of everything. I read quite a few things about ZFS structure and GPT but it's still a bit blurred in my mind. And especialy when I read in this thread that a GPT entry exists at the begining of each HDD AND a another one created by ZFS for itself. I don't really get it.

  1. Could you give me some advices?
  2. What to check first to be sure of the issue?
  3. What to do?
  4. What NOT to do to protect my data?
  5. What is the "dev/gpt/wdgreen label"?
  6. Is it wise to use a tool for partition recovery? I mainly use TestDisk (http://www.cgsecurity.org/wiki/TestDisk) which is able to find and recover GPT partition table, but as I saw in your post maybe it's more effective to recreate a new one?
  7. The person in the other thread was using a single HDD at the time, I use 3, does it make a difference in the recovery process?

Some many questions, I'm sorry :)

I hope someone will answer me and save my life. Thanks for your help!
 
The gpart(8) output shows an MBR disk. /dev/gpt/wdgreen is a GPT label on a GPT disk. Use
% gpart list
and check the output for wdgreen.

Do not do anything until you have a full binary copy of the drives in question. That might be all of them. Then physically disconnect the old ones. Do not try to recover with them connected, it is easy to end up writing to a bad drive because it appears to be a new one.
 
Hi,

Hopefully someone will reply since it's been a while now.

I finally managed to get my hand on three identical HDDs. Now how do I do a full binary copy? I will use dd I guess, but since the three HDDs are part of a ZFS volume, is there something I should know? Do? Can you give me some advice on how to use dd?

As I said I have a VMware infra on this server. I was thinking of booting on a specific Linux distribution to do the copy etc, or freeBSD FreeBSD maybe? I don't know the best way. Should I leave connected only two HDDs, the source and destination, and do this three times for the three HDDs?

Is there a link between the disk in a ZFS volume, like an order, maybe depending on the SATA slot used?

Thanks everyone for your help I will get over it! !!!!!!
 
@o0larry0o

1. Boot from a FreeBSD-9.0 CD or memstick and choose "Live"

2. Identify your hard drives:
Code:
[CMD="#"]camcontrol devlist[/CMD]
ada0 # old nr.1
ada1 # old nr.2
ada2 # new nr.3
ada3 # new nr.1
ada4 # new nr.2
ada5 # new nr.3

3. Duplicate Data:
# dd if=/dev/ada0 of=/dev/ada3 bs=128k | dd if=/dev/ada1 of=/dev/ada4 bs=128k | dd if=/dev/ada2 of=/dev/ada5 bs=128k

4. Go out for a looong walk:)

Is there a link between the disk in a ZFS volume, like an order, maybe depending on the SATA slot used ?
ada0 is the disk connected to the first SATA port, ada1 is on the second, and so on. But the best way to keep track is to use labeling when you create the pool.

Here´s an example of pool-creating with labels down at post nr. 12:
4x2TB disk partition help

/Sebulon
 
So I'm back in this business !!
Now I have done a full raw copy of my 3 old HDD on my 3 new ones.

As I understand from this post : http://forums.freebsd.org/showpost.php?p=121748&postcount=12

I would need to:
- writes zeroes to the first 1MiB of the disk
- creates a new GPT partition scheme
- creates a freebsd-boot boot partition
- creates a data partition spanning the rest of the drive minus 1MB of the GPT partition table and freebsd boot partition

After that, ZFSv28 would be able to see my ZFS file system and import my ZFS pool.

According to your post Sebulon here : http://forums.freebsd.org/showpost.php?p=172137&postcount=12
To do so I would need to do :

- gpart create -s gpt dax
On each drive ?
- gpart add -t freebsd-boot -s 64k dax
On each drive again ?
- gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 dax
I don't understand this command, do I need it ? can you explain it to me ? I have the feeling that it's to make the disk bootable, if so I guess I don't need it cause I don't boot on them, they are only used for storage
- gpart add -t freebsd-zfs -l disk0 -b 2048 -a 4k dax
On each drive again ? Is the label important ? I mean, if my old disk didn't have any would it make a different in the process ? and I couldn't find any entries in the gpart man page about the -a option, what is it used for ?

I just thought that I might have missed a step in my process.
Maybe I could use my 3 new HDD to start a new configuration in FreeNAS to check the partitionning scheme and to have a reference to copy from. To be sure of the lenght of each partition etc. Because maybe FreeNAS does thing differently than a manual configuration on a basic FreeBSD system. I'm wondering if the size of the freebsd-boot is the same (64k), and if the freebsd-zfs starts at the same position ?
Does it make any sense ?

Thanks in advance for your replies.

Ludovic
 
o0larry0o said:
- gpart create -s gpt dax
- gpart add -t freebsd-zfs -l diskY -b 2048 -a 4k dax

... and I couldn't find any entries in the gpart man page about the -a option, what is it used for ?

Only those two are needed if you're not going to boot from them. And "- a" is used for aligning the end boundary of the partition, so that you writes are aligned, even down to the very last.

To make a bootable ZFS, you need to a) add a freebsd-boot partition, and b) write bootcode into that partition. Remember, a partition is empty until you do something with it. Lastly c) set zpool bootfs. Omit all of these if you're not going to boot from ZFS.

The label is probably the most important part of all. Ideally, you connect only one drive at a time, so you are essentially holding adaX in your hands. After running the command, you are dead sure which drive is diskY, and take a sticker, or marking pen, and write (or tape) diskY onto the hard drive. This prevents you from ever pulling the wrong drive when replacing. Because the physical hard drive ada5 may end up being called some else upon reboot, like ada1 for example. But the label disk0 is always going to correspond to that physical drive.

After doing these two steps, you have partitioned the drives. There is still no ZFS on them. Continue following the guide to complete the process.

/Sebulon
 
Okay I'll try that asap,
But remember I don't want to carry on the process of creating a ZFS volume,
I want to rebuild the partition table without touching any of the data that are on the old ZFS volume, so my aim is to recreate the GPT partition and the ZFS partition descriptor and then see if FreeBSD is able to see the pool again.

About the label does it matter if my old partitionning scheme did not have any ?
About the -a option it seems that my Samsung ecogreen F2 (HD103SI) have 512 bytes per sector, so if I understood well I should use -a 512, right ?

what about my last question ? If I put my new drives in FreeNAS and do as if it was a new installation, How do I check all the parameters to be able to reproduce them afterwards ?

Many thanks for your help
 
The guide is for installing new and discarding the old. I gave you an example of installing anew with labels, aligned and optimized for 4k.

If you like to recover what might be left from before, only follow wblock´s instructions.

# gpart list
# gpart show -l
# gpart recover adaX

About the -a option it seems that my Samsung ecogreen F2 (HD103SI) have 512 bytes per sector, so if I understood well I should use -a 512, right ?
Don´t. Since you only wanted to recover. But I can explain it for you any way. I googled a bit to find out for sure if that particular model is 4k, but couldn´t find any information on what sector size is actually used. When no information exists, that usually means that they are regular 512b, but since there is no performance loss in aligning them, you might as well: "-a 4k"

what about my last question ? If I put my new drives in FreeNAS and do as if it was a new installation, How do I check all the parameters to be able to reproduce them afterwards ?
In FreeNAS, you can drop into a shell from the console or ssh in remote and make the same commands to partition and setup ZFS as you would in FreeBSD. FreeNAS is FreeBSD base and a fancy WUI ontop, so basically anything you can do in FreeBSD also applies to FreeNAS. But they have made it better suited for USB-sticks or CF-cards; loading all configurations- and writings onto a RAM(md) drive to save the USB of unnecessary writing(wear) to it.

/Sebulon
 
Back
Top