13

I have problems transferring binary programs to a micro-controller prototype board when using ubuntu/kubuntu to mount the board via usb. With MacOS and Windows there are no problems. I have found the writing from Ubuntu definitely changes the written file. I suspect that the write caching is the problem. How can I disable it, or what else might be the problem.

3 Answers 3

11

Read this first: http://groups.google.com/group/linux.kernel/msg/8d1591196c0ae15e?pli=1
I am unsure if it is true or not.

You can try using hdparm to set the write caching feature to off at runtime. (You will probably need to run this after every boot or every time you remove and reinsert the device)

sudo hdparm -W 0 /dev/devicename

Please ensure you know the correct device name (sdb, sdc or so on).

You can find out the device name by running:

sudo fdisk -l

You can also edit /etc/fstab and add the mount options sync,dirsync however I am not very familiar with how /etc/fstab works with removable devices. I think they need a permanent mount point.

1
  • 2
    Is there a way to set the default "fstab" options for removable devices? Nov 25, 2018 at 8:45
5

kudos to @NightwishFan for the hdparm switch to set the drive's write-caching feature.

Note that the sync mount option decreases the speed by a magnitude (over 10 times). flush mount option ensures an effective writing with no performance cost. Also I've been using it with no issues for a few years on all the FAT devices (spinning or flash-memory based) I've used: Actually the whole set of mount options is noauto,users,noatime,flush,umask=111,dmask=000, set manually or in /etc/fstab.

1

I have replaced "sync" in favor of "noatime,flush" like stated in @tuk0z answer.

This lead to the USB floppydrive behaving the same like sync, but it writes files so much faster, like the normal operationspeed you expect it to be.

Reading image files from floppy does not result in random artifacts anymore. Also reading DD floppies does not result in weird characters in filenames.

Perhaps it's a bit unfortunate how the official documentation of "mount" put the usage in context.

Kudos!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .