Skip to content

Commit 611db9b

Browse files
committed
Change udev properties for Linux disk serial
The properties that are currently used are not always accurate, for example we have seen that they sometimes contain the WWN and not the serial. This change uses SCSI_IDENT_SERIAL and ID_SCSI_SERIAL first. This behavior aligns with what lsblk does: https://github.com/util-linux/util-linux/blob/36c52fd14b83e6f7eff9a565c426a1e21812403b/misc-utils/lsblk-properties.c#L122-L128
1 parent 73f5a04 commit 611db9b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pkg/block/block_linux.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,16 @@ func diskSerialNumber(paths *linuxpath.Paths, disk string) string {
147147
return util.UNKNOWN
148148
}
149149

150+
// First try to use the serial from sg3_utils
151+
if serial, ok := info["SCSI_IDENT_SERIAL"]; ok {
152+
return serial
153+
}
154+
155+
// Fall back to ID_SCSI_SERIAL
156+
if serial, ok := info["ID_SCSI_SERIAL"]; ok {
157+
return serial
158+
}
159+
150160
// There are two serial number keys, ID_SERIAL and ID_SERIAL_SHORT The
151161
// non-_SHORT version often duplicates vendor information collected
152162
// elsewhere, so use _SHORT and fall back to ID_SERIAL if missing...

0 commit comments

Comments
 (0)