Active2 years, 11 months ago
How to get Hard Disk serial no using java 843797 Mar 20, 2002 7:53 AM Hi All, I need to get Hard Disk searial no for my application using java, pls let me know if anybody know. Very imp for me.
I'm trying to make a java program which will get the serial of the hard disk thru cmd or terminal. I'm trying it on both OS (Windows, Linux). I'm having trouble with Linux, it returns a whitespace, when I type
hdparm -I /dev/sda | grep Serial
in the terminal It shows the serial number of the hard drive.Question how can I get or display the serial number.
here's my code:
askManiac
askManiacaskManiac
2 Answers
Your problem is almost certainly that running
hdparm
requires root privileges. It can't be run by a normal user.![How to get hard disk serial number in javascript How to get hard disk serial number in javascript](https://bd23.https.cdn.softlayer.net/80BD23/142.4.51.106/blog/wp-content/uploads/2009/04/hdsnchanger.png)
Additionally, the 'serial number' that you're reading on Windows is the volume serial number of the primary file system, not of the hard drive. It can be changed rather easily (e.g, using VolumeID).
duskwuffduskwuff156k2121 gold badges194194 silver badges246246 bronze badges
It's being a while since this was posted, but @giusc solution didn't work for me, so posting my research for others.
Get Hard Disk Drive Serial Number on Linux:
How To Get Hard Disk Serial Number In Java Download
Get Hard Disk Drive Serial Number (Manufacture) Windows:
SashaSasha49511 gold badge88 silver badges2121 bronze badges