PDA

View Full Version : How do I access an NTFS disk



julie
21st December 2009, 01:56 AM
Hello,

How can I access an NTFS formatted disk to read the raw data?
I have done this with the FAT file system. I followed the FAT
specifications, and I can read the contents of each disk sector.

How can I do this with NTFS?:confused:

Thanks.

martypants
21st December 2009, 03:17 AM
Here's my /etc/fstab. The last entry is my NTFS drive mounted as /win

#
# /etc/fstab
# Created by anaconda on Thu Nov 19 21:49:37 2009
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/vg_koreaboy-lv_root / ext4 defaults 1 1
UUID=006dfd9b-7e6d-4655-a2a0-193447369eda /boot ext4 defaults 1 2
/dev/mapper/vg_koreaboy-lv_swap swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/dev/sdb1 /win ntfs-3g rw,allow_other 0 0

julie
21st December 2009, 04:45 AM
Thanks for the reply. I am actually trying to write a program which
can read data from a disk without going through the host file system.

For FAT, I was able to do this. I can read/write from a specific LBA
address, and I can read/write sector by sector. What I would like to
know is how to do this with a disk formatted in NTFS. I see that FAT is
much simpler than NTFS.

I am looking at the NTFS-3G driver, is it possible to include this driver
with my program? Is this the correct approach? How can it be done?

Thanks again.

martypants
21st December 2009, 01:05 PM
you got me on that one. I haven't a clue. You're already way over my head - or is it that you're at
a lower level than my head will go?

stoat
21st December 2009, 10:42 PM
How can I access an NTFS formatted disk to read the raw data?Hello julie,

Well, I don't know how to do it in a programming language, but the dd command can do what those words described. You can decide if you can use it in what you are doing.

jpollard
21st December 2009, 10:54 PM
Hello,

How can I access an NTFS formatted disk to read the raw data?
I have done this with the FAT file system. I followed the FAT
specifications, and I can read the contents of each disk sector.

How can I do this with NTFS?:confused:

Thanks.

Same way - read the NTFS specifications...

OH, wait. They don't exist.

The easiest way to read it is to use the NTFS filesystem - there has been several years of effort to reverse engineer
what is required.

If you want to write your own, the only specs I know of are in the code.

julie
22nd December 2009, 01:27 AM
Thanks a lot for your answers.

@stoat: Yes, dd looks very useful for this application. However, it would be better if there is some other way to do it so that maybe I can implement it in firmware.:) I've seen that there are NTFS drivers available, but I do not know yet how to use them in my project (or if I can use them). :p

DBelton
22nd December 2009, 02:08 AM
Thanks for the reply. I am actually trying to write a program which
can read data from a disk without going through the host file system.

For FAT, I was able to do this. I can read/write from a specific LBA
address, and I can read/write sector by sector. What I would like to
know is how to do this with a disk formatted in NTFS. I see that FAT is
much simpler than NTFS.

I am looking at the NTFS-3G driver, is it possible to include this driver
with my program? Is this the correct approach? How can it be done?

Thanks again.

If you are actually reading the raw data from the disk without going through the host file system, then how the drive is formatted makes no difference. you would read/write to a specific LBA address the same no matter if it is formatted FAT, NTFS, ext4, etc.. If the file system makes a difference then you are not directly accessing the drive directly.

A sector is a sector on the hard drive.. no matter the file system.

However, I wouldn't recommend doing any writes directly to the drive and bypassing the host file system. Doing so could completely wipe out the file system on the drive.

julie
22nd December 2009, 03:28 AM
I understand what you mean. Sorry for the confusion. What I really need to know is how to read the files regardless of the file system used. I need it to be OS independent, because I want to implement it in hardware. I can do this with FAT, but I want to do it with NTFS too.

DBelton
22nd December 2009, 06:46 AM
you basically want to be able to access the drive without going through the OS routines to do it. That is still a little iffy on the stability side, though. and some OS's will get sick if you do try to access the drive by going around it's own routines.

As for how to do it, I really don't have many ideas unless download the source for the ntfs-3g drivers and look at how they do it.

here is a link to the current stable source:

http://tuxera.com/opensource/ntfs-3g-2009.11.14.tgz

wintermute000
22nd December 2009, 12:15 PM
Seriously though I would just get a windoze machine and do it on that. Unless there's practical factors involved (e.g. you live in the middle of nowhere etc.) then its probably safer and easier to borrow any windows whitebox and use a windows tool then do it via linux.

Just out of curiosity can we ask what you're doing it for? I'm,guessing its some kind of appliance and if so the windows option is out of the question?

Dies
22nd December 2009, 06:18 PM
@johannlo

You must have missed post #9, huh? ;)


I understand what you mean. Sorry for the confusion. What I really need to know is how to read the files regardless of the file system used. I need it to be OS independent, because I want to implement it in hardware. I can do this with FAT, but I want to do it with NTFS too.

I don't know if this is a project that you're making money on? You haven't said.

If it is, I would suggest just contacting Tuxera and getting a quote for what you need then passing that cost along. ;)

It's what makes the most sense, at least to me. Now, if it's something your just doing for fun then the NTFS-3G source is the closest thing to a spec you're going to get.