Find the answer to your Linux question:
Results 1 to 8 of 8
Hi, I am using the following code to get the hard disk serial number struct hd_driveid hd; int ide; ide=open("/dev/hda",O_RDONLY); (void)ioctl(ide,HDIO_GET_IDENTITY,&hd); (void)printf("Serial number - %s\n",hd.serial_no); this is working fine..but for ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jan 2007
    Posts
    26

    getting SATA disk serial number


    Hi,
    I am using the following code to get the hard disk serial number

    struct hd_driveid hd;
    int ide;
    ide=open("/dev/hda",O_RDONLY);
    (void)ioctl(ide,HDIO_GET_IDENTITY,&hd);
    (void)printf("Serial number - %s\n",hd.serial_no);

    this is working fine..but for sata hard disk it is not working how to change the code to get SATA hard disk serial number....i changed "/dev/hda" to "dev/sda" that is also not working

  2. #2
    Linux Enthusiast
    Join Date
    Aug 2006
    Posts
    631

  3. #3
    Just Joined!
    Join Date
    Jan 2007
    Posts
    26

    already seen that

    Hi Franklin,
    I had already seen that post, but i don't know which struct should be used instead of
    struct hd_driveid
    also i want to know
    ide=open("/dev/sda",O_RDONLY); is correct

  4. #4
    Linux Enthusiast
    Join Date
    Aug 2006
    Posts
    631

  5. #5
    Just Joined!
    Join Date
    Jan 2007
    Posts
    26
    Ok leave this programming franklin, can u tell me how to find the serial number of my hard disk...i tried sdparm the output is
    Code:
    [root@linux-new ~]# sdparm -i /dev/sda
        /dev/sda: ATA       HDS728080PLA380   PF2O
    Device identification VPD page:
      Addressed logical unit:
        desig_type: vendor specific [0x0],  code_set: ASCII
     00     4c 69 6e 75 78 20 41 54  41 2d 53 43 53 49 20 73    Linux ATA-SCSI s
     10     69 6d 75 6c 61 74 6f 72                             imulator
    in this HDs728080PLA380 is the model number and what is my hard disk serial number

  6. #6
    Linux Enthusiast
    Join Date
    Aug 2006
    Posts
    631
    For your hd, hdparm can do the job:

    Code:
    hdparm -I /dev/hda
    Regards

  7. #7
    Just Joined!
    Join Date
    Jan 2007
    Posts
    26
    s I know about hdparm, but any way it will not work for SATA hdd..any idea for SATA disk ?

  8. #8
    Just Joined!
    Join Date
    Aug 2009
    Posts
    1

    Talking

    Quote Originally Posted by creativemadhan View Post
    Ok leave this programming franklin, can u tell me how to find the serial number of my hard disk...i tried sdparm the output is
    Code:
    [root@linux-new ~]# sdparm -i /dev/sda
        /dev/sda: ATA       HDS728080PLA380   PF2O
    Device identification VPD page:
      Addressed logical unit:
        desig_type: vendor specific [0x0],  code_set: ASCII
     00     4c 69 6e 75 78 20 41 54  41 2d 53 43 53 49 20 73    Linux ATA-SCSI s
     10     69 6d 75 6c 61 74 6f 72                             imulator
    in this HDs728080PLA380 is the model number and what is my hard disk serial number

    [root@linux-new ~] # sdparm --quiet --page=sn /dev/sda

    maybe like this!!

    Unit serial number VPD page:
    3BT1ZQGR000081240XP7

Posting Permissions

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