- Persistent block device naming
- Contents
- Persistent naming methods
- by-label
- by-uuid
- by-id and by-path
- by-partlabel
- by-partuuid
- Static device names with udev
- Using persistent naming
- fstab
- Kernel parameters
- Linux: Mount Disk Partition Using LABEL
- Syntax: Mount Command With Label
- Update /etc/fstab File
- See also:
- [bash][conky][fs label] Как узнать метку тома ??
- Arch Linux
- #1 2015-05-16 08:05:23
- Error /dev/disk/by-label/ARCH-2015 did not show up
- #2 2015-05-16 09:49:09
- Re: Error /dev/disk/by-label/ARCH-2015 did not show up
- #3 2015-05-16 10:42:10
- Re: Error /dev/disk/by-label/ARCH-2015 did not show up
- #4 2015-05-16 11:45:33
- Re: Error /dev/disk/by-label/ARCH-2015 did not show up
- #5 2015-05-16 13:45:36
- Re: Error /dev/disk/by-label/ARCH-2015 did not show up
- #6 2015-05-17 12:16:18
- Re: Error /dev/disk/by-label/ARCH-2015 did not show up
- #7 2015-05-17 12:29:41
- Re: Error /dev/disk/by-label/ARCH-2015 did not show up
- #8 2015-05-17 15:59:20
- Re: Error /dev/disk/by-label/ARCH-2015 did not show up
- #9 2015-05-17 17:34:13
- Re: Error /dev/disk/by-label/ARCH-2015 did not show up
- #10 2015-05-18 21:16:50
- Re: Error /dev/disk/by-label/ARCH-2015 did not show up
- #11 2015-11-14 06:23:41
- Re: Error /dev/disk/by-label/ARCH-2015 did not show up
- #12 2015-12-27 19:35:33
- Re: Error /dev/disk/by-label/ARCH-2015 did not show up
- #13 2015-12-28 06:47:04
- Re: Error /dev/disk/by-label/ARCH-2015 did not show up
Persistent block device naming
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 arbitrary. This may result in device names like /dev/sda and /dev/sdb switching around on each boot, culminating in an unbootable system, kernel panic, or a block device disappearing. Persistent naming solves these issues.
Contents
Persistent naming methods
There are four different schemes for persistent naming: by-label, by-uuid, by-id and by-path. For those using disks with GUID Partition Table (GPT), two additional schemes can be used by-partlabel and by-partuuid. You can also use static device names by using Udev.
The directories in /dev/disk/ are created and destroyed dynamically, depending on whether there are devices in them.
The following sections describe what the different persistent naming methods are and how they are used.
The lsblk command can be used for viewing graphically the first persistent schemes:
For those using GPT, use the blkid command instead. The latter is more convenient for scripts, but more difficult to read.
by-label
Almost every file system type can have a label. All your volumes that have one are listed in the /dev/disk/by-label directory.
Most file systems support setting the label upon file system creation, see the man page of the relevant mkfs.* utility. For some file systems it is also possible to change the labels. Following are some methods for changing labels on common file systems:
swap swaplabel -L «new label» /dev/XXX using util-linux ext2/3/4 e2label /dev/XXX «new label» using e2fsprogs btrfs btrfs filesystem label /dev/XXX «new label» using btrfs-progs reiserfs reiserfstune -l «new label» /dev/XXX using reiserfsprogs jfs jfs_tune -L «new label» /dev/XXX using jfsutils xfs xfs_admin -L «new label» /dev/XXX using xfsprogs fat/vfat fatlabel /dev/XXX «new label» using dosfstools mlabel -i /dev/XXX ::»new label» using mtools exfat tune.exfat -L «new label» /dev/XXX using exfatprogs exfatlabel /dev/XXX «new label» using exfatprogs or exfat-utils ntfs ntfslabel /dev/XXX «new label» using ntfs-3g udf udflabel /dev/XXX «new label» using udftools crypto_LUKS (LUKS2 only) cryptsetup config —label=»new label» /dev/XXX using cryptsetup
The label of a device can be obtained with lsblk:
by-uuid
UUID is a mechanism to give each filesystem a unique identifier. These identifiers are generated by filesystem utilities (e.g. mkfs.* ) when the device gets formatted and are designed so that collisions are unlikely. All GNU/Linux filesystems (including swap and LUKS headers of raw encrypted devices) support UUID. FAT, exFAT and NTFS filesystems do not support UUID, but are still listed in /dev/disk/by-uuid/ with a shorter UID (unique identifier):
The UUID of a device can be obtained with lsblk:
The advantage of using the UUID method is that it is much less likely that name collisions occur than with labels. Further, it is generated automatically on creation of the filesystem. It will, for example, stay unique even if the device is plugged into another system (which may perhaps have a device with the same label).
The disadvantage is that UUIDs make long code lines hard to read and break formatting in many configuration files (e.g. fstab or crypttab). Also every time a volume is reformatted a new UUID is generated and configuration files have to get manually adjusted.
by-id and by-path
by-id creates a unique name depending on the hardware serial number, by-path depending on the shortest physical path (according to sysfs). Both contain strings to indicate which subsystem they belong to (i.e. pci- for by-path , and ata- for by-id ), so they are linked to the hardware controlling the device. This implies different levels of persistence: the by-path will already change when the device is plugged into a different port of the controller, the by-id will change when the device is plugged into a port of a hardware controller subject to another subsystem. [1] Thus, both are not suitable to achieve persistent naming tolerant to hardware changes.
However, both provide important information to find a particular device in a large hardware infrastructure. For example, if you do not manually assign persistent labels ( by-label or by-partlabel ) and keep a directory with hardware port usage, by-id and by-path can be used to find a particular device.[2] [3]
by-id also creates World Wide Name links of storage devices that support it. Unlike other by-id links, WWNs are fully persistent and will not change depending on the used subsystem.
This article or section needs expansion.
by-partlabel
GPT partition labels can be defined in the header of the partition entry on GPT disks.
This method is very similar to the filesystem labels, except the partition labels do not get affected if the file system on the partition is changed.
All partitions that have partition labels are listed in the /dev/disk/by-partlabel directory.
The partition label of a device can be obtained with lsblk:
by-partuuid
Like GPT partition labels, GPT partition UUIDs are defined in the partition entry on GPT disks.
MBR does not support partition UUIDs, but Linux[5] and software using libblkid[6] (e.g. udev[7]) are capable of generating pseudo PARTUUIDs for MBR partitions. The format is SSSSSSSS—PP , where SSSSSSSS is a zero-filled 32-bit MBR disk signature, and PP is a zero-filled partition number in hexadecimal form. Unlike a regular PARTUUID of a GPT partition, MBR’s pseudo PARTUUID can change if the partition number changes.
The dynamic directory is similar to other methods and, like filesystem UUIDs, using UUIDs is preferred over labels.
The partition UUID of a device can be obtained with lsblk:
Static device names with udev
Using persistent naming
There are various applications that can be configured using persistent naming. Following are some examples of how to configure them.
fstab
Kernel parameters
To use persistent names in kernel parameters, the following prerequisites must be met. On a standard installation following the installation guide both prerequisites are met:
- You are using an initramfs image that has udev in it.
- For mkinitcpio, enable either the udev or systemd hook in /etc/mkinitcpio.conf
The location of the root filesystem is given by the parameter root on the kernel command line. The kernel command line is configured from the boot loader, see Kernel parameters#Configuration. To change to persistent device naming, only change the parameters which specify block devices, e.g. root and resume , while leaving other parameters as is. Various naming schemes are supported:
Persistent device naming using label and the LABEL= format, in this example Arch Linux is the LABEL of the root file system.
Persistent device naming using UUID and the UUID= format, in this example 0a3407de-014b-458b-b5c1-848e92a327a3 is the UUID of the root file system.
Persistent device naming using disk id and the /dev path format, in this example wwn-0x60015ee0000b237f-part2 is the id of the root partition.
Persistent device naming using GPT partition UUID and the PARTUUID= format, in this example 98a81274-10f7-40db-872a-03df048df366 is the PARTUUID of the root partition.
Persistent device naming using GPT partition label and the PARTLABEL= format, in this example GNU/Linux is the PARTLABEL of the root partition.
Источник
Linux: Mount Disk Partition Using LABEL
H ow do I mount the filesystem (disk partition) using the filesystem label on the ext3/ext4 file system located on USB disk or hard disk under Linux operating systems?
The e2label command will display or set the filesystem label. The mount command has the option to mount partition that has the specified label. To see your current label type the following command:
# e2label /dev/sdc1
Sample outputs:
Syntax: Mount Command With Label
The syntax is as follows:
- No ads and tracking
- In-depth guides for developers and sysadmins at Opensourceflare✨
- Join my Patreon to support independent content creators and start reading latest guides:
- How to set up Redis sentinel cluster on Ubuntu or Debian Linux
- How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
- How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
- A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
- How to protect Linux against rogue USB devices using USBGuard
Join Patreon ➔
To mount the /dev/sdc1 using the seagate_2tb_usb label at /media/usb, enter:
# mkdir -p /media/usb
# mount -L seagate_2tb_usb /media/usb
# df -H
Sample outputs:
Please note that my actual device name is /dev/sdf1. Feel free to replace actual label names and mount point as per your requirements.
Update /etc/fstab File
You can update the /etc/fstab file as follows to mount it automatically using the disk label:
See also:
🐧 Get the latest tutorials on Linux, Open Source & DevOps via
Источник
[bash][conky][fs label] Как узнать метку тома ??
В коньках отображаю инфу о свободном просторе на фс. Но вместо точки монтирования было б неплохо показывать метку тома фс. При этом у меня разные фс: ext2, ext3, ext4, fat32, ntfs, iso9660
Мне нужен скрипт для того, чтобы узнать метку тома на разделе.
Да, но я на самом деле имел ввиду, например, средства hal
А вообще, у меня вот gentoo с -HAL собрана, тут udisk всем рулит.
Почитай
blkid —help
на предмет ключика -o
> blkid | grep «sda3»
blkid -o full /dev/sda3
Но лучше
blkid -o value /dev/sda3 | head -n 1
Вернёт метку, а если метки нет, то ююйд.
Очень хорошо! Я, честно говоря, и не догадывался, что у blkid есть опции) Там еще -s есть, судя по всему, оно сразу может из нужного столбца выводить значение, но чета я не понял, какие у него тэги есть.
Всем спасибо за информативные коментарии.
# blkid -s LABEL /dev/sda1
/dev/sda1: LABEL=«BOOT»
localhost
# blkid -s UUID /dev/sda1
/dev/sda1: UUID=«9ce2de63-309f-45e9-9062-572226bf1a43»
localhost
# blkid -s TYPE /dev/sda1
/dev/sda1: TYPE=«ext2»
> blkid -s LABEL -o value /dev/sda3
Проще, но что делать при отсутствии метки?
такой вариант не катит с blkid. заюзал udisks
>Проще, но что делать при отсутствии метки?
Это всё для коньков делается, а не для АЭС.
Если нужна работа из под юзера и в таком извращённом виде, то никаких проблем.
localhost
$ sudo blkid -o value /dev/disk/by-uuid/41ad61f1-7e6b-40cc-b504-e3ab04bcb78c | head -n1
lenny
Опять же, в случае отсутствия у раздела метки, вернётся хотя бы ююйд.
Ну, он больше информации конечно выдаёт, есть где разгуляться фантазии, но тупое грепанье выхлопа
udisks —show-info /dev/disk/by-uuid/41ad61f1-7e6b-40cc-b504-e3ab04bcb78c | sed ‘/label/!d’ показывает две строки label и необходимость форматировать, то есть ещё как минимум нужно паравозиком подцепить gawk.
> Это всё для коньков делается, а не для АЭС.
Путь к порядку на АЭСах начинается с порядка в коньках.
Мне мой вариант blkid -o value /dev/sda3 | head -n 1 нравится больше всего.
Источник
Arch Linux
You are not logged in.
#1 2015-05-16 08:05:23
Error /dev/disk/by-label/ARCH-2015 did not show up
I downloaded, checked and burned my install cd.
I booted it and choose the x86_64 After a few seconds I see this message:
Waiting 30 second for device /dev/disk/by_label/ARCH-201505
Error : /dev/disk/by_label/ARCH-201505 did not show up after 30 seconds.
#2 2015-05-16 09:49:09
Re: Error /dev/disk/by-label/ARCH-2015 did not show up
Hi roelof and welcome to the forums
Is that the only error message displayed? How did you burn the CD?
Take a look also to this thread https://bbs.archlinux.org/viewtopic.php?id=195763.
Last edited by mauritiusdadd (2015-05-16 13:46:11)
— When you have eliminated the impossible, whatever remains, however improbable, must be the truth — Spock | Sherlock Holmes
#3 2015-05-16 10:42:10
Re: Error /dev/disk/by-label/ARCH-2015 did not show up
Try loading it again a few more times.
I have seen this with USB sticks and they did work eventually.
#4 2015-05-16 11:45:33
Re: Error /dev/disk/by-label/ARCH-2015 did not show up
I burned with the Windows burner programm which never has disappionted me.
And yes, this one is the only error message
#5 2015-05-16 13:45:36
Re: Error /dev/disk/by-label/ARCH-2015 did not show up
Do as HoaS suggested and if it does not work, maybe try another CD. If you have another machine running linux you could try to use wodim.
PS: I’m sorry, for some strange reason I thought that was your first post, my bad
Last edited by mauritiusdadd (2015-05-16 13:46:37)
— When you have eliminated the impossible, whatever remains, however improbable, must be the truth — Spock | Sherlock Holmes
#6 2015-05-17 12:16:18
Re: Error /dev/disk/by-label/ARCH-2015 did not show up
I tried several cd but still the same error.
Can it be that on the 201505 install cd there is a bug/error.
#7 2015-05-17 12:29:41
Re: Error /dev/disk/by-label/ARCH-2015 did not show up
I just downloaded the 201505 iso and made an USB flash installation media and it worked flawlessly. I will also try to burn a disc but I doubt there is a bug in the iso.
—edit: for the record I tried to burn a CD with wodim and it just worked.
Last edited by mauritiusdadd (2015-05-17 19:27:16)
— When you have eliminated the impossible, whatever remains, however improbable, must be the truth — Spock | Sherlock Holmes
#8 2015-05-17 15:59:20
Re: Error /dev/disk/by-label/ARCH-2015 did not show up
Then it ís still a mistery why I can install it.
#9 2015-05-17 17:34:13
Re: Error /dev/disk/by-label/ARCH-2015 did not show up
Try a different method of burning your CD. Some work better than others.
I recently had trouble installing a CD that I had created in Windows. https://bbs.archlinux.org/viewtopic.php?id=195763
Nothing is too wonderful to be true, if it be consistent with the laws of nature — Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. — Alan Turing
—
How to Ask Questions the Smart Way
#10 2015-05-18 21:16:50
Re: Error /dev/disk/by-label/ARCH-2015 did not show up
Hello, my first post, installed Arch just a few days ago I love it already, it’s everything i was looking for!
Anyway, OP your problem appeared to me too and I could not start the installation. However I am proud to say I found a solution
The usb stick is labeled wrong and should be changed to whatever the error says (for me it was ‘ARCH_201505’).
At least I believe so. I cd’ed to the specified folder ( /dev/disk/by_label/ ) and soft linked like so «ln -s ARCH_201505 ../../sdx1» which was my usb.
Then exit and the installation should commence without any problems. Hope I helped
Last edited by takispan (2015-05-18 21:17:54)
#11 2015-11-14 06:23:41
Re: Error /dev/disk/by-label/ARCH-2015 did not show up
Same thing happen to me today, the name of the usb device didn’t match with ARCH_201511(in my case), i changed and went like a punch in dark
hardware : the thing that you punch.
software : the cause
#12 2015-12-27 19:35:33
Re: Error /dev/disk/by-label/ARCH-2015 did not show up
Had the same problem. Linking /dev/disk/by-label/ARCH to /dev/disk/by-label/ARCH_201512 worked for me.
#13 2015-12-28 06:47:04
Re: Error /dev/disk/by-label/ARCH-2015 did not show up
The same thing happens to me regularly. I’m using a CD with the 2015_06 iso.
I think the problem is that arch isn’t trying hard enough to read the CD. Yes, the problem exists because the CD reader isn’t working as well as it should, but usually this can be overcome by more retries.
Anyway, what I do is mount the CD in the emergency shell. For instance : mount /dev/sr0 /somewhere (need to try a few times ocassionally) then umount and exit. Installation resumes.
Last edited by rdata (2015-12-28 06:49:28)
Источник