Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Files on Windows and Contiguous Sectors

Is there a way to guarantee that a file on Windows (using the NTFS file system) will use contiguous sectors on the hard disk? In other words, the first chunk of the file will be stored in a certain sector, the second chunk of the file will be stored in the next sector, and so on.

I should add that I want to be able to create this file programmatically, so I'd rather not just ask the user to defrag their harddrive after creating this file. If there is a way to programmatically defrag just the file that I create, then that would be OK too.

like image 796
Terry Avatar asked Mar 02 '23 08:03

Terry


2 Answers

I would start here:

http://technet.microsoft.com/en-us/sysinternals/bb897428.aspx

and follow Mark's documentation of the defrag stuff:

http://technet.microsoft.com/en-us/sysinternals/bb897427.aspx

like image 67
Will Dean Avatar answered Mar 16 '23 15:03

Will Dean


I know of no such guarantees.

But also keep in mind that NTFS "files" are comprised of multiple data streams. So you are actually looking for a way to guarantee that a stream is contiguous.

like image 28
Frank Krueger Avatar answered Mar 16 '23 15:03

Frank Krueger