Sample Header Ad - 728x90

Execute single command with write caching disabled

1 vote
2 answers
447 views
Whenever I write a large file to a USB drive, write caching makes it very difficult to track process. I can disable it in various ways like echo 1000000 > /proc/sys/vm/dirty_bytes which solves the problem. However then I also have to re-enable the old setting (or reboot). How can I tell my system to bypass the dirty bytes entirely for a single write command? For example, something like:
DIRTYBYTES=nope pv file.bin > /dev/sdb1
Or
pv file.bin | cache_buster > /dev/sdb1
To clarify: The current behavior of pv file.bin > /dev/sdb1 is that the meter shoots to 100% immediately, and then the command hangs waiting for the USB to actually finish writing. Instead, I want to modify the command and make the meter gradually increase at about the correct write rate of the USB drive, **without altering** the dirty bytes etc settings in such a way that the next command will also bypass the cache.
Asked by Bagalaw (1085 rep)
Nov 22, 2021, 03:28 AM
Last activity: Nov 26, 2021, 09:00 PM