Find the answer to your Linux question:
Results 1 to 8 of 8
Hello guys I want to know how to find the serial number of a Sata harddrive using the ioctl function,or any other method please if anybody have an idea to ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jun 2006
    Location
    Bangalore , India
    Posts
    29

    Finding the serial Number of the hard drive


    Hello guys
    I want to know how to find the serial number of a Sata harddrive using the ioctl function,or any other method please if anybody have an idea to do it please let me know Thanks in advance.(USING C ONLY);

  2. #2
    Super Moderator Roxoff's Avatar
    Join Date
    Aug 2005
    Location
    Nottingham, England
    Posts
    3,809
    You can do this with the hdparm tool, e.g.: 'hdparm -i /dev/hda' or 'hdparm -I /dev/hda'.

    You could either call the shell to do use this tool, capture the output and parse it for the serial number, or you could take a look at the source code for this tool to see how it gathers the information.
    Linux user #126863 - see http://linuxcounter.net/

  3. #3
    Just Joined!
    Join Date
    Jun 2006
    Location
    Bangalore , India
    Posts
    29
    Hello Roxoff,
    I know about the hdparm and its sorce but it works only for /dev/hda but not /dev/sda(SATA DISK) It says HDIO_GET_IDENTITY inappropriate ioctl for device /dev/sda

  4. #4
    Super Moderator Roxoff's Avatar
    Join Date
    Aug 2005
    Location
    Nottingham, England
    Posts
    3,809
    The SATA drive control is channelled through the SCSI driver in Linux. Maybe the sdparm tool can help?
    Linux user #126863 - see http://linuxcounter.net/

  5. #5
    Linux User
    Join Date
    Aug 2005
    Location
    Italy
    Posts
    401
    search the constant (and documentation) for ioctl SG_GET_VERSION_NUM declared in scsi/sg.h.

    You will control SCSI devices (dev/sd*)!

    However, i your're trying to protect your software using the HD serial number...
    When using Windows, have you ever told "Ehi... do your business?"
    Linux user #396597 (http://counter.li.org)

  6. #6
    Just Joined!
    Join Date
    Jun 2006
    Location
    Bangalore , India
    Posts
    29
    Thanks for the reply guys............ SG_GET_VERSION_NUM works...

  7. #7
    Just Joined!
    Join Date
    Feb 2007
    Posts
    2
    Quote Originally Posted by babbutycoon
    Thanks for the reply guys............ SG_GET_VERSION_NUM works...
    what ioctl return for SATA removable disk:

    ioctl(fd, SG_GET_VERSION_NUM, serial);

    what data type for serial ?

  8. #8
    Just Joined!
    Join Date
    Feb 2007
    Posts
    2
    what ioctl return for SATA removable disk:

    ioctl(fd, SG_GET_VERSION_NUM, serial);

    what data type for serial ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •