Find the answer to your Linux question:
Results 1 to 4 of 4
hello can anyone please tell me what /dev/sda, /dev/sdb, etc mean in linux and how devices get these names assigned ? thanks...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2005
    Posts
    3

    scsi on linux


    hello

    can anyone please tell me what /dev/sda, /dev/sdb, etc mean in linux and how devices get these names assigned ?

    thanks

  2. #2
    Linux Enthusiast
    Join Date
    Oct 2004
    Posts
    609

    Re: scsi on linux

    Quote Originally Posted by deepa1206
    hello

    can anyone please tell me what /dev/sda, /dev/sdb, etc mean in linux and how devices get these names assigned ?

    thanks
    "/dev/sda" is the first scsi harddisk,
    "/dev/sdb" is the second, and so on.

    These are assigned during boot and installation.

  3. #3
    Linux User
    Join Date
    Oct 2004
    Location
    Serbia&Montenegro
    Posts
    281
    USB flash keys are usually mounted on /dev/sda.
    Linux registered user #358842
    Human knowledge belongs to the world.

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    Apr 2005
    Posts
    3
    I have a system with a SCSI controller installed on the PCI bus and 10 SCSI drives connected to it. I ran the following piece of code on the system, and the results were as follows:

    /dev/sdd SCSI:00:00:03:00

    Why do I see only one partition listed when there are actually 10 drives in the system?
    (sorry.. the code is a little long )..by the way is there anyway i can attach the code i require as a file?

    Thanks.

    ##start of code ##

    static const char *devices[] = {
    "/dev/sda", "/dev/sdb", "/dev/sdc", "/dev/sdd", "/dev/sde", "/dev/sdf",
    "/dev/sdg", "/dev/sdh", "/dev/sdi", "/dev/sdj", "/dev/sdk", "/dev/sdl",
    "/dev/sdm", "/dev/sdn", "/dev/sdo", "/dev/sdp", "/dev/sdq", "/dev/sdr",
    "/dev/sds", "/dev/sdt", "/dev/sdu", "/dev/sdv", "/dev/sdw", "/dev/sdx",
    "/dev/sdy", "/dev/sdz", "/dev/sdaa", "/dev/sdab", "/dev/sdac", "/dev/sdad",
    "/dev/scd0", "/dev/scd1", "/dev/scd2", "/dev/scd3", "/dev/scd4",
    "/dev/scd5",
    "/dev/scd6", "/dev/scd7", "/dev/scd8", "/dev/scd9", "/dev/scd10",
    "/dev/scd11", "/dev/sr0", "/dev/sr1", "/dev/sr2", "/dev/sr3", "/dev/sr4",
    "/dev/sr5",
    "/dev/sr6", "/dev/sr7", "/dev/sr8", "/dev/sr9", "/dev/sr10", "/dev/sr11",
    "/dev/cdrom", "/dev/cdrom0", "/dev/cdrom1", "/dev/cdrom2",
    "/dev/cdwriter", "/dev/cdwriter0", "/dev/cdwriter1", "/dev/cdwriter2",
    "/dev/dvd", "/dev/dvd0", "/dev/dvd1", "/dev/dvd2",
    "/dev/st0", "/dev/st1", "/dev/st2", "/dev/st3", "/dev/st4", "/dev/st5",
    "/dev/nst0", "/dev/nst1", "/dev/nst2", "/dev/nst3", "/dev/nst4",
    "/dev/nst5",
    "/dev/nosst0", "/dev/nosst1", "/dev/nosst2", "/dev/nosst3", "/dev/nosst4",
    "/dev/tape", "/dev/tape0", "/dev/tape1", "/dev/tape2", "/dev/tape3",
    "/dev/tape4",
    NULL
    };
    typedef struct my_scsi_idlun
    {
    int mux4;
    int host_unique_id;
    }
    My_scsi_idlun;


    static string scsi_handle(unsigned int host,
    int channel = -1,
    int id = -1,
    int lun = -1)
    {
    char buffer[10];
    string result = "SCSI:";


    snprintf(buffer, sizeof(buffer), "%02d", host);
    result += string(buffer);

    if (channel < 0)
    return result;

    snprintf(buffer, sizeof(buffer), "%02d", channel);
    result += string(":") + string(buffer);

    if (id < 0)
    return result;

    snprintf(buffer, sizeof(buffer), "%02d", id);
    result += string(":") + string(buffer);

    if (lun < 0)
    return result;

    snprintf(buffer, sizeof(buffer), "%02d", lun);
    result += string(":") + string(buffer);

    return result;
    }

    main(){

    int fd = -1;
    int i = 0;
    My_scsi_idlun m_idlun;

    for (i = 0; devices[i] != NULL; i++)
    {
    fd = open(devices[i], O_RDONLY|O_NONBLOCK);
    if (fd >= 0)
    {
    int bus = -1;
    char host[500];
    int * length = (int*)host;
    *length = sizeof(host);
    memset(host, 0, sizeof(host));
    if (ioctl(fd, SCSI_IOCTL_PROBE_HOST, &host) >= 0)
    {
    if (ioctl(fd, SCSI_IOCTL_GET_BUS_NUMBER, &bus) >= 0)
    { memset(&m_idlun, 0, sizeof(m_idlun));
    if (ioctl(fd, SCSI_IOCTL_GET_IDLUN, &m_idlun) >= 0)
    {
    sg_map[string(devices[i])] = scsi_handle(bus, (m_idlun.mux4 >> 16) & 0xff,
    m_idlun.mux4 & 0xff,
    (m_idlun.mux4 >> 8 ) & 0xff);
    cout<<devices[i]<<" "<<sg_map[string(devices[i])]<<endl;
    }

    }
    }
    }
    }
    }

Posting Permissions

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