ZFS FreeBSD 13.0 disk identification

Is the lunid the equivalent of the WWN?

Yes and no. WWN stands for World Wide (unique) Name, and is a hex number, typically 64 bits, typically in one of the IEEE number series (the 5 at the beginning means something, and I forgot what). They are supposed to be world-wide unique; any manufacturer that ships a device with WWN 50...01 is a scammer (or at least incompetent).

For SCSI devices, there are separate names (all world-wide unique) for the device itself (known in SCSI language as a target), each of the two ports, and each LUN (*). Since normal disks typically have exactly one LUN, that makes four entities that are numbered. As far as I've seen, most manufacturers assign four sequential numbers to these four entities. There are special versions of the SCSI Inquiry command you can use to read all these numbers. So what you can do is mask the lowest two bits off from any WWN you read, and you end up with something that's unique to the disk drive and non-confusing.

As far as I know (and this is not from studying the manuals, only from experience), SATA devices have a single name. SATA doesn't have the concept of LUN, and they have only a single port, so there is no distinction needed.

Footnote: (*) Everyone calls them LUN, when they mean "a part of a disk drive that can be addressed like a virtual disk". That entity is really called Logical Unit or LU; the LUN is the Logical Unit Number. The whole concept started with the first SCSI-connected RAID arrays, where one "device" (a think with one physical port) could have multiple logical things in it. But most people just use the word LUN to refer to the virtual device, when in reality the LUN is just a small integer (traditionally 0...7, 3 bits).
 
