# Where does glabel store the metadata?



## Swapjim (Oct 29, 2015)

I understand that the label is stored somewhere inside the disk, but where?

The handbook says:



			
				FreeBSD handbook said:
			
		

> glabel stores the label in the last sector of a given provider



but where exactly is that? Is this the MBR? 

I admit I'm a newbie as to the topology of HDDs, so any information I get I'll have to research to understand the answer.

This question is for me to understand whether giving a label to an NTFS partition (USB portable HDD) can cause data corruption or reading problems when I connect it to a Windows OS.


----------



## usdmatt (Oct 29, 2015)

In GEOM, the 'provider' is the disk (or partition, or whatever you ask glabel to label). So if you label a raw disk, it will go in the very last sector at the end of the disk. If you label a partition, it will go at the end of the partition, etc, etc.

I'm not a big fan of glabels generally. If you label an NTFS partition, it will go right at the end, which for the most part will probably remain untouched by Windows. Of course it's still part of the partition and there's nothing actually stopping Windows overwriting it if it wants to.


----------



## tobik@ (Oct 29, 2015)

Swapjim said:


> This question is for me to understand whether giving a label to an NTFS partition (USB portable HDD) can cause data corruption or reading problems when I connect it to a Windows OS.


Why not use GPT then? Windows understands it as does FreeBSD and it natively supports labels.


----------



## wblock@ (Oct 29, 2015)

usdmatt said:


> I'm not a big fan of glabels generally. If you label an NTFS partition, it will go right at the end, which for the most part will probably remain untouched by Windows. Of course it's still part of the partition and there's nothing actually stopping Windows overwriting it if it wants to.



On the FreeBSD side, this won't be a problem.  The glabel(8) metadata is separate, and not part of the device.  Use /dev/label/_myntfsname_ and that device is one block smaller than the partition or disk it refers to.

On Windows, there is always the chance that it will helpfully blow away anything not invented by Microsoft.  Yes, this is probably even worse with generic labels, because Windows is guaranteed not to understand them.  As tobik suggests, this is a reason to use GPT, where the label metadata is in the GPT itself.  Of course, there are problems with using GPT for booting some versions of Windows.  I don't know the status of GPT support for data disks with Windows 7, but it will probably work due to the PMBR.


----------



## Swapjim (Oct 29, 2015)

I don't know what GPT is. Yesterday was the first time I read about glabel. I'll need to do search for GPT once I post this. Having said that, I'll need to ask a couple of things.

1. Is there anything I can do to make sure, or at least to be more sure, that Windows will not remove the label? For example, not filling the whole drive.



wblock@ said:


> Of course, there are problems with using GPT for booting some versions of Windows.



2. If I don't plan to boot from this particular drive, is this still a problem? For example, can it cause a problem if it's connected when I boot, even through I boot from another drive.


----------



## wblock@ (Oct 30, 2015)

GPT is the new kind of disk partitioning that fixes most of the problems of MBR.  The label metadata on a GPT partitioned disk is stored in the GPT, so is safe from Windows.

If you had to do MBR, there might be a utility to mark that last block of the disk as used by NTFS.


----------



## Swapjim (Nov 18, 2015)

To be frank, I haven't checked this. It's still pending thing. When I get to it, I'll return to this thread with my results (or more questions ). Thank you.


----------

