0

I am running a container with CentOS:

docker run -it centos bash

I first check for its Label or UUID:

[root@3271c071fe0a /]# cat /proc/cmdline
BOOT_IMAGE=/boot/vmlinuz-5.3.0-1032-aws root=LABEL=cloudimg-rootfs ro console=tty1 console=ttyS0 nvme_core.io_timeout=4294967295

Then I tried to use the Label (cloudimg-rootfs) and convert it to device name so I used blkid but it doesn't print anything:

[root@3271c071fe0a /]# blkid -L="cloudimg-rootfs"
[root@3271c071fe0a /]#

I was expecting to get /dev/xvda1 because I checked it with lsblk:

[root@3271c071fe0a /]# lsblk
NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
loop1     7:1    0 96.6M  1 loop
loop2     7:2    0 28.1M  1 loop
loop3     7:3    0 97.1M  1 loop
xvda    202:0    0    8G  0 disk
`-xvda1 202:1    0    8G  0 part /etc/hosts

Why it doesn't print it?
I tried with =:
enter image description here

And without: enter image description here

5
  • 1
    I would say the syntax is wrong, there should not be an = sign: -L "something". Oct 13, 2020 at 13:06
  • I tried also with = and it doesn't work - see edit with picture
    – E235
    Oct 13, 2020 at 14:18
  • 1
    Did you try without the =? Oct 13, 2020 at 14:21
  • Yes, updated the answer with print screen
    – E235
    Oct 13, 2020 at 16:22
  • 1) Does the output of blkid without arguments include, in any place, the string you are searching for? 2) lsblk -o +LABEL may help you check if a volume labeled cloudimg-rootfs is actually known to the kernel.
    – fra-san
    Oct 13, 2020 at 16:48

1 Answer 1

0

You shouldn't used blkid for this task because it is unreliable. If you check man blkid under the DESCRIPTION section you'll find this passage (emphasis mine):

It is recommended to use lsblk(8) command to get information about block devices, or lsblk --fs to get an overview of filesystems, or findmnt(8) to search in already mounted filesystems.

lsblk(8) provides more information, better control on output formatting, easy to use in scripts and it does not require root permissions to get actual information. blkid reads information directly from devices and for non-root users it returns cached unverified information. blkid is mostly designed for system services and to test libblkid functionality.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .