[opensuse] How find the disk ID command?
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, I want to find the disk IDs corresponding to a device. Something similar to "lsblk -n --output UUID /dev/sdb" but for ID, and for the disk, not the partitions. The way I know is this: Telcontar:~ # l /dev/disk/by-id | grep -w sdb lrwxrwxrwx 1 root root 9 Nov 7 10:47 ata-ST2000DM001-1CH164_Z1F5J9FQ -> ../../sdb lrwxrwxrwx 1 root root 9 Nov 7 10:47 scsi-1ATA_ST2000DM001-1CH164_Z1F5J9FQ -> ../../sdb lrwxrwxrwx 1 root root 9 Nov 7 10:47 scsi-SATA_ST2000DM001-1CH1_Z1F5J9FQ -> ../../sdb lrwxrwxrwx 1 root root 9 Nov 7 10:47 scsi-SATA_ST2000DM001-1CH_Z1F5J9FQ -> ../../sdb lrwxrwxrwx 1 root root 9 Nov 7 10:47 wwn-0x5000c500792f9269 -> ../../sdb Telcontar:~ # and then parse the output. I wonder about a command that directly gives the information. maybe blkid, but I don't see how. - -- Cheers Carlos E. R. (from 13.1 x86_64 "Bottle" at Telcontar) -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iEYEARECAAYFAlgjK7IACgkQtTMYHG2NR9WI2gCghjmRjTBVUy07ZLhTbfp7X2Y3 EHkAn2zCarvBsmJBzaSMb1uKB1Cooc4k =P0Q+ -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
* Carlos E. R.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Hi, I want to find the disk IDs corresponding to a device.
Something similar to "lsblk -n --output UUID /dev/sdb" but for ID, and for the disk, not the partitions.
The way I know is this:
Telcontar:~ # l /dev/disk/by-id | grep -w sdb lrwxrwxrwx 1 root root 9 Nov 7 10:47 ata-ST2000DM001-1CH164_Z1F5J9FQ -> ../../sdb lrwxrwxrwx 1 root root 9 Nov 7 10:47 scsi-1ATA_ST2000DM001-1CH164_Z1F5J9FQ -> ../../sdb lrwxrwxrwx 1 root root 9 Nov 7 10:47 scsi-SATA_ST2000DM001-1CH1_Z1F5J9FQ -> ../../sdb lrwxrwxrwx 1 root root 9 Nov 7 10:47 scsi-SATA_ST2000DM001-1CH_Z1F5J9FQ -> ../../sdb lrwxrwxrwx 1 root root 9 Nov 7 10:47 wwn-0x5000c500792f9269 -> ../../sdb Telcontar:~ #
and then parse the output. I wonder about a command that directly gives the information. maybe blkid, but I don't see how.
- -- Cheers
Carlos E. R. (from 13.1 x86_64 "Bottle" at Telcontar)
You can start with something like: $ hdparm -I /dev/sda | egrep -i 'device.*media|number|wwn' Which, in mycase on this particular system, gives: ATA device, with non-removable media Model Number: WDC WD2002FAEX-007BA0 Serial Number: WD-WMAWPXXXXXXX Logical Unit WWN Device Identifier: 5001xxxxxxxx6708 The various links in the "/dev/disk/by-id/" dir appear to be made from combinations of the above. Do not know of another, more direct way to do it. Hope this helps! --Phil -- Philip Amadeo Saeli psaeli@zorodyne.com -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 2016-11-11 05:02, Philip Amadeo Saeli wrote:
* Carlos E. R. <> [2016-11-09 07:59]:
and then parse the output. I wonder about a command that directly gives the information. maybe blkid, but I don't see how.
You can start with something like:
$ hdparm -I /dev/sda | egrep -i 'device.*media|number|wwn'
Which, in mycase on this particular system, gives:
ATA device, with non-removable media Model Number: WDC WD2002FAEX-007BA0 Serial Number: WD-WMAWPXXXXXXX Logical Unit WWN Device Identifier: 5001xxxxxxxx6708
The various links in the "/dev/disk/by-id/" dir appear to be made from combinations of the above. Do not know of another, more direct way to do it.
Hope this helps!
Yes, a solution of that manner is what I though. But perhaps I'll rethink my algorithm differently. -- Cheers / Saludos, Carlos E. R. (from 13.1 x86_64 "Bottle" at Telcontar)
Hello, On Fri, 11 Nov 2016, Carlos E. R. wrote:
On 2016-11-11 05:02, Philip Amadeo Saeli wrote:
* Carlos E. R. <> [2016-11-09 07:59]:
and then parse the output. I wonder about a command that directly gives the information. maybe blkid, but I don't see how.
You can start with something like:
$ hdparm -I /dev/sda | egrep -i 'device.*media|number|wwn' [..] Yes, a solution of that manner is what I though.
# /lib/udev/ata_id --export /dev/sdX # eval $(/lib/udev/ata_id --export /dev/sdX) # echo $ID_SERIAL $ID_WWN HTH, -dnh -- "There was a point to this story, but it has temporarily escaped the chronicler's mind." -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 2016-11-11 15:15, David Haller wrote:
Hello,
# /lib/udev/ata_id --export /dev/sdX # eval $(/lib/udev/ata_id --export /dev/sdX) # echo $ID_SERIAL $ID_WWN
cer@Telcontar:~> /lib/udev/ata_id --export /dev/sda bash: /lib/udev/ata_id: No such file or directory cer@Telcontar:~> cer@Telcontar:~> /usr/lib/udev/ata_id --export /dev/sdd unable to open '/dev/sdd' cer@Telcontar:~> Ah, maybe it needs root permissions... Telcontar:~ # /usr/lib/udev/ata_id --export /dev/sdd ID_ATA=1 ID_TYPE=disk ID_BUS=ata ID_MODEL=ST2000DM001-1CH164 ID_MODEL_ENC=ST2000DM001-1CH164\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20 ID_REVISION=CC27 ID_SERIAL=ST2000DM001-1CH164_Z340FVDC ID_SERIAL_SHORT=Z340FVDC ID_ATA_WRITE_CACHE=1 ID_ATA_WRITE_CACHE_ENABLED=1 ID_ATA_FEATURE_SET_HPA=1 ID_ATA_FEATURE_SET_HPA_ENABLED=1 ID_ATA_FEATURE_SET_PM=1 ID_ATA_FEATURE_SET_PM_ENABLED=1 ID_ATA_FEATURE_SET_SECURITY=1 ID_ATA_FEATURE_SET_SECURITY_ENABLED=0 ID_ATA_FEATURE_SET_SECURITY_ERASE_UNIT_MIN=218 ID_ATA_FEATURE_SET_SECURITY_ENHANCED_ERASE_UNIT_MIN=218 ID_ATA_FEATURE_SET_SECURITY_FROZEN=1 ID_ATA_FEATURE_SET_SMART=1 ID_ATA_FEATURE_SET_SMART_ENABLED=1 ID_ATA_FEATURE_SET_PUIS=1 ID_ATA_FEATURE_SET_PUIS_ENABLED=0 ID_ATA_FEATURE_SET_APM=1 ID_ATA_FEATURE_SET_APM_ENABLED=1 ID_ATA_FEATURE_SET_APM_CURRENT_VALUE=128 ID_ATA_DOWNLOAD_MICROCODE=1 ID_ATA_SATA=1 ID_ATA_SATA_SIGNAL_RATE_GEN2=1 ID_ATA_SATA_SIGNAL_RATE_GEN1=1 ID_ATA_ROTATION_RATE_RPM=7200 ID_WWN=0x5000c50064e4a321 ID_WWN_WITH_EXTENSION=0x5000c50064e4a321 Telcontar:~ # Ok, it works, but needs being root. -- Cheers / Saludos, Carlos E. R. (from 13.1 x86_64 "Bottle" at Telcontar)
Hello, On Fri, 11 Nov 2016, Carlos E. R. wrote:
On 2016-11-11 15:15, David Haller wrote:
# /lib/udev/ata_id --export /dev/sdX # eval $(/lib/udev/ata_id --export /dev/sdX) # echo $ID_SERIAL $ID_WWN
cer@Telcontar:~> /lib/udev/ata_id --export /dev/sda bash: /lib/udev/ata_id: No such file or directory
Ah, SuSE must've moved it (probably with the systemd switch). In 12.1 and Gentoo (eudev) it's still in /lib.
cer@Telcontar:~> /usr/lib/udev/ata_id --export /dev/sdd unable to open '/dev/sdd' cer@Telcontar:~>
Ah, maybe it needs root permissions...
Nope. Just read-access to the raw device. $ strace /lib/udev/ata_id --export /dev/sdb [..] open("/dev/sdb", O_RDONLY|O_NONBLOCK) = -1 EACCES (Permission denied) $ ls -l /dev/sdb brw-rw---- 1 root disk 8, 16 Nov 11 14:56 /dev/sdb $ id -Gn | tr ' ' '\n' | grep disk $ echo $? 1 # chmod o+r /dev/sdb $ /lib/udev/ata_id --export /dev/sdb | head -3 ID_ATA=1 ID_TYPE=disk ID_BUS=ata # chmod o-r /dev/sdb
Telcontar:~ # /usr/lib/udev/ata_id --export /dev/sdd [..] ID_SERIAL=ST2000DM001-1CH164_Z340FVDC ID_WWN=0x5000c50064e4a321 [..] Ok, it works, but needs being root.
See above. You'll probably want to use something like this: for dev; do eval $( /usr/lib/udev/ata_id --export "$dev" ) printf '%s: ata-%s\n%s: wwn-%s\n' \ "$dev" "${ID_SERIAL}" "$dev" "${ID_WWN}" done HTH, -dnh -- I must admit that Micro$oft does seem to bear an awful resemblence to the Sirius Cybernetic Corporation. Considering that my attempts at using Word always resulted in something almost, but not quite, entirely unlike a document. -- Rich Kaszeta -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 2016-11-12 00:04, David Haller wrote:
Hello,
Ah, maybe it needs root permissions...
Nope. Just read-access to the raw device.
Well, ok, but in the end it is the same: it will not run out of the box on any machine. Needs changes. The suggestion from Andrei is very good :-) -- Cheers / Saludos, Carlos E. R. (from 13.1 x86_64 "Bottle" at Telcontar)
09.11.2016 16:59, Carlos E. R. пишет:
Hi, I want to find the disk IDs corresponding to a device.
Something similar to "lsblk -n --output UUID /dev/sdb" but for ID, and for the disk, not the partitions.
The way I know is this:
Telcontar:~ # l /dev/disk/by-id | grep -w sdb lrwxrwxrwx 1 root root 9 Nov 7 10:47 ata-ST2000DM001-1CH164_Z1F5J9FQ -> ../../sdb lrwxrwxrwx 1 root root 9 Nov 7 10:47 scsi-1ATA_ST2000DM001-1CH164_Z1F5J9FQ -> ../../sdb lrwxrwxrwx 1 root root 9 Nov 7 10:47 scsi-SATA_ST2000DM001-1CH1_Z1F5J9FQ -> ../../sdb lrwxrwxrwx 1 root root 9 Nov 7 10:47 scsi-SATA_ST2000DM001-1CH_Z1F5J9FQ -> ../../sdb lrwxrwxrwx 1 root root 9 Nov 7 10:47 wwn-0x5000c500792f9269 -> ../../sdb Telcontar:~ #
and then parse the output. I wonder about a command that directly gives the information. maybe blkid, but I don't see how.
udevadm info -q symlink -n sda
On 2016-11-12 08:51, Andrei Borzenkov wrote:
09.11.2016 16:59, Carlos E. R. пишет:
and then parse the output. I wonder about a command that directly gives the information. maybe blkid, but I don't see how.
udevadm info -q symlink -n sda
Cute. Thanks :-) -- Cheers / Saludos, Carlos E. R. (from 13.1 x86_64 "Bottle" at Telcontar)
participants (4)
-
Andrei Borzenkov
-
Carlos E. R.
-
David Haller
-
Philip Amadeo Saeli