3

I...

  • Bought a microSD card to store music on, for my Samsung Galaxy S4.
  • Inserted it into the S4 and formatted the card (exFat).
  • Installed fuse-exfat and exfat-utils and inserted the card into my computer (Fedora 21, Gnome 3.14); Mounts successfully.
  • Copied music to the card.
    • Directory Structure: Card/Music/Artist/Album/SongTitle.ogg
  • Opened files -- they play fine.
  • Unmount card
  • Eject card
  • Insert card into computer again
  • Noted that many files and folders no longer appear.

    • All Artist folders appear.
    • Some album folders do not appear
    • Most song files do not appear.
    • Seems that for both files and folders, there is a discrete point where they disappear (ie, the start of the alphabet copies successfully), though folders get farther than files.
1

You don't mention unmounting before ejecting the card. If that isn't an omission when writing the question, there's your problem.

Writing to any kind of disk is buffered: the operating system accumulates data to write in memory, then writes it to the disk when it judges it to be convenient. The data isn't necessarily written to the disk in the same order that applications wrote their files.

This is normally fully transparent to applications. When an application reads data back from the disk, if the data is still waiting in a buffer, the application gets that data back.

However, if you suddendly eject the disk, all the unwritten buffers get lost. They aren't recovered when you insert the disk back because the operating system has no way to be sure that this is the same disk and that the disk hasn't been modified on another machine in the meantime. (And anyway the OS reuses the in-memory buffers for other content as soon as it detects that the disk has gone — because it couldn't use the buffer contents for anything anyway.)

Before ejecting the disk, you need to tell the operating system that you aren't using it any longer. This is called unmounting (the opposite operation, making the system start using a filesystem, is called mounting). When you tell the system to unmount the filesystem, it will flush all the buffers so that the data on the disk is up-to-date. Typical desktop environments automatically mount the disk as soon as you insert it. You need to tell your system to unmount before removing the disk: if you remove the disk, it's too late for the system to unmount. Many file managers show an “unmount” or “eject” button; press it and wait for the file manager to tell you that the operation is finished (depending on how much data remains to be written, it can take a few seconds), then you can eject the card.

This has nothing to do with exfat, by the way, it would happen with any filesystem and any media.

It is possible to configure writes on the card to happen automatically. This is not done because it can be a lot slower, and because the more frequent writes can wear out cheap flash media very quickly (flash media is limited in the number of times a block can be rewritten, and repeatedly rewriting a block just to update a small part of it is inefficient comparing to writing a large amount of data in a single go).

  • It was an omission, my apologies; I meant using Nautilus' eject button, waiting until gnome has finished writing data to disk, and then ejecting. I've edited the OP to reflect that. I do agree, though, that something like this is the most likely problem. I'll try using 'sync' from the command line before I unmount, next time. – Julian Delphiki Feb 16 '15 at 18:30
  • @JulianDelphiki Unmounting causes a sync. I wonder if this could be a bug in synching through FUSE. If you write a large amount of data, does unmounting take longer than if you hadn't written anything? – Gilles Feb 16 '15 at 19:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.