FreeBSD Flash Drive Issue

I've plugged in a USB flash drive and transferred a file of around 4 GB in size without running the sync command. I was using Dolphin File Manager. After I removed the flash drive and plugged it back in, I noticed that the file size had changed to about 13 MB. This issue never happens when I run sync and then umount the drive.

How can I automate this process so that even if a user removes the USB flash drive without ejecting it or running the sync command manually, the data is still properly written to the device?

Most people who would be using this workstation are used to Windows or Ubuntu, where they typically transfer files and remove the drive without explicitly ejecting it, and it still works. So I’d like to make the experience on FreeBSD a bit more foolproof and reduce the risk of data loss in case users forget to sync and eject properly.
 
This issue never happens when I run sync and then umount the drive.
Syncing is done when you unmount it.
where they typically transfer files and remove the drive without explicitly ejecting it, and it still works.
Until it doesn't. Even on Windows you should properly 'eject' a memory stick to make sure it's actually done writing to it.
 
Thank you! Now, I'm running into an issue with File Managers like Dolphin, Thunar or Nautilus, everytime I try to unmount/eject a flash drive from the File Manager GUI, it keeps telling me the device is busy can't unmount/eject/safely remove. They freeze. Is there a way to avoid that?
 
The device is probably busy. The most common cause for that: If you have a shell window, and are cd'ed into a directory on the device (*), the shell keeps the directory open and prevents unmounting. How to debug this? Use the fuser utility, on the directories on the device (*).

(* Footnote: When I say "on the device", I really mean "in the file system on the device", but that's sort of implied, and too many words.)
 
It usually happens when you mount NTFS partitions.
Just close all terminals and file managers and try again, eventually logout/login and try again.
 
Back
Top