#100 Use dd oflag=direct
Merged a year ago by javierm. Opened a year ago by javierm.
javierm/arm-image-installer dd-oflag-direct  into  main

file modified
+1 -1
@@ -340,7 +340,7 @@ 

  	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

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.

Signed-off-by: Adam Jackson ajax@redhat.com

Pull-Request has been merged by javierm

a year ago
Metadata