How can I get the BSD name of a USB disk from its serial number in the terminal?

Hello Everyone!

MacBook Air Mac14,2

macOS Tahoe 26.1


The command 'system_profiler SPUSBDataType' was removed in macOS Tahoe 26.1. The new command 'system_profiler SPUSBHostDataType' does not provide sufficient information.


Could anyone provide me with some suggestions? Thanks in advance.





MacBook Air, macOS 26.1

Posted on Dec 8, 2025 12:52 AM

Reply
8 replies

Dec 8, 2025 4:30 AM in response to LeonSu

Put the following shell function in your ~/.zshenv file which won't exist until you create it:

function dfdevice () {
    # skip df headings and last line
    df | awk '$0 ~ /map/ {getline}{printf "%-35s%-25s\n", fields[NF],fields[1]}{split($0, fields, FS)}'
}


Once you have saved the ~/.zshenv file, make that function available. Subsequent Terminal launches will make it available by default:

source ~/.zshenv


and then run the function from the shell:

dfdevice


This will produce two columns of output:

  1. path
  2. device name (e.g. /dev/disk7s1)


Dec 10, 2025 6:26 AM in response to LeonSu

I think I may have a possible solution. There is an app I use for monitoring my SSD writes but has a lot more to it than just that. The app is a command line app called "smartctl" which can extract more information than one could possibly want to know about any drive.


https://www.smartmontools.org/


I looked through the man pages and it looks like you could get what you want. You may need to recurse through disk0, disk1, etc. to get what you want.


When I run the basic command to get the info I want about drive usage I get this (disk5 in this case). Note the -a parameter collects all info available via SMART:

smartctl -a disk5


=== START OF INFORMATION SECTION ===


Model Number:                       OWC Aura Ultra IV

Serial Number:                      xxxxxxxxxxxxxxx

Firmware Version:                   EIFM70.3

PCI Vendor/Subsystem ID:            0x1987

IEEE OUI Identifier:                0x6479a7

Total NVM Capacity:                 1,000,204,886,016 [1.00 TB]

Unallocated NVM Capacity:           0

plus alot more after this.


There are parameters that you can set to limit the output and as I recall from a quick scan of the man page serial number may be one.


Also, I think you need to install another extension in order to access USB drives as the Mac USB drivers do not have the capability of retrieving SMART data from USB drives.


I think this may at least be a start in the right direction.

Dec 10, 2025 9:19 AM in response to woodmeister50

woodmeister50 wrote:

I think I may have a possible solution. There is an app I use for monitoring my SSD writes but has a lot more to it than just that. The app is a command line app called "smartctl" which can extract more information than one could possibly want to know about any drive.

https://www.smartmontools.org/

I was thinking of this as well. However, as I was looking to see if macOS still had the information, I found that the serial number which macOS does retrieve with "ioreg" was for the adapter for my SSD & not the SSD itself. That got me to thinking the OP may actually need to adapter/enclosure serial number as opposed to the serial of the physical internal drive itself.


However, to limit the information provided by "smarctl", you would want to use the " -i " or " --info " option which will just pull the drive's physical information such as Make, Model, Serial, Firmware, etc.


Also, for external USB drives, the OP would need to install a special USB driver in order to allow "smartctl" to attempt to access the drive's SMART details.

Dec 8, 2025 11:27 PM in response to VikingOSX

Thank VikingOSX for your reply.

But I need to find the BSD name of a USB disk from some fixed information, namely a unique number. In this case, we use the serial number of the USB disk.


In new versions of macOS, I could not determine the rule that connects the serial number with the BSD name. For example, when I run the command 'system_profiler SPUSBHostDataType -detailLevel full' in the terminal, I obtain the following information:

//------------------------------------------------------

USB 3.1 Bus:


Location ID: 0x00000000

Connection Type: Built-in

Driver: AppleT8112USBXHCI


Sabrent:


Location ID: 0x00100000

Connection Type: Removable

Manufacturer: Sabrent

Serial Number: 012345678922

Link Speed: 480 Mb/s

USB Vendor ID: 0x0bda

USB Product ID: 0x9210

USB Product Version: 0x2100

Power Allocated: 2.5 W (500 mA)

//------------------------------------------------------

I can identify the USB disk I want from its serial number, but the information is insufficient to determine the BSD name of the disk. Alternatively, when I run the command 'system_profiler SPStorageDataType' in the terminal, the output is as follows:

//--------------------------------------------------------

SSI_Disk02:


Free: 231.91 GB (231,913,226,240 bytes)

Capacity: 240.02 GB (240,023,306,240 bytes)

Mount Point: /Volumes/SSI_Disk02

File System: ExFAT

Writable: Yes

Ignore Ownership: Yes

BSD Name: disk4s2

Volume UUID: B1BFBA4E-54DD-3A1C-861A-18EBFC7F3670

Physical Drive:

Media Name: Sabrent Media

Protocol: USB

Internal: No

Partition Map Type: GPT (GUID Partition Table)

//-----------------------------------------------------------------------

The data display the BSD name of the USB disk, but I cannot be certain that the disk is my intended target. This issue may arise when two identical USB disks are connected.


I need some methods to connect the serial number and the BSD name of a USB disk. C or C++ example code would also be helpful.

Thanks again.





How can I get the BSD name of a USB disk from its serial number in the terminal?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.