Search code examples
javamacoshardwarehard-driveserial-number

Getting Primary HDD serial on OSx using terminal


Ok, so I think the title of this question pretty much sums it up.

I would to know of a way to obtain the serial number of the HDD that the operating system is installed on, in OSx without having Admin privileges. Preferably, I would like to do this using Terminal because I need to use the serial in my Java application and I doubt Java has the capabilities to obtain the information itself.

Thanks in advance


Solution

  • /usr/sbin/diskutil info / | /usr/bin/awk '$0 ~ /UUID/ { print $3 }'
    

    That should give you the serial of the drive mounted at root.