# Labelling existing partitions with glabel



## mahashakti89 (Aug 17, 2013)

Hi,

I am using FreeBSD 9.2-RC2 with two partitions , one for root and one for swap. I tried to label both partitions with glabel using the method described in the manual, rebooted in single-user mode, labelled root with `glabel label FreeBSD /dev/ada0p2` and the same technique for swap. I did `ls -l /dev/label` to verify that both labels exist. It was O.K. but after doing a normal reboot, the /dev/label/ directory has disappeared... and the labels also!

I searched why but found no real clue... how to solve this "mystery".

Any help will be welcome.

mahashakti89

PS: geom_label.ko and geom_bsd.ko are present in the GENERIC kernel configuration and loaded at boot via loader.conf.


----------



## wblock@ (Aug 17, 2013)

First: don't use generic labels with GPT partitions.  It is not necessary and only complicates the setup.  Instead, use GPT labels with gpart(8):
`# gpart modify -i2 -l ezfreebsdfs ada0`
`# gpart modify -i3 -l ezswap      ada0`

These labels will appear in /dev/gpt/.

Second: use unique names for labels.  Add a couple of letters to the beginning or end of the name to help identify that particular partition uniquely.

As to labels "disappearing", the GEOM system hides labels when a that device is in use (mounted).


----------



## mahashakti89 (Aug 17, 2013)

Thanks for your answer.

I used the described method. I rebooted in single-user mode and created the two labels. I got a success message. After that the labels were present in /dev/gpt but disappeared after reboot. What did I do wrong?

Regards.


----------



## wblock@ (Aug 17, 2013)

Boot in single user mode, set the labels, and then reboot.  If you boot directly into multi-user mode after setting the labels, they will be overwritten.


----------



## mahashakti89 (Aug 17, 2013)

wblock@ said:
			
		

> Boot in single user mode, set the labels, and then reboot.  If you boot directly into multi-user mode after setting the labels, they will be overwritten.



I had already done this but same problem. I did another verification, rebooted in single-user mode, the labels are present, rebooted again and they had disappeared.

Regards.


----------



## wblock@ (Aug 17, 2013)

Please show the output of `gpart show -l` after booting.  Remember that GEOM may hide the labels (not show them in /dev/gpt/) if they have been used to mount the partition.


----------



## mahashakti89 (Aug 17, 2013)

wblock@ said:
			
		

> Please show the output of `gpart show -l` after booting.  Remember that GEOM may hide the labels (not show them in /dev/gpt/) if they have been used to mount the partition.




```
gpart show -l
                     [root@ishwara /usr/home/claude]# gpart show -l
=>        34  1953525101  ada0  GPT  (931G)
          34         128     1  freebsd-boot  (64k)
         162   266338176     2  freebsd  (127G)
   266338338     8390622     7  freebsdswap  (4.0G)
   274728960   247515136     3  (null)  (118G)
   522244096   167936000     4  Kali  (80G)
   690180096   256000000     5  (null)  (122G)
   946180096     8388608     6  (null)  (4.0G)
   954568704   998956431        - free -  (476G)
```

I forgot the couple of letters at the beginning, the other partitions are Linux partitions. Is that crucial or only a memory help ?

I have nothing more in /dev/ufs or /dev/label. I destroyed the labels created by glabel doing `glabel destroy freebsd`.

Same technique for freebsdswap.

Regards.


----------



## wblock@ (Aug 17, 2013)

See post #2 about the letters.  Please show the output of `mount`.


----------



## mahashakti89 (Aug 17, 2013)

wblock@ said:
			
		

> See post #2 about the letters.  Please show the output of `mount`.




```
mount 
/dev/ada0p2 on / (ufs, local, journaled soft-updates)                                                                                                                                                                                         
devfs on /dev (devfs, local, multilabel)                                                                                                                                                                                                        
/dev/md0 on /tmp (ufs,local)                                                                                                                                                                                                                   
linprocfs on /compat/linux/proc (linprocfs, local)
```

Regards.


----------



## wblock@ (Aug 17, 2013)

This still looks like GEOM hiding the labels.  Boot into single user mode and try to mount the filesystem with the GPT label:
`# mount -u /dev/gpt/freebsd /`


----------



## mahashakti89 (Aug 17, 2013)

wblock@ said:
			
		

> This still looks like GEOM hiding the labels.  Boot into single user mode and try to mount the filesystem with the GPT label:
> `# mount -u /dev/gpt/freebsd /`



I rebooted in single user mode, did  `# mount -u /dev/gpt/freebsd /` but I got the following answer: 
	
	



```
/dev/gpt/freebsd : No such file or directory
```

I did 

`# ls -l /dev/gpt`, there was no /dev/gpt/freebsd at all.
`# gpart show -l ada0`. The labels are present.
Then I rebooted one more time in  single user mode, did operations 1 and 2 . It seemed O.K. But as I did `# mount -u /dev/gpt/freebsd /` I got the same answer 
	
	



```
No such file or directory
```

Regards.


----------



## wblock@ (Aug 17, 2013)

The vague wording has me confused.  It's not clear whether the labels ever appeared in /dev/gpt/.


----------



## mahashakti89 (Aug 17, 2013)

wblock@ said:
			
		

> The vague wording has me confused.  It's not clear whether the labels ever appeared in /dev/gpt/.



The first time I rebooted in single user mode to do as you requested: `# mount -u /dev/gpt/freebsd /` the only label present in /dev/gpt was that for the swap partition. I didn't understand. Did another reboot in single user mode, both labels were present in /dev/gpt, that for the root partition and the other for swap but as I said I couldn't mount /dev/gpt/freebsd. 
	
	



```
"/dev/gpt/freebsd :No such file or directory"
```

Regards


----------



## wblock@ (Aug 17, 2013)

This still looks like it's because GEOM is preventing access to the labels because it's already mounted.  Change /etc/fstab to use the GPT labels, then reboot.


----------



## mahashakti89 (Aug 18, 2013)

Hi,

Working! Thanks. I thought it was too risky to edit /etc/fstab and then to reboot if the labels are not visible.

Thanks.


----------



## wblock@ (Aug 18, 2013)

The worst that will happen is it will not find the device when booting.  Then you would have to enter the boot device by hand.


----------

