Persistent block device naming (Italiano)
|Summary help replacing me|
|An overview of persistent block device naming; the preferred method of referencing block devices.|
|Available in languages|
Note: You don't have to worry about this if you are using LVM2. LVM2 takes care of this automatically.
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.
Why persistent 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 or kernel panic. Persistent naming solves these issues.
Additionally, by-label, by-id and by-path methods provide human-readable names.
Which method should I use?
There are four different schemes for persistent naming:
Almost every filesystem type can have a label. All your partitions that have one are listed in the Template:Filename directory.
You can change the labels of your filesystems using these commands:
mkswap -L <label> /dev/XXX
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>
UUID, or Universally Unique Identifier, 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 by-uuid 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 won't be discussed any further here.
Enabling persistent naming
Based on the method of choice, enable persistent naming for your system:
Do so for all the partitions in your fstab file.
Instead of listing the device explicitly, one may specify the device via "LABEL=<label>" or "UUID=<uuid>" (e.g. "LABEL=boot" or "UUID=3e6be9de-8139-11d1-9106-a43f08d823a6").
In your boot manager
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.
kernel /boot/vmlinuz26 root=/dev/sda1 vga=0x318 ro
Depending on which naming scheme you would prefer, change it to one of the following:
kernel /boot/vmlinuz26 root=/dev/disk/by-label/root vga=0x318 ro
kernel /boot/vmlinuz26 root=/dev/disk/by-uuid/2d781b26-0285-421a-b9d0-d4a0d3b55680 vga=0x318 ro
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/vmlinuz26 root=LABEL=root vga=0x318 ro