Jump to content











Photo

Request: Defrag iso before copying to flash disk.


  • Please log in to reply
8 replies to this topic

#1 thegoodguy

thegoodguy
  • Members
  • 1 posts
  •  
    United Kingdom

Posted 19 August 2013 - 01:37 PM

Could you give an option to defrag before copying to the flash disk?

 

It is taking forever doing it after.



#2 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 19 August 2013 - 02:27 PM

Could you give an option to defrag before copying to the flash disk?

 

It is taking forever doing it after.

Please read here why this is impossible :(:

http://reboot.pro/to...-cd-with-xboot/

 

:cheers:

Wonko



#3 steve6375

steve6375

    Platinum Member

  • Developer
  • 7566 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films
  •  
    United Kingdom

Posted 19 August 2013 - 05:33 PM

It makes no sense to defrag a file before copying it!

 

The source of the file is irrelevant. Only the destination drive filesystem is relevant.

 

Consider a target drive volume which is composed of clusters, the files may be arranged like this:

 

Volume Begin

File1 - clusters 1,2,3  (a contiguous, unfragmented file)

File2 - clusters 7,9,23 (a non-contiguous, fragmented file)

File 3 - clusters 8,14-22 (a non-contiguous, fragmented file)

Volume End

 

so we only have clusters 4,5,6,10,11,12,13 available and unused.

 

Now let us suppose we want to write a new file (File 4) which requires 5 clusters (each cluster is 4k and the file is 18k in size). So the OS will write the file to clusters 4,5,6, 10 and 11.

So the file is fragmented. There is no way to prevent this because the file cannot be written using sequential clusters as there is not enough free sequential clusters available on the target drive volume.

The only way to fix this is to defragment all (or most) of the files on the disk, so we get:

 

Volume Begin

File1 - clusters 1,2,3  (a contiguous, unfragmented file)

File2 - clusters 7,8,9 (a contiguous, unfragmented file)

File 3 - clusters 10-19 (a contiguous, unfragmented file)

File 4 - clusters 20,21,22,23,24 (a contiguous, unfragmented file)

Volume End

 

So you see that if you try to write to a disk that has 'gaps' of unused clusters, you will always get a fragmented file if there is an insufficient number of sequential clusters in the volume. Gaps are often caused by the user deleting files in a volume and then writing different sized files to the volume.

 

WinContig will defrag all files on a volume for you but it may be slow on a USB flash drive or there may not be enough free space and it may fail (to defrag a 4GB file requires 4GB of free space on the same drive).

 

The way to avoid this is to have all your source files in a folder on your hard drive and copy them over to a freshly formatted USB drive in one go (e.g. using Windows Explorer or the copy command). 

 

For XBOOT, you could try re-formatting and re-making the USB drive but avoid deleting any files.

 

If this is not possible, then the next best thing is to copy all the files to an empty folder on your hard disk, re-format and remake the target USB drive (e,g, using XBOOT) and then copy all the files back again (though this may not always work).

 

HTH

 

 

 

 

 

 

 

 



#4 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 20 August 2013 - 05:47 AM

Wonko and Steve, you are right.

But there are situations when a better file copy function is needed.
For example: a file that needs 4 clusters, a storage device with 1, 3, 5, 6, 7, 8 free clusters. The file will be copied into 1, 3, 5, 6 clusters and, of course, Wincontig will fail to defrag it because there is not enough free space with consecutive free clusters...
This happened to me a few times. The only 2 solutions (for now) are:
1. to defrag the entire volume on the storage device which is painfully slow, wears the flash drives and sometimes might fail;
2. like Steve said, backup all the files from the volume, format it and copy all the files back. This is a little faster and wears the flash drives a little less but still it's annoying.
The best solution is to use an enhanced file copy function that will copy the file in the free consecutive clusters every time, if there are enough free consecutive clusters for the entire file, of course; if not, then use one of those 2 methods...

Unfortunately I don't know any program with such a file copy function...



#5 steve6375

steve6375

    Platinum Member

  • Developer
  • 7566 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films
  •  
    United Kingdom

Posted 20 August 2013 - 06:49 AM

How about a program that defrags files like this?:

 

1. User picks a volume of a USB flash/USB HDD

2. Copy all the files from a drive volume to an empty folder on an HDD

3. Erase all user file entries (but not $MFT entries like $bitmap, etc.)  including deleted file entries so all file clusters are unused

4. Copy all files back to the flash drive volume

 

This way any MBR, pre-PBR and PBR code and partition layout is not affected but the files should now be contiguous. Not sure how easy (3) would be to do though - could it be done just using file delete and then disk defrag???



#6 genetix

genetix

    Frequent Member

  • Advanced user
  • 132 posts
  •  
    Finland

Posted 20 August 2013 - 07:29 AM

How about keep data contiquous through progress:

 

1. Install tool hmm, Partition Wizard (should be pretty near available for all systems).

2. Make VHD or any type of Virtual HD that OS supports mounting and Part Wizard can see.

3. Copy files contiquous there / defrag that space 1 time.

4. Add files only to that space never ever copy anything directly to end location (unless testing specific thing).

5. When done use Partition Wizard 'copy' partition clean to media / end location without resizing.

 

Should be really helpful when building larger project like I do. Also, in general sense like Windows doesn't understand multiple partitions in USB-Flash this works great as basically you can have all partitions open on screen to modification and when you are done Part. Wizard should be able to copy then no matter what Little Bill says.

 

Well, for minus side my tactic does not save USB MBR (you would basically wanna dump them with Acronis to save disk signature too), if working with environment where boot cannot be rebuild.


Edited by genetix, 20 August 2013 - 07:30 AM.


#7 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 20 August 2013 - 11:48 AM

How about a program that defrags files like this?:

 

1. User picks a volume of a USB flash/USB HDD

2. Copy all the files from a drive volume to an empty folder on an HDD

3. Erase all user file entries (but not $MFT entries like $bitmap, etc.)  including deleted file entries so all file clusters are unused

4. Copy all files back to the flash drive volume

 

This way any MBR, pre-PBR and PBR code and partition layout is not affected but the files should now be contiguous. Not sure how easy (3) would be to do though - could it be done just using file delete and then disk defrag???

 

 

This could be an acceptable solution but, as you pointed out, (3) it's not that easy to do...
File delete + disk defrag unfortunately doesn't help...

Btw, for some time I'm looking for a way to "clean" a volume just like a format will do but without actually format it. So far I couldn't find a safe and fast way.



#8 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 20 August 2013 - 01:51 PM

The usual way here is to make a RAW copy of the stick, mount it as "virtual" disk, copy/defrag anything, the re-image it to the stick.

 

@davidB

@Steve6375

I don't understand.

When you format a volume (in any way until XP/2003 and Vista :ph34r: and later with the /q switch) the ONLY thing that is done is to re-create the filesystem structures.

Nothing else is touched.

What do you mean by "clean" a volume "without formatting"?

You delete all files on it and it is just (as far as contiguity/defragging is involved) as a new volume.

 

:cheers:

Wonko



#9 steve6375

steve6375

    Platinum Member

  • Developer
  • 7566 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films
  •  
    United Kingdom

Posted 20 August 2013 - 03:52 PM

I have Win7 64-bit and a 4GB USb flash drive.

If I install grub4dos to the PBR and then do format /q M:   - the bootmgr PBR boot code is installed.

We need to preserve all boot code but just delete all file allocations.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users