Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I've noticed that Linux distributions typically have a /dev/disk/by-label directory, but this isn't always the case (For example, the CirrOS Linux test image doesn't have one).

What's required on a Linux system for the /dev/disk/by-label directory to be properly populated?

share|improve this question
I don't know this, but I guess udev has something to do with that kind of stuff. – user13742 Nov 21 '12 at 12:45

2 Answers 2

up vote 4 down vote accepted

On most modern Linux systems, pretty much everything under /dev is put there by udev.

On my Debian machine, /dev/disk/by-label comes from several files under /lib/udev/rules.d For example, here is a rule from 60-persistent-storage.rules:

ENV{ID_FS_LABEL_ENC}=="?*",     ENV{ID_FS_USAGE}=="filesystem|other", \

A few lines earlier is where ID_FS_LABEL_ENC comes from:

# probe filesystem metadata of disks
KERNEL!="sr*", IMPORT{program}="/sbin/blkid -o udev -p $tempnode"

You can run blkid yourself to see the data its passing to udev:

root@Zia:~# /sbin/blkid -o udev -p /dev/sda2

And indeed:

root@Zia:~# ls -l /dev/disk/by-label/xfer1 
lrwxrwxrwx 1 root root 10 Nov 19 10:02 /dev/disk/by-label/xfer1 -> ../../sda2

You can put additional rules files in /etc/udev/rules.d/ if you'd like to make additional names for devices, change permissions, etc. E.g., here we have one that populates and sets the permissions on a /dev/disk/for-asm.

share|improve this answer

udisks-daemon is probably doing that (although HAL or DBUS could, also). You can watch it happen if you're so inclined. Open a termanal and run:

udisks --monitor-detail

and then plug in a drive. You'll get something like:

job-changed: /org/freedesktop/UDisks/devices/sdb1
  job underway:                FilesystemMount, initiated by uid 1000
changed:     /org/freedesktop/UDisks/devices/sdb1
Showing information for /org/freedesktop/UDisks/devices/sdb1
  native-path:                 /sys/devices/pci0000:00/0000:00:1a.7/usb1/1-4/1-4:1.0/host3/target3:0:0/3:0:0:0/block/sdb/sdb1
  device:                      8:17
  device-file:                 /dev/sdb1
    presentation:              /dev/sdb1
    by-id:                     /dev/disk/by-id/usb-SanDisk_Cruzer_20054858820EEB607D7D-0:0-part1
    by-id:                     /dev/disk/by-uuid/D033-D063
    by-path:                   /dev/disk/by-path/pci-0000:00:1a.7-usb-0:4:1.0-scsi-0:0:0:0-part1
  detected at:                 Wed 21 Nov 2012 07:45:47 AM EST
  system internal:             0
  removable:                   0
  has media:                   1 (detected at Wed 21 Nov 2012 07:45:47 AM EST)
    detects change:            0
    detection by polling:      0
    detection inhibitable:     0
    detection inhibited:       0
  is read only:                0
  is mounted:                  1
  mount paths:             /media/CRUZER
  mounted by uid:              1000
  presentation hide:           0
  presentation nopolicy:       0
  presentation name:           
  presentation icon:           
  size:                        8000094208
  block size:                  512
  job underway:                no
  usage:                       filesystem
  type:                        vfat
  version:                     FAT32
  uuid:                        D033-D063
  label:                       CRUZER
    part of:                   /org/freedesktop/UDisks/devices/sdb
    scheme:                    mbr
    number:                    1
    type:                      0x0b
    offset:                    16384
    alignment offset:          0
    size:                      8000094208
share|improve this answer
Also, for an interesting read on the history / development of udisk – charlesbridge Nov 21 '12 at 14:45
Actually, it's all udev—it has nothing to do with udisks. – derobert Nov 21 '12 at 16:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.