tags:

views:

46

answers:

2

Hi,

I want to develop a program that copies a partition's 'data' only, to another partition. And I want to do it such that the program starts from the first sector of source partition and checks if a sector is used.

If it is used copy it to the destination parition. Else don't copy.

In other words it's like copying only the contents of a partition to another, sector-by-sector.

Question: Is there a way to check if a particular sector on harddisk is used or not?

The programming language I am using is C++ and the underlying filesystem in NTFS.

Thanks a lot.

+1  A: 

IIRC, sectors store only raw bytes and low level error-specific data. The info you need is a sort of meta-info which only the file system can provide to you.

Nick D
Okay thanks Nick. I will see if I can find a way to achieve what I want via meta-info you talked about.
baltusaj
+1  A: 

Your question is fundamentally flawed. NTS can store data and metadata in the same cluster. Both are handled as file attributes.

I'm also wondering what the point is. Without the metadata, raw data is useless. You can't even tell where one file ends and another begins.

MSalters
You are right. My question is wrong. I should not look for raw data. I just thought that there must be some attribute with each sector that would tell the operating system if a particular sector is available for storing data or already occupied. Anyway, my mistake. :)Thanks
baltusaj
Nope, the free list is managed at cluster level. But from there it's fairly easy. There's a special `$Bitmap` file which has one bit per cluster that tells the OS whether the cluster is free. Note that you shouldn't rely on the contents of this file on a _running_ system.
MSalters
Thanks a lot. That was helpful. How can I view MFT and $Bitmap?
baltusaj
Browse http://www.forensicfocus.com/downloads/ntfs-hidden-data-analysis.pdf. It covers more than you need, but specifically describes the MFT and $Bitmap including (in an appendix) how to view them.
MSalters