Linux – What differences are there between labelling options that appear under /dev/disk/by-label and /dev/disk/by-partlabel

coreoslinuxpartition

I want to create a disk under CoreOS that is automatically mounted at /var/lib/docker

So I created a var-lib-docker.mount unit file to do it and decided to use the by-label path under /dev/disk.

Initially I found my partitions appear under the by-partlabel path.
It works great however.

In the process I found out that there is a program called e2label, and also under fdisk expert mode I can also create a partition label.

Having not found e2label initially I found I could label partitions with the word "DOCKER" in fdisk. But they actually come through to the path /dev/disk/by-partlabel and not /dev/disk/by-label

What are the differences between these? should one be favoured over the other?

Best Answer

The ArchLinux wiki has (as always) good documentation on this issue. You wrote:

Having not found e2label initially I found I could label partitions with the word "DOCKER" in fdisk. But they actually come through to the path /dev/disk/by-label

I assume you meant "do NOT come through"? That could be explained by the fact that you created a partition label and your labeled disk should show up under /dev/disk/by-partlabel/ instead. Once you create a filesystem label (e.g. via e2label (tune2fs -L) for ext{2,3,4} file systems), the disk should show up under /dev/disk/by-label.

should one be favoured over the other?

partition labels are only available for GPT disks. For filesystem labels one would need some filesystem tool to apply a label to the partition. All major on-disk file systems seem to have this (tune2fs -L, jfs_tune -L, xfs_admin -L, reiserfstune -l) so unless it's something more exotic, file system labels should work just fine.