Results 1 to 3 of 3
Hello All,
I'm trying to disable buffered write to a USB stick for our embedded Linux system.
The USB stick can be used for logging and the reason I want ...
- 06-18-2009 #1Just Joined!
- Join Date
- Jun 2009
- Posts
- 2
Disable buffered write to USB stick.
Hello All,
I'm trying to disable buffered write to a USB stick for our embedded Linux system.
The USB stick can be used for logging and the reason I want to disable buffered write is to ensure the logs on the USB stick are up to date if the embedded system looses power or the USB stick is removed without being unmounted.
Currently when logging to USB is enabled and the USB stick is removed without first being unmounted: severlal seconds of the the logs entries on the USB will be missing.
I am currently mounting the USB stick as follows:
I have looked at the man pages for the mount command and have been unable to find anything about disabling buffered write.Code:mount -t vfat /dev/sda1 /mnt
Does anyone know how to do this?
Regards,
Don
- 06-18-2009 #2Linux Guru
- Join Date
- Nov 2007
- Location
- Córdoba (Spain)
- Posts
- 1,513
There are many things involved. I don't know if there's a way to do it at the level of usb-storage (which is the driver that manages these drives).
So I suggest doing it at the fs driver level. You might want to read about "sync" and "dirsync" on the man page for "mount".
Note however that doing sync'ed I/O has some secondary effects. It will render the I/O scheduler almost useless for write operations, since the operations will be done as soon as possible instead of being scheduled and re-ordered in a sane fashion. That might or might not be an issue depending on the bandwidth of your USB bus and devices and the amount of traffic they receive.
The other side effect is that the life cycle of the device will be shorted if it's NAND based. That because these devices are flased in blocks. If you write one single byte, then the whole block that contains that byte needs to be flased. That means that if a second later you need to write another byte in that same block, the whole block will be reflased again.
When you do asynchronous I/O there's a big chance that the two write operations will be re-scheduled as a single operation, so the same block would only need to be reflashed once.
Whether these factors are relevant in your situation or not is for you to decide.
- 06-18-2009 #3Just Joined!
- Join Date
- Jun 2009
- Posts
- 2
Hi i92guboj,
Thank you very much for the very informative reply. That's exactly what I needed to know.
Best Regards,
Don


Reply With Quote