Need interface to discover all disks and filesystems in linux - Linux

This is a discussion on Need interface to discover all disks and filesystems in linux - Linux ; Hi experts, I need to retrieve information about all the disks in a linux system (irrespective of SCSI, IDE or SATA). I also need to discover all the filesystems avaiable (rather mounted) on linux. I have no idea how to ...

+ Reply to Thread
Results 1 to 5 of 5

Thread: Need interface to discover all disks and filesystems in linux

  1. Need interface to discover all disks and filesystems in linux

    Hi experts,

    I need to retrieve information about all the disks in a linux system
    (irrespective of SCSI, IDE or SATA).
    I also need to discover all the filesystems avaiable (rather mounted)
    on linux.

    I have no idea how to discover all the disks available in a system and
    its paramaters, like manufacturer, serial number and blksize. However
    it seems there is a command on linux called "hdparm", which can give
    all the parameters of a disk. But I am not sure whether it can discover
    all the disks in the system.

    Regarding my second problem, I think I can discover all the mounted
    filesystems on a system by reading /etc/mnttab or probably
    /proc/mounts. However, is it a reliable method? If not, what is the
    correct way to do so.

    Thanks,
    - Uday


  2. Re: Need interface to discover all disks and filesystems in linux

    Oh, I also need to discover all the CDROMs and floppy drives, if there
    are any in the system. Sorry to miss it out in my last mail.

    Thanks,
    - Uday

    uday....@gmail.com wrote:
    > Hi experts,
    >
    > I need to retrieve information about all the disks in a linux system
    > (irrespective of SCSI, IDE or SATA).
    > I also need to discover all the filesystems avaiable (rather mounted)
    > on linux.
    >
    > I have no idea how to discover all the disks available in a system and
    > its paramaters, like manufacturer, serial number and blksize. However
    > it seems there is a command on linux called "hdparm", which can give
    > all the parameters of a disk. But I am not sure whether it can discover
    > all the disks in the system.
    >
    > Regarding my second problem, I think I can discover all the mounted
    > filesystems on a system by reading /etc/mnttab or probably
    > /proc/mounts. However, is it a reliable method? If not, what is the
    > correct way to do so.
    >
    > Thanks,
    > - Uday



  3. Re: Need interface to discover all disks and filesystems in linux

    > Oh, I also need to discover all the CDROMs and floppy drives, if there
    > are any in the system. Sorry to miss it out in my last mail.


    >I need to retrieve information about all the disks in a linux system
    >>(irrespective of SCSI, IDE or SATA).
    >>I also need to discover all the filesystems avaiable (rather mounted)
    >>on linux.


    /proc/mounts is reliable.

    The pseudo-filesystem /sys contains lots of info
    about the logical devices that the kernel thinks it has,
    and how they are being managed. You'll need a thorough
    understanding of the kernel source code to use /sys .

    There is an application dmidecode which will interpret
    the PC BIOS information about hardware configuration.
    Beware that PC BIOS information is frequently incomplete,
    misleading, or incorrect.

    --

  4. Re: Need interface to discover all disks and filesystems in linux

    Thanks a lot John.

    However, I am using quite a old version of linux (kernel 2.4.18) which
    probably does not support sysfs (I guess that's what is /sys
    pseudo-filesystem).
    And as you have mentioned I am not inclined to use any third-party
    tool/library for this purpose. Main reason being I need to port this
    application to Solaris in future.
    Can there be any options in ioctl() to do this? Or can I get all the
    device information from /proc? It seems in Solaris sysinfo() gives a
    little more flexibility to know all the devices attached to the system.

    Thanks again,
    - Uday

    John Reiser wrote:

    > > Oh, I also need to discover all the CDROMs and floppy drives, if there
    > > are any in the system. Sorry to miss it out in my last mail.

    >
    > >I need to retrieve information about all the disks in a linux system
    > >>(irrespective of SCSI, IDE or SATA).
    > >>I also need to discover all the filesystems avaiable (rather mounted)
    > >>on linux.

    >
    > /proc/mounts is reliable.
    >
    > The pseudo-filesystem /sys contains lots of info
    > about the logical devices that the kernel thinks it has,
    > and how they are being managed. You'll need a thorough
    > understanding of the kernel source code to use /sys .
    >
    > There is an application dmidecode which will interpret
    > the PC BIOS information about hardware configuration.
    > Beware that PC BIOS information is frequently incomplete,
    > misleading, or incorrect.
    >
    > --



  5. Re: Need interface to discover all disks and filesystems in linux


    uday.sen@gmail.com wrote:

    > And as you have mentioned I am not inclined to use any third-party
    > tool/library for this purpose. Main reason being I need to port this
    > application to Solaris in future.


    The way to port code like this is to design an interface that has the
    features you need, then implement that interface on all plaftorms you
    need to support. There is no reason the implementations have to be at
    all similar.

    DS


+ Reply to Thread