When I boot my Linux and start writing to a USB-backed block device, everything goes fine for the first few times.
Afterwards, if I write to it once more, dd
reports absurdly huge transfer rates (2.9 GB/s, which isn't possible), and it is seemingly successful. But when I plug it into any other computer, I can clearly see it holds the old data. Yet, my Linux reports the new data even when plugged back in (checked with xxd
)! This should mean that it's holding the data in the cache and not ever flushing it. Only when rebooting does it finally work again.
I've tried many different things: running sync
, passing conv=sync
, conv=fdatasync
, oflag=direct
, writing 3 to /proc/sys/vm/drop_caches
, turning off the USB nicely with udisksctl
, waiting 30 seconds, trying to write zeroes with cat
, etc. but none of them end up doing anything.
I even switched my Linux system to something else (something I almost never do) because the previous one was a buggy mess anyways, but, unsurprisingly, Linux is the buggy mess. This is a brand new, 1-day old Debian 11.
Any ideas?
cp
to write file to a file system ? was it unmount ? if you usedd
which device did you use ? (I suspect you use something likedd of=/dev/usba
this would write to a file name/dev/usba
) – Archemar Oct 03 '21 at 09:29dd if=drive.bin of=/dev/sda bs=1M status=progress
, and it worked fine until it suddenly didn't – Poopoo Oct 03 '21 at 09:31eject /dev/sdX
before removing any usb storage device (or use whatever similar button in your GUI). Not only Linux is caching and lying, but the usb's device firmware does it too. I'm quite skeptical of some of the your claims, though. – Oct 03 '21 at 09:43/dev/sda
before it was created as a block device file, so your USB gotsdb
. Or maybe it was alreadysdb
for whatever reason. Or maybe this time it was not detected at the hardware level (one of my old laptops sometimes does not detect a USB drive until plugged in again). Anywaysda
was a regular file with no connection to the USB whatsoever. You did not notice and worked with the regular file until the reboot./dev
is a virtual filesystem (in memory), the reboot destroyed the file and allowed the things to work as you expect. – Kamil Maciorowski Oct 03 '21 at 12:02lsblk
before any writing; the USB is always in/dev/sda
– Poopoo Oct 05 '21 at 16:43eject
the first few times, could you explain why? Feel free to write as an answer, and I'll mark it – Poopoo Oct 05 '21 at 16:44