By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,419 Members | 1,179 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,419 IT Pros & Developers. It's quick & easy.

Raw disk access

P: n/a
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?

I am running FreeBSD 6.x.

--
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
Mar 23 '07 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Daniel Rudy wrote:
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?

I am running FreeBSD 6.x.
Either a BSD group or comp.unix.programmer would be a better place to ask.

--
Ian Collins.
Mar 23 '07 #2

P: n/a
On Mar 23, 9:34 am, Daniel Rudy <spamt...@spamthis.netwrote:
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?
Do a search for USB and "mass storage" devices.

The things that you are looking for might not even exist. USB
implements an interface. There is no knowing what is on the device
itself.

Mar 23 '07 #3

P: n/a
At about the time of 3/23/2007 2:34 AM, Daniel Rudy stated the following:
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?

I am running FreeBSD 6.x.
Opps....

Wrong group. That's what happens when you post at 2AM.
--
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
Mar 23 '07 #4

P: n/a

To access the USB drive in raw mode in Linux...do not mount the drive.
Just search the device file in the folder /dev
It will probably be /dev/sda or /dev/sdc.

Since all the devices are treated as files in linux.you can use the
file in raw mode
in C/C++ program

eg

FILE* fp=fopen("/dev/sda","r");

etc.
For writing you may probably need to run the program as root.

daya
Mar 23 '07 #5

P: n/a
daya wrote, On 23/03/07 16:54:
To access the USB drive in raw mode in Linux...do not mount the drive.
Just search the device file in the folder /dev
It will probably be /dev/sda or /dev/sdc.

Since all the devices are treated as files in linux.you can use the
file in raw mode
in C/C++ program
I think you mean binary mode, C does not have a raw mode.
eg

FILE* fp=fopen("/dev/sda","r");
That would open it in text mode which is not what you want (although it
does not make much difference on Linux). You should use "rb" for binary.
etc.
For writing you may probably need to run the program as root.
All this would be best discussed on a Linux or Unix programming group
where the specifics of the system are topical. They are not topical here.
--
Flash Gordon
Mar 23 '07 #6

P: n/a
At about the time of 3/23/2007 1:08 PM, Flash Gordon stated the following:
daya wrote, On 23/03/07 16:54:
>To access the USB drive in raw mode in Linux...do not mount the drive.
Just search the device file in the folder /dev
It will probably be /dev/sda or /dev/sdc.

Since all the devices are treated as files in linux.you can use the
file in raw mode
in C/C++ program

I think you mean binary mode, C does not have a raw mode.
No, I mean raw device access mode in Unix, when the disk looks just like
a bunch of data blocks and you can view the partition table and
filesystem structures that the kernel uses to keep track of things on
the disk. In my case, it's a USB flash drive.
>eg

FILE* fp=fopen("/dev/sda","r");

That would open it in text mode which is not what you want (although it
does not make much difference on Linux). You should use "rb" for binary.
It would have to be binary mode.
>etc.
For writing you may probably need to run the program as root.

All this would be best discussed on a Linux or Unix programming group
where the specifics of the system are topical. They are not topical here.
Which is why I posted a follow-up message indicating that I posted to
the wrong group. The poster that you replied to snipped my post that
made a statement to that fact.
--
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
Mar 24 '07 #7

P: n/a
Daniel Rudy wrote, On 24/03/07 08:53:
At about the time of 3/23/2007 1:08 PM, Flash Gordon stated the following:
<snip>
>All this would be best discussed on a Linux or Unix programming group
where the specifics of the system are topical. They are not topical here.

Which is why I posted a follow-up message indicating that I posted to
the wrong group. The poster that you replied to snipped my post that
made a statement to that fact.
I either did not see or did not remember that. I'm not disputing you
posted it, just pointing out that it is not unusual for these things to
be pointed out more than once.
--
Flash Gordon
Mar 24 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.