0

I want make a system in which I can encrypt/decrypt something based on Hard Disk serial number so that key can't be shared across the computer.

mik
  • 73
  • 8

1 Answers1

0

How to get the serial number of a hard disk is different for every Unix variant.

For Linux, if you're running as root, the most direct way is to either use 'hdparm -i /dev/sda' or more correctly the C code (ioctl's) that it uses.

The serial numbers aren't generally useful in Linux so if you aren't running as root you have to interrogate one of the few subsystems that actually has a use -- udev. It uses the serial numbers to uniquely identify devices and stores this information under /run/udev/data ( or /var/run/udev/data) in a file with a name based on the device numbers assigned by Linux.

The data for the first disk found is in /var/run/udev/data/b8:0
the second is in /var/run/udev/data/b8:16

This is a text file.

BTW: The disk serial number is NOT a good encryption key, as you see it's easy to find and is no where as random as it might look.

user3710044
  • 2,261
  • 15
  • 15