0

Command:

lsblk -l -e7 -o RM,TYPE,PATH,NAME,VENDOR,MODEL |\
awk '{ if ( ($1 == 1) && ($2 == "disk") ) {print $2,$3,$4,$5,$6} }'

Context/limitations regarding my question:

  1. The LABEL field, which can be requested with
lsblk -l -e7 -o RM,TYPE,NAME,LABEL |\
awk '{ if ( ($1 == 1) && ($2 == "part") ) {print $2,$3,$4} }'

concerns the partition(s) and can be changed with fatlabel, e2label, ntfslabel . . . ; this is not what I am looking for.

  1. The volume-label mentioned in the man page of tune2fs command seems to actually be the partition label.
    The command tune2fs -l PATH only works with a PATH including a magic number, therefore a partition (not a disk).

  2. Why do I suspect I miss some knowledge or information in this matter?
    A device/volume/PATH(without magic number) can encompass several partitions ; therefore, I do not see any other specific identifier for the hardware device than the VENDOR and MODEL fields. If you use several usb sticks from the same manufacturer (my case), it is getting confusing and I found nothing on the web.

My regards to the experienced contributors on this site ; I owe them much of the modest progress I booked on my Ubuntu system.

  • 1
    what do you mean by "magic number"? What is it you are actually trying to achieve by "modifying the vendor and model fields" (note: you can NOT change those) - so, what is the end goal, perhaps someone can suggest an alternative – Jaromanda X Jan 29 '23 at 22:00
  • 2
    So, you are trying to differentiate drives that have the same vendor and model ID when running lsblk? Just add SERIAL to the -o fields to get the serial no. of the drive which should be unique. – don_crissti Jan 29 '23 at 22:04
  • Attn JAROMANDA : the magic number is the last character (a digit, the x in /dev/sdbx) which specifies the partition in a block device identification ; I say "magic" because it is what Bash tells me when I do not type the digit in where needed. NOW, you answered the question and I THANK YOU. More details, attn DON_CRISSTI, about the context of my question : imagine a display of a tree structure with HW devices=>Partitions=>Directories (several possible items per mother branch) and the same identification for the USB keys ; which one refers to which port on the machine ? – Dominique Jan 31 '23 at 22:19

0 Answers0