Skip to content

Image File Fragmentation

Eric Helgeson edited this page Jan 7, 2025 · 6 revisions

What?

If the image file on your SD card is fragmented it can impact the performance.

You will see a warning:

 - file is fragmented, see https://github.com/BlueSCSI/BlueSCSI-v2/wiki/Image-File-Fragmentation

which leads you to this page.

Solution

Copy files

  • Copy all files off your SD Card.
  • Delete all files off the SD card or do a Full format of the card
  • Copy all the files over to your SD Card one at a time.
  • The files should no longer be fragmented on the SD card.

Mac OS

Modern MacOS has extended attributes on files which can not be copied to FAT/exFAT file systems and cause fragmentation when attempting to copy. Here are a few work rounds:

  • Copy the file without extended attributes
    • cp -X MyFileName.hda /Volumes/MySDCard/

or

  • Remove extended attributes before copying files
    • Open Terminal
    • Run xattr -c MyFileName.hda
    • Run xattr -d com.apple.provenance MyFileName.hda
    • Copy via Finder or CLI.

Stop MacOS from placing metadata files:

It is also a good idea to stop MacOS from updating metadata files on the drive:

  • Exclude the SD Card from Spotlight
    • System Settings -> Siri & Spotlight -> Spotlight Privacy...
    • Exclude the SD Card
  • Disable .DS_Store creation on removable drives
    • Open Terminal
    • Run defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true

Defrag (Windows)

  • Use a defrag utility like Defraggler to defrag the image file on the SD card.

Technical details

https://github.com/greiman/SdFat/issues/256#issuecomment-778795554