We are buffering on a USB drive and after x-minutes this will be send to our server. because this involves a lot of write and delete cycles the USB dies pretty quickly (between 1.5 - 6 months)
I know this is not an ideal situation but due to many reasons I need to deal with this for a while and as a backup solution the USB will remain
(incase there are internet issues it can still buffer on the local server).
However I am trying to look for a way to increase the USB lifetime even if it is just a small improvement.
I have been reading up on the limited write/delete cycles and I was wondering if I could possibly save lifetime on USB by modifying the files instead of creating and deleting files.
The current file size is around 524 B... this is not alot while the blocksize is 16.384 B.
As I understood from all the information I have gathered this space will be reserved by default so I should be able to write another 30+ times to this block before it will use another block, correct?
So my plan was to have a dedicated file for each device that needs to buffer and let the file grow and shrink by adding content to the file instead of creating a new file.
And not delete the file over and over but just empty the contents of the file.
So the real question is: Will modifying a file save (possibly) any lifetime for the USB instead of creating and deleting files constantly or will it not matter at all?
First. the pendrive and SD, use block of N bytes, N can be 128, 256, 512 and so on.
Small block is better, because if one software write por example each 128 bytes, or each lap of time, is not equal write one time 128, that two times 256 bytes, or four times 512 bytes block.
So, I will try to get fewer size block, but it implies that the maximum size of files is lower.
Second, and more important, try to not use caché write through, because it always write to disk. Is better to keep all in memory, and write just once in pendrive or SD. This point invalidate the first one of block size.
Third, in Linux, you can minimizing disk access You may want to configure journald to store its journals in RAM, e.g. by creating a custom configuration file: /etc/systemd/journald.conf.d/usbstick.conf
[Journal] Storage=volatile RuntimeMaxUse=30M