8

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.

8

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.

  • Is there a way to set the default "fstab" options for removable devices? – Aaron Franke Nov 25 '18 at 8:45
1

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.

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.