On Thu, Jan 03, 2013 at 08:08:00PM +0100, Helmut Hullen wrote:
> Hallo, Hugo,
> 
> Du meintest am 03.01.13:
> 
> >>>> But for what purpose offers "mkfs.btrfs" this option?
> 
> >>>    So that you don't have to run the label command immediately
> >>>    after making the filesystem.
> 
> 
> >> But other filesystems don't put the label onto more than 1 device.
> >> There's the problem for/with btrfs.
> 
> >    Aargh. How many times do I have to say this?
> 
> >    Devices are not given labels.
> >    *Filesystems* are given labels.
> 
> And "mkfs.btrfs" combines working with devices and working with a  
> filesystem.

   As do all mkfs implementations. They write a filesystem to a device
(or devices), and optionally give the filesystem a label. They don't
put labels on devices, except incidentally where each filesystem
exists on one or more devices.

>         blkid /dev/sdb
> 
> shows (if set) the label of a device (among other data).

   No, it shows the label of the filesystem that lives on that device.
Other devices may have another part of the same filesystem on them,
and will show the same label.

   I repeat: devices do not have labels.

> >> The label has to be unique for the whole machine.
> 
> >    Wrong. You can have several filesystems on a machine with the same
> > label.
> 
> On my machines that doesn't work when I use programs like "blkid" or  
> "findfs". They don't work when there is more than 1 device with the same  
> label. That's no special btrfs problem, that happens with (p.e.) ext4fs  
> too.

   OK, and that's a blkid problem, not a btrfs problem.

> > It doesn't mean that they're easily managable, but there's
> > nothing that will stop it from happening.
> 
> >    If you want a unique label for a *device*, take a look at the
> > symlinks in /dev/disk/by-id, and the udev rules that generate them.
> 
> Sorry - I don't use "udev" (I've told it long time ago). And I still  
> believe that "btrfs" doesn't depend on "udev".

   No, btrfs doesn't depend on udev.

   However, trying to make a unique device label out of a filesystem
label won't work. This isn't a bug, it's not something that was ever
guaranteed, it's just the wrong approach. You need to find another
one -- see below for the options that I can see.

> > Trying to use filesystem labels to give unique and stable device IDs
> > is the wrong tool for the job.
> 
> I beg to differ. On my machines it's the simpliest way, and it's a sure  
> way.

   No, because *it* *doesn't* *work*. This is not a bug. This is how
things have always behaved -- you're relying on an assumption (one FS
per device) which simply isn't true any longer.

   You may think it's simpler, but that's because your assumptions are
incorrect. The world does not work the way you think it does. I'm
sorry this makes things hard for you, but what you're asking for is
not in scope for a filesystem -- any filesystem.

> [...]
> 
> 
> >    As I said above, you're expecting something which just isn't true.
> > Filesystems have labels, not devices. If you want to have unique
> > labels on devices, then you're going to have to write some udev rules
> > to generate them for you, and then refer to /dev/helmuts-devices/foo
> > (or whatever you want to call them).
> 
> And how is the way for a system which doesn't use "udev"?

   There isn't one ready-made. Your options are:

 * run udev

 * write something which uses (e.g.) SMART information on block
   devices to extract a unique ID, and convert that into a stable
   device label (which is effectively what udev does)

 * find some piece of the device which isn't going to be overwritten
   by partition tables, GPTs, filesystems, or other kinds of metadata,
   and write your label into there; again, you will need to develop
   your own tool for reading/writing this information

> Labelling via "btrfs filesystem label <device> <label>" works well.

   Clearly it doesn't, because you're having problems with it. The
behaviour where only one device in the FS gets the label, immediately
after a btrfs label command, is a bug -- *all* of the devices in the
FS should get the label. You're trying to rely on the behaviour of a
bug, not on the designed behaviour of the system.

   You need to find some other way of doing this. btrfs is working as
it should, and I'm afraid you're using the wrong tools for the job
you're trying to do.

   Hugo.

-- 
=== Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk ===
  PGP key: 515C238D from wwwkeys.eu.pgp.net or http://www.carfax.org.uk
                     --- O tempura! O moresushi! ---                     

Attachment: signature.asc
Description: Digital signature

Reply via email to