Raw disk access? - Unix

This is a discussion on Raw disk access? - Unix ; How does one access the raw disk? I have a USB thumb drive that will have many megabytes of data on it. What I want to do is access the device raw and do reading from/writing to the usb device ...

+ Reply to Thread
Results 1 to 5 of 5

Thread: Raw disk access?

  1. Raw disk access?


    How does one access the raw disk?

    I have a USB thumb drive that will have many megabytes of data on it.
    What I want to do is access the device raw and do reading from/writing
    to the usb device itself. No partitions, no mounting, just raw disk
    access to data in predefined structures that is on the device. I have
    looked at Advanced Unix Programming (ISBN 0-13-141154-3) by Marc J.
    Rochkind and it does mention a few things about it, but I want to know
    more. Any documentation/references online that someone is willing to share?


    --
    Daniel Rudy

    Email address has been base64 encoded to reduce spam
    Decode email address using b64decode or uudecode -m

    Why geeks like computers: look chat date touch grep make unzip
    strip view finger mount fcsk more fcsk yes spray umount sleep

  2. Re: Raw disk access?

    Daniel Rudy writes:

    > How does one access the raw disk?
    >
    > I have a USB thumb drive that will have many megabytes of data on it.
    > What I want to do is access the device raw and do reading from/writing
    > to the usb device itself. No partitions, no mounting, just raw disk
    > access to data in predefined structures that is on the device. I have
    > looked at Advanced Unix Programming (ISBN 0-13-141154-3) by Marc J.
    > Rochkind and it does mention a few things about it, but I want to know
    > more. Any documentation/references online that someone is willing to share?


    Opening the raw disk device.

    For example, instead of opening /tmp/toto, you open /dev/hda

    Well, perhaps you should not try to open /dev/hda in write mode if
    your file systems are stored on it.

    Let's be a little less raw, and just open a free partition. Assume
    /dev/hda7 is a free partition, to access it, just open /dev/hda7.

    (you can substitute the exact device name for your unix; the naming
    scheme is usually documented in the 4th section of the unix manual:
    man 4 hd
    man 4 sd
    etc)


    Now for a usb device, of course, you'll go to /dev/usb/something, or,
    depending on your unix system works, thru /dev/sd?; for example, usb
    storage devices are usually accessed thru the scsi device drivers on
    Linux.


    --
    __Pascal Bourguignon__
    http://www.informatimago.com
    http://pjb.ogamita.org

  3. Re: Raw disk access?

    At about the time of 3/23/2007 10:39 AM, Pascal Bourguignon stated the
    following:
    > Daniel Rudy writes:
    >
    >> How does one access the raw disk?
    >>
    >> I have a USB thumb drive that will have many megabytes of data on it.
    >> What I want to do is access the device raw and do reading from/writing
    >> to the usb device itself. No partitions, no mounting, just raw disk
    >> access to data in predefined structures that is on the device. I have
    >> looked at Advanced Unix Programming (ISBN 0-13-141154-3) by Marc J.
    >> Rochkind and it does mention a few things about it, but I want to know
    >> more. Any documentation/references online that someone is willing to share?

    >
    > Opening the raw disk device.
    >
    > For example, instead of opening /tmp/toto, you open /dev/hda
    >
    > Well, perhaps you should not try to open /dev/hda in write mode if
    > your file systems are stored on it.
    >
    > Let's be a little less raw, and just open a free partition. Assume
    > /dev/hda7 is a free partition, to access it, just open /dev/hda7.
    >
    > (you can substitute the exact device name for your unix; the naming
    > scheme is usually documented in the 4th section of the unix manual:
    > man 4 hd
    > man 4 sd
    > etc)
    >
    >
    > Now for a usb device, of course, you'll go to /dev/usb/something, or,
    > depending on your unix system works, thru /dev/sd?; for example, usb
    > storage devices are usually accessed thru the scsi device drivers on
    > Linux.
    >
    >


    I figured it out. /dev/da0 on my FreeBSD machine. I'm using a 256MB
    USB Flash drive, and I might make a rudimentary filesystem on it. The
    big problem here is auto detecting the size and blocksize of the device.
    I've been examining the source code for the fdisk program, and it seems
    to get the data from the kernel, but I fail to see exactly how it does it.


    --
    Daniel Rudy

    Email address has been base64 encoded to reduce spam
    Decode email address using b64decode or uudecode -m

    Why geeks like computers: look chat date touch grep make unzip
    strip view finger mount fcsk more fcsk yes spray umount sleep

  4. Re: Raw disk access?

    Daniel Rudy wrote:
    > I figured it out. /dev/da0 on my FreeBSD machine. I'm using a 256MB
    > USB Flash drive, and I might make a rudimentary filesystem on it. The
    > big problem here is auto detecting the size and blocksize of the device.
    > I've been examining the source code for the fdisk program, and it seems
    > to get the data from the kernel, but I fail to see exactly how it does it.


    Does FreeBSD have some sort of system call tracing facility, like strace,
    ktrace, or truss? If so, you run the fdisk program, then switch from one
    disk to another and watch what system calls it makes.

    - Logan

  5. Re: Raw disk access?

    At about the time of 3/24/2007 8:57 AM, Logan Shaw stated the following:
    > Daniel Rudy wrote:
    >> I figured it out. /dev/da0 on my FreeBSD machine. I'm using a 256MB
    >> USB Flash drive, and I might make a rudimentary filesystem on it. The
    >> big problem here is auto detecting the size and blocksize of the device.
    >> I've been examining the source code for the fdisk program, and it seems
    >> to get the data from the kernel, but I fail to see exactly how it does it.

    >
    > Does FreeBSD have some sort of system call tracing facility, like strace,
    > ktrace, or truss? If so, you run the fdisk program, then switch from one
    > disk to another and watch what system calls it makes.
    >
    > - Logan


    I has ktrace, and there is a major project to port Sun's dtrace over to it.
    I'll have to check to see if it's compiled into the kernel though.


    --
    Daniel Rudy

    Email address has been base64 encoded to reduce spam
    Decode email address using b64decode or uudecode -m

    Why geeks like computers: look chat date touch grep make unzip
    strip view finger mount fcsk more fcsk yes spray umount sleep

+ Reply to Thread