# gMirror issue when working with GPT



## Leander (Oct 18, 2011)

Hi fellows,

only gMirror seems not being able to stop mirror if mirror was setup/configured with GPT partitions. Here is the code for reproducing the bug:

Prepare Devices:

```
FreeBSD [~]# gpart destroy -F ada1
ada1 destroyed
FreeBSD [~]# gpart destroy -F ada2
ada2 destroyed
FreeBSD [~]# 
FreeBSD [~]# 
FreeBSD [~]# gpart create -s GPT ada1
ada1 created
FreeBSD [~]# gpart create -s GPT ada2
ada2 created
FreeBSD [~]# 
FreeBSD [~]# 
FreeBSD [~]# gpart add -l 'Storage' -t freebsd-ufs ada1
ada1p1 added
FreeBSD [~]# gpart add -l 'StorageParity' -t freebsd-ufs ada2
ada2p1 added
```

Set up / configure the mirror:

```
FreeBSD [~]# gmirror label -b round-robin Test gpt/Storage gpt/StorageParity
FreeBSD [~]# gmirror status
       Name    Status  Components
mirror/Test  COMPLETE  ada1p1 (ACTIVE)
                       ada2p1 (ACTIVE)
```
^^ Huh? shows ada1p1 insted of label ... hmmm maybe thats wanted?!


Stoping the mirror:

```
FreeBSD [~]# gmirror stop Test
FreeBSD [~]# gmirror status
       Name    Status  Components
mirror/Test  COMPLETE  gpt/StorageParity (ACTIVE)
                       gpt/Storage (ACTIVE)
```
^^ Huh? Test mirror didn't stop as expected ;/ but it switched from its regular dev name to its label (as actually originally configured ...?!) This switching arround will happen as many times as one may run the "gmirror stop" command ... till eternity


Olny workaround I figured thus far:

```
FreeBSD [~]# gmirror deactivate Test gpt/Storage
FreeBSD [~]# gmirror deactivate Test gpt/StorageParity
FreeBSD [~]# gmirror status
FreeBSD [~]# gmirror clear gpt/Storage
FreeBSD [~]# gmirror clear gpt/StorageParity
```

As mentioned above already - ONLY gMirror seems to b!tch around when configured with GPT partitions. Havn't had any issues using gconcat and GPT partitions.

P.S.: this does not only happen when configured with labels:

```
FreeBSD [~]# gmirror label -b round-robin Test ada1p1 ada2p1
FreeBSD [~]# gmirror status
       Name    Status  Components
mirror/Test  COMPLETE  ada1p1 (ACTIVE)
                       ada2p1 (ACTIVE)
FreeBSD [~]# gmirror stop Test
FreeBSD [~]# gmirror status
       Name    Status  Components
mirror/Test  COMPLETE  gpt/StorageParity (ACTIVE)
                       gpt/Storage (ACTIVE)
```


----------



## Sylhouette (Oct 19, 2011)

Short answer.

GPT and the geom classes like label, mirror and stripe do not work when used both


Long answer.

gstripe label and mirror, put there metadata at the end of the disk, GPTdoes that also.
So if you GPT your disk, all is fine.
If you however start using the geom classes , the will overwrite the GPT metadata.

What bugs me is that with the new 9.0 release, GPT is set to default.
So people who install there new server and use gmirror to mirror the disk, will fall into this pitfall.
There are a lot discussions on the mailing list about this.
I opt for a warning at install level when GPT is used, you can get into trouble using gmirror and the like.


To overcome your problem you can mirror the slices seperately.
So instead of using the whole disk, just mirror ada1p1 and ada1p2 and so on.

use the following as a guide.

http://unix-heaven.org/node/24

regards
Johan Hendriks


----------



## hishnik (Jan 17, 2012)

Hello.

I've used *gmirror label -h* combined with *newfs -r 2*. Don't know. Maybe *-r 1* would be enough. It works fine.

Another problem I have, is: I need command to make clean detach of one disk without clearing metadata. Is it possible?

More comprehensive description: I need to mirror /boot partition to md0 (for example), then I want to detach my bootable pen-drive and make it possible to boot from it next time. For now it works well, but when I'm booting from this drive gmirror reports of errors.

May I detach gmirror provider without clearing metadata and setting "clean" bit on it?

THNX


----------



## raitech (Apr 2, 2012)

I have two disks without the same size, so the only  way to do raid1 with both is slice-by-slice (or partitions, in means of GPT). And this misbehaviour came up. I couldn't stop my mirrors. So, as sugested by sylhouette, mirroring only the slices does not work. I am using the 9.0-RELEASE amd64.


----------



## Leander (Apr 3, 2012)

> I have two disks without the same size, so the only way to do raid1 with both is slice-by-slice (or partitions, in means of GPT). And this misbehaviour came up. I couldn't stop my mirrors. So, as sugested by sylhouette, mirroring only the slices does not work. I am using the 9.0-RELEASE amd64.



- Well you could still use the conservative BSD slices to prevent this misbehaviour (which I don't recommend)
- The mirror functionallity is btw. still given with GPT - nothing seems to go wrong in mirroring - it's just that the stop command doesn't result as expected. My described workaround is still giving you the chance to force a stop. So according to the core functionallity mirroring, you could actually ignore this issue.



> I have two disks without the same size


You do not necessarily have to make partitions to get mirror running. gmirror will automatically take the sice of the smallest unit / the smallest component. Except you don't want to compromise on losing valuable storage space. (Keep in mind that highest performance of mirror will be gained without making use of multiple partitions on one disk.)

Feel free to open a ticket to Pawel Jakub Dawidek <pjd@FreeBSD.org>. I've mailed him the issue once - but he unfortunately didn't reply - so I left it like this.


Greetings
Leander


----------

