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

E235
  • 363
  • 7
  • 19

1 Answers1

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.

Seamus
  • 2,522
  • 1
  • 16
  • 31