August 22nd, 2013, 07:37 AM
Reading and writing directly from/to clusters
Sorry for my english...
Is there any (preferably fast, easy and) safe way to:
1. Check which clusters are free on a volume (Fat32 or NTFS).
2. Copy a file to that volume in specific clusters (usually consecutive clusters).
3. Clear the volume of any files (even deleted ones if possible) but without formatting the volume and as fast as possible.
Why do I need them: I want to make a file copy function that will copy the file unfragmented into the volume, if there are enough free consecutive clusters.
If there aren't, I intend to copy all the files from the volume in a temporary location, clear the volume without formatting it and copy the files back. This way the files will be unfragmented.
They will be part of a freeware program which will be used to help people who want to make their USB stick/flash/key bootable with grub4dos or any similar boot managers.
As some of you perhaps know already, with grub4dos (and not only) you can boot from an iso file. But, to avoid loading it into RAM (which is very slow), it needs to be stored in consecutive clusters.
To defragment the storage device is rarely an optimum solution because it will be very slow and it will increase the wearing.
The formatting is also not a good option because it will change the PBR.
What I already know: I know how to open directly a volume and read or write from/to a specific cluster. What I don't know is how to find which clusters are free (so I can write the file in them) and how to update the FAT/MFT (about the status of the clusters).
What do you think...?
Thank you for any idea.