#99 [PATCH] Use dd oflag=direct
Closed: Fixed by javierm. Opened by ajax.

Sorry for submitting this as a patch instead of a pull request but the "Open PR / New Pull Request" menu says "bad branch 'master'" and I'm just asking for a one-liner here.

Linux's block layer is somewhat daft and will happily queue up writes for as long as you have the memory. Once enqueued, they are no longer interruptible. In my case, this means on a 64GB host system trying to write an 8GB image to an SD card that can write around 24MB/sec I spend about five minutes staring at dd syncing its output. If I decide midway through that I wanted to flash something else instead I still have to wait for that to finish, and the progress bar was basically lying to me about how fast things were going. Not a good look.

oflag=direct fixes this by asking for O_DIRECT which skips the above buffering.

On my system I also get a warning like:

dd: warning: partial read (8192 bytes); suggest iflag=fullblock

Which might also be worth quashing, and the docs make it sound harmless, but I haven't tried it.

diff -up arm-image-installer-3.7/arm-image-installer.jx arm-image-installer-3.7/arm-image-installer
--- arm-image-installer-3.7/arm-image-installer.jx      2022-09-09 12:28:21.000000000 -0400
+++ arm-image-installer-3.7/arm-image-installer 2023-03-13 22:37:04.469878441 -0400
@@ -340,7 +340,7 @@ if [ "$IMAGE" != "" ]; then
        echo "= Writing: "
        echo "= $IMAGE "
        echo "= To: $MEDIA ...."
-       xzcat $IMAGE | dd of=$MEDIA bs=4M status=progress; sync; sleep 3
+       xzcat $IMAGE | dd of=$MEDIA oflag=direct bs=4M status=progress; sync; sleep 3
        echo "= Writing image complete!"
 fi
 # check to see how many partitions on the image

@ajax thanks for the patch. It makes sense to me and I believe that have seen the same behavior before indeed.

I've pushed with your authorship as commit https://pagure.io/arm-image-installer/c/7179562753b4

Metadata Update from @javierm:
- Issue close_status updated to: Fixed
- Issue status updated to: Closed (was: Open)

Log in to comment on this ticket.

Metadata