Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am building a function that has to read the HD serial number, and it cannot run external applications or require root privileges. I am aware that I can list the contents of this folder:

/dev/disk/by-id

My question is, is this folder standard in every linux distribution? Is it persistent, do the contents of this folder change over time?

Also, is there any common pattern? I suppose I can always extract the link to sda (ignoring sda1, etc.). For example, in a linux machine I get something like this when I do ls -la:

ata-ST500NM0011_Z1M0CDVS -> ../../sda
ata-ST500NM0011_Z1M0CDVS-part1 -> ../../sda1
...
scsi-1ATA_ST500NM0011_Z1M0CDVS -> ../../sda
...
scsi-SATA_ST500NM0011_Z1M0CDVS -> ../../sda
...
wwn-0x5000c500405b477d -> ../../sda
...

In others there are only ata-, scsi-SATA and wwn. What does these mean? Will I always find at least three of the four above?

Thanks!

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.