# gpt label under gmirror, not showing the gpt label, but the gpt partition



## da1 (Sep 29, 2011)

Hi guys,

Today I was in the process of creating a gmirror for the swap partition of 2 disks and I went along with using the GPT label:

```
[...]
gpart add -s 4G -t freebsd-swap -l swap00 ad0
gpart add -s 4G -t freebsd-swap -l swap01 ad1
```
The labels show up in /dev/gpt/ but when I use them for the gmirror, I get the partition name instead of the label (ex: ad0p2 instead of swap00).

My cmd's:

```
gmirror label -vb round-robin swap gpt/swap00
gmirror insert swap gpt/swap01
```

Result:

```
Name    Status  Components
mirror/swap  COMPLETE  ad0p2
                       ad1p2
```

Am I missing something here ?


PS: not sure if I posted this already or not.


----------



## Sebulon (Sep 29, 2011)

This immediately came to mind:
http://forums.freebsd.org/showthread.php?t=24695
Could be related.

/Sebulon


----------



## wblock@ (Sep 29, 2011)

gmirror status goes through geom(8).  I believe this is a lower level that doesn't know about GPT labels, but they're working because it found the correct partitions.  Test it: shut down and swap cables so the drives are renumbered.  It should come up without rebuilding or complaining about the mirror.


----------



## da1 (Sep 29, 2011)

First of all, nice new color wblock.

ATM, I'm thinking if we really need glabels if we can simply use the gpart labels (even if we see "ad0p2" instead of a nice and shinny label). Nevertheless, would be nice to be able to use the GPT labels and not (g)label something that was already labeled.


----------



## wblock@ (Sep 29, 2011)

da1 said:
			
		

> First of all, nice new color wblock.



Thanks!



> ATM, I'm thinking if we really need glabels if we can simply use the gpart labels (even if we see "ad0p2" instead of a nice and shinny label). Nevertheless, would be nice to be able to use the GPT labels and not (g)label something that was already labeled.



The GPT labels are working--it's how the mirror partitions were found.  I think it's just that GEOM happens at a lower level, and gmirror status is just a straight-through call to geom(8).  So it's not showing the label name, but it is using the label to find the right thing.  Like resolving a hostname to an IP address.

Even gpart(8) doesn't show labels by default, and it knows all about GPT labels.


----------



## Sebulon (Sep 30, 2011)

Hi,

I tested your procedure on a VMWare virtual install:


```
# uname -a
FreeBSD restora.slu.se 8.2-RELEASE FreeBSD 8.2-RELEASE #0: Thu Feb 17 02:41:51 UTC 2011     
root@mason.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64
```

gpart

```
# cleandrives ad0 ad1
Drive ad0 verified.
Drive ad1 verified.

This will irreversibly destroy partition- and filesystem data on drive(s):
ad0 ad1

USE WITH EXTREME CAUTION!
Do you confirm "yes/no": yes

Drive(s) cleaned.
# gpart create -s gpt ad0
ad0 created
# gpart create -s gpt ad1
ad1 created
# gpart add -t freebsd-swap -l swap00 ad0
ad0p1 added
# gpart add -t freebsd-swap -l swap01 ad1
ad1p1 added
# gmirror label -vb round-robin swap gpt/swap00
Metadata value stored on gpt/swap00.
Done.
# gmirror status
       Name    Status  Components
mirror/swap  COMPLETE  ad0p1
# gmirror insert swap gpt/swap01
# gmirror status
       Name    Status  Components
mirror/swap  DEGRADED  ad0p1
                       ad1p1 (6%)
# ls -lah /dev/gpt
total 2
dr-xr-xr-x   2 root  wheel   512B Sep 30 07:26 .
dr-xr-xr-x  10 root  wheel   512B Sep 30 09:21 ..
# gmirror deactivate swap ad1p1
# gmirror deactivate swap ad0p1
# gmirror status
# gpart delete -i 1 ad1
ad1p1 deleted
# gpart delete -i 1 ad0
ad0p1 deleted
# gpart destroy ad1
ad1 destroyed
# gpart destroy ad0
ad0 destroyed
```

glabel

```
# cleandrives ad0 ad1
Drive ad0 verified.
Drive ad1 verified.

This will irreversibly destroy partition- and filesystem data on drive(s):
ad0 ad1

USE WITH EXTREME CAUTION!
Do you confirm "yes/no": yes

Drive(s) cleaned.
# glabel label swap00 ad0
# glabel label swap01 ad1
# gmirror label -vb round-robin swap label/swap00
Metadata value stored on label/swap00.
Done.
# gmirror insert swap label/swap01

...

# gmirror status
       Name    Status  Components
mirror/swap  COMPLETE  label/swap00
                       label/swap01
# ls -lah /dev/label/
total 2
dr-xr-xr-x   2 root  wheel         512B Sep 30 07:50 .
dr-xr-xr-x  10 root  wheel         512B Sep 30 09:21 ..
crw-r-----   1 root  operator    0,  92 Sep 30 08:03 swap00
crw-r-----   1 root  operator    0,  94 Sep 30 08:03 swap01
# reboot

...

# gmirror status
       Name    Status  Components
mirror/swap  COMPLETE  label/swap00
                       label/swap01
```

I would suggest using glabel instead.

/Sebulon


----------



## da1 (Sep 30, 2011)

For the moment, I am using glabels but would be nice to be able to use the GPT labels.


----------



## wblock@ (Sep 30, 2011)

Is it more than a cosmetic problem?  What am I missing?  Oh, and also: gmirror With Disk Partitions


----------



## da1 (Sep 30, 2011)

Nothing more than a cosmetic problem.


----------



## Tsuroerusu (Oct 31, 2012)

I have been having this problem myself in some testing cases I did at work, I have however found the solution to this. 

When creating the mirror use the "-h" parameter, which will hardcode the providers' names into the metadata. This will solve the problem of disks appearing without GPT labels.

For reference, check the gmirror man page.

Also, Pawel used the "-h" paramenter in a ZFS HOWTO (gmirror used for swap) that he did two years ago, it can be found here: http://blogs.freebsdish.org/pjd/2010/08/06/from-sysinstall-to-zfs-only-configuration/


----------



## xeube (Nov 2, 2012)

@Sebulon,

Would it be possible to obtain your update version of the "cleandrives" script? I saw what you posted here and here. But it would be nice to see your updated version if it's not too much to ask. Thanks.


----------



## Sebulon (Nov 2, 2012)

xeube said:
			
		

> @Sebulon,
> 
> Would it be possible to obtain your update version of the "cleandrives" script? I saw what you posted here and here. But it would be nice to see your updated version if it's not too much to ask. Thanks.



You've already seen it The second link, Fast and easy delete of partition and filesystem data is the most updated version there is. Glad you find it useful!

/Sebulon


----------