Were the [...] serial numbers not correct in my case?
I hope there are no fake serial numbers on memory devices floating around, as I already read of chinesium stuff (don't remember what it was) of which somebody reported that all items of the batch he got had exactly the same serial number...

keeping in context, from #19:
"This looks as close to the old Solaris way as I can get, I'm happy with that. Does anyone see any issues with this?"
so I maintain "no issues". OP is gpart labelling based on info from geom disk list, using lunid for the identifier.
[...]
Your lunid from geom list looks like it would be consistent if you used it as the argument to gpart -l.

What I learned from this thread is that the proper way to do this labeling probably is to combine lunid (WWN) and serial number.
For example label format "lunid<lunid>_sn<serial number>".
Particularly with automated labeling this would be least likely to cause problems. For example in the case of fake WWN, like with the "Transcend" example grahamperrin showed.

ralphbsz this is interesting. I don't really understand what you mean with "two ports". Could you explain this more?
And regarding the LUN, I think what geom disk list shows as lunid might be lun 0. Maybe somebody who has a SES or SCC device can check this? The SCSI manual I consulted does not really tell much about that. The REPORT LUNS command description doesn't go into detail what results one can expect with different kinds of devices (-> Table 61).
So I am not really sure whether to mask out how many bits of lunid, but I would like to know this, for doing things right in script automation of labelling drives GPT.
 
I hope there are no fake serial numbers on memory devices floating around,
I have no idea. I've seen disk drives that have WWN = zero and serial number "prototype" or empty string. They tend to have a big hand-written label that says something like "Seagate prototype for internal use or under NDA only" (you can substitute other names for Seagate). The only people who get to see those either work for the device manufacturers, or closely with them. Sometimes you have a dozen of these drives, and they all have the same (non-existing) id. That tends to cause confusion.

The only time I've ever seen two production things on the open market have the same serial number was a reputable brand of motherboards, and it was the Mac address of the built-in ethernet port. We had two boards that had the same number, both in hardware and on the little printed label. But all the others (we had bought several dozen) were fine and distinct. This is truly a bizarre manufacturing bug, and we ignored it.

ralphbszI don't really understand what you mean with "two ports".
Some SCSI disks have more than one physical port. For example, SAS disks (nearly?) always have two ports. They happen to be on the same physical connector, but you can split the wiring and connect them to two different computers, or to the same computer via two cables (multipath). Each of those ports has an ID number, which is the port ID.

And regarding the LUN, I think what geom disk list shows as lunid might be lun 0.
The SCSI standard says that every block device (the thing we call disk) must have a LUN 0, at all times. You can always ask that LUN 0 what the other LUNs on the device are (the command is probably called something like "Report LUN list" or such). AFAIK, there are no physical disk drives in the free market that multiple LUNs. The kind of disks that have multiple LUNs are typically RAID boxes (where a LUN is a logical volume, created out of an array of physical disks), and the multi-actuator drives (both WD and Seagate make them) which are not sold on the open market.

Each LUN must have a LUN id, just like any SCSI device has a device ID (known as its WWN), and any SCSI port has a port ID.

I think the only other kind of SCSI device that can have multiple LUNs is tape drives, but I've never worked with such a drive. I don't see how multiple LUNs would make sense for printers, scanners, enclosure controllers, and alike, but perhaps they exist.

If you add it up, you get: One WWN for the device itself. Two port IDs for the two ports. One LUNid. Makes a total of four. So what manufacturers do is they assign four sequential numbers to these four things, all coming from the same number sequence (the 5xxx things shown above).

So I am not really sure whether to mask out how many bits of lunid, but I would like to know this, for doing things right in script automation of labelling drives GPT.
Just use the LUNid, done. Or use the SCSI device WWN. Just be consistent. If you get both and they differ (only happens for SCSI, not for SATA), then in my experience you'll find that masking off the lowest two bits will make them "unique for the drive". This is not guaranteed by standards, but in my experience it works.
 
… any manufacturer that ships a device with WWN 50...01 is a scammer (or at least incompetent). …

The 500GB device here with lunid 5000000000000001 (reported by geom(8)) is:

a circa 2010 hard disk drive (StoreJet Transcend 25 Mobile) on USB.

Part TS500GSJ25M, presumably. It would have been purchased from a consortium-approved supplier.

I'm not bothered by the strangeness of 5000000000000001 in this case, but it's nice to learn. Thanks ralphbsz



Not for FreeBSD disk identification purposes, but for reference, there's an additional code on the underside, which Google can't match with anything meaningful: B06532 2782. There's nothing more of interest after removing the outer case, and I don't intend to open the inner case.
 
Semi-OT:

grahamperrin that's interesting.
So you opened the case and found a drive inside, only covered with labels containing numbers, without hinting who manufactured that thing.
It would be interesting to examine that drive, if it at all works with normal SATA. In that case one could determine whether that drive actually has a non-fake WWN from which the origin of the drive could be found out, aside of analyzing the drives' hardware to find out the real manufacturer.

In this case it would be proof that this product sold by Transcend at least suffers of engineering incompetence (failure to pass through the WWN).

Personally, I avoid Transcend and other pseudo-brands like Corsair. The indications are too many that these could be rejects marketers like Spectek back then (which was founded to market Micron chip rejects). These play a gamble game with the QA thresholds which rejects are still "good enough" to be sold. For example Corsair is known for frequent recalls and even bankruptcy due to the cost of failed gambling. Personally, I consider these "manufacturers"/brands as scammers which I avoid.
 
Possible confusion from there being no photographs in the Wayback Machine capture (linked above). Sorry.

The drive is certainly a few years old, re: <https://en.wikipedia.org/wiki/USB_3...B_2.0_vs_USB_Micro-B_SuperSpeed_(USB_3.0).jpg> it has a Macro-B SuperSpeed USB 3.0 port, maybe it's the more recent 25M3 <https://uk.transcend-info.com/Products/No-284>.

Whilst I can't be certain of the exact model or part number, it does have an outer case that's silicon. From the current web page for 25M3:
1646644068277.png
NB:

I don't intend to open the inner case.

… So you opened the case …

– not the inner case ;-)
 
If you are creating a boot device you wind up with some partitions anyway, a boot partition (either efi or freebsd-boot).
I often build simple PCs without any partitioning at all. I prefer to geom label each disk with unique label, not to confuse myself in the future, but that's all. After that I build ZFS pool from this disk labels and install zfsboot:
dd if=/boot/zfsboot of=/dev/label/mydsk1 count=1 dd if=/boot/zfsboot of=/dev/label/mydsk1 iseek=1 oseek=1024
on each disk.
Finally it works like a charm.
 
Back
Top