Persistent block device naming

From ArchWiki
Revision as of 15:09, 21 September 2011 by James Eder (Talk | contribs) (remove contractions)

Jump to: navigation, search

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.

Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어

External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

Template:Article summary start Template:Article summary text Template:Article summary heading Template:Article summary wiki Template:Article summary wiki Template:Article summary end

This article describes how to use persistent names for your block devices. This has been made possible by the introduction of udev and has some advantages over bus-based naming. If your machine has more than one SATA, SCSI or IDE disk controller, the order in which their corresponding device nodes are added is random. This may result in device names like Template:Filename and Template:Filename switching around randomly on each boot, culminating in an unbootable system, kernel panic, or a block device disappearing. Persistent naming solves these issues. Note that if you are using LVM2, this article is not relevant as LVM takes care of this automatically.

Persistent naming methods

There are four different schemes for persistent naming: by-label, by-uuid, by-id and by-path. The following sections describes what the different persistent naming methods are and how they are used.


Almost every filesystem type can have a label. All your partitions that have one are listed in the Template:Filename directory. This directory is created and destroyed dynamically, depending on whether you have partitions with labels attached.


The labels of your filesystems can be changed, but note that they have to be unambiguous to prevent any possible conflicts. Following are some methods for changing labels on common filesystems:

# mkswap -L <label> /dev/XXX
Warning: This command will destroy your running swap.
If your swap is mounted, run Template:Codeline before and Template:Codeline.
# e2label /dev/XXX <label>
# reiserfstune -l <label> /dev/XXX
# jfs_tune -L <label> /dev/XXX
# xfs_admin -L <label> /dev/XXX
fat/vfat (mtools package) 
# mlabel -i /dev/XXX ::<label>
ntfs (ntfsprogs package) 
# ntfslabel /dev/XXX <label>
Tip: Labels can be up to 16 characters long.


UUID is a mechanism to give each filesystem a unique identifier. It is designed so that collisions are unlikely. All GNU/Linux filesystems (including swap) support UUID. FAT and NTFS filesystems do not support UUID, but are still listed in Template:Filename with a unique identifier:


As you can see, the FAT and NTFS partitions (fat and windows labels above) have shorter names, but are still listed. The advantage about using the UUID method is that it is less likely that you have name collisions than with labels. The disadvantage is that UUIDs lose any readability advantage.

By-id and by-path

by-id creates a unique name depending on the hardware serial number. by-path creates a unique name depending on the shortest physical path (according to sysfs). Both contain strings to indicate which subsystem they belong to (i.e. "-ide-", for 'by-path', and "ata-" for 'by-id') and thus are not suitable for solving the problems mentioned in the beginning of this article. They will not be discussed any further here.

Using persistent naming

There are various applications that can be configured using persistent naming. Following are some examples of how to configure them.


To enable persistent naming in Template:Filename replace the device kernel name in the first column with the persistent name path as follows:

/dev/disk/by-label/home ...
/dev/disk/by-uuid/31f8eb0d-612b-4805-835e-0e6d8b8c5591 ...

or directly specify the persistent name type using a prefix:

LABEL=home ...
UUID=1f8eb0d-612b-4805-835e-0e6d8b8c5591 ...

Boot managers

To use persistent names in your boot manager, the following prerequisites must be met:

  • You are using a mkinitcpio initial RAM disk image
  • You have udev enabled in Template:Filename
  • When your initramfs image was generated, version 101-3 or greater of klibc-udev was installed (persistent naming is broken in any earlier version). If you are updating klibc-udev from an earlier version and want to use persistent naming, regenerate your initramfs image before you reboot.

In the above example, Template:Filename is the root partition. In the GRUB Template:Filename file, the kernel line looks like this:

kernel /boot/vmlinuz-linux root=/dev/sda1 ro quiet

Depending on which naming scheme you would prefer, change it to one of the following:

kernel /boot/vmlinuz-linux root=/dev/disk/by-label/root ro quiet


kernel /boot/vmlinuz-linux root=/dev/disk/by-uuid/2d781b26-0285-421a-b9d0-d4a0d3b55680 ro quiet

If you are using LILO, then do not try this with the Template:Codeline configuration option; it will not work. Use Template:Codeline or Template:Codeline instead. Read the LILO man page for more information on append and addappend.

There is an alternative way to use the label embedded in the filesystem. For example if (as above) the filesystem in Template:Filename is labeled "root", you would give this line to GRUB:

 kernel /boot/vmlinuz-linux root=LABEL=root ro quiet