Glabelling drives

From FBSD_tips

Jump to: navigation, search

Back to "Admin building blocks"

How to keep track of your drives in a more human friendly fashion, or "how one device renumbering can ruin your whole day".

Contents

[edit] Rationale

Glabel can put a descriptive label into the metadata on a drive and cause the system to recognize this label and 'call' it by that name (in /dev/label) for purposes of filesystem mounting/maintenance/etc. This can be very handy as device attachment is not always guaranteed to be the same. This is especially true with external media like flash 'thumb' drives and USB/Firewire hard disks but can also come in really handy if you are adding/moving controllers and/or drives. The 'stackable' nature of Glabel also lets you label other GEOM entities (mirrors, stripes ...)!

[edit] Setup

If you do not have glabel loaded on boot, do it now.

kldload geom_label

Labelling one drive:

glabel label label1 ad10

Now, we have a new device in /dev/label/

# ls -l /dev/label
total 0
crw-r-----  1 root  operator    0,  98 Oct 11 07:28 label1

[edit] Using

We can newfs and mount it.

# newfs /dev/label/label1
/dev/label/label1: 95396.3MB (195371564 sectors) block size 16384, fragment size 2048
        using 520 cylinder groups of 183.77MB, 11761 blks, 23552 inodes.
super-block backups (for fsck -b #) at:
 160, 376512, 752864, ...
# mount /dev/label/label1 /mnt
# df /mnt
Filesystem        1K-blocks Used    Avail Capacity  Mounted on
/dev/label/label1  94607292    4 87038706     0%    /mnt

[edit] Booting from a Glabel

A very nice use of this label van be to boot from it and avoid various device reordering confusions. T accomplish this you have load the glabel kernel object on boot.

# echo 'geom_label_load="YES' >> /boot/loader.conf

Now you can add the labels to your /etc/fstab as a replacement to the device names.

[edit] Discussion

Glabel is in the GENERIC kernel as of 7.0.

If you may ever want to put the glabelled drive in another machine you might want to label it e.g. the name of the machine for instance. This would avoid name collision.

Glabel will write it's data to the end of the disk or slice. UFS leaves this space open, other filesystems may not. Make sure that the last filesystem on the drive is UFS ot you could have trouble.

Glabel is limited to 8 characters.

Wan to see all your partitions? Easy with Glabel :

sysctl -b kern.geom.conftxt

FzZzT Has discussed some pros and cons of the glabel method too.


Gongo 16:52, 11 October 2007 (UTC)

Personal tools