1

I write ISO files to USB thumb drives a lot, and I'm trying to find a way to monitor the status of a write. Googling this, I have found a bunch of solutions, including pv, dcfldd and the USR1 signal to the dd command.

In all cases, this seems to be the case:

  1. The file is written to the thumb drive at ca 100 MB/s
  2. The transfer finishes (or possibly freezes at 99.99%) in less than 10 seconds
  3. The transfer command remains unresponsive for several minutes, not even responding to interrupts
  4. The transfer finishes

The behavior I expect would be a relatively slow write, perhaps around 5 MB/s, and a progress bar that progresses evenly from 0% to 100%. It seems to be that the file is written quickly into a buffer of some kind, then slowly flushed to disk afterwards.

Here are some commands I have tried, all with basically the same outcome:

# function vdd {
>     sudo dd "$@" &
>     sudo sh -c "while pkill -10 ^dd$; do sleep 5; done"
> }
# vdd bs=4096 if="/path/to/ubuntu-15.04-desktop-amd64.iso" of=/dev/sdb
dcfldd bs=4096 if="/path/to/ubuntu-15.04-desktop-amd64.iso" of=/dev/sdb
pv "/path/to/ubuntu-15.04-desktop-amd64.iso" | dd bs=4096 of=/dev/sdb
pv -B 4096 "/path/to/ubuntu-15.04-desktop-amd64.iso" > /dev/sdb

I have searched the man pages for dd, pv and dcfldd for the word "flush" with no results...

3
  • I have not seen this on USB transfers, but I have found network transfers particularly prone. When I examine the state of the transfer I find it in non-interruptible I/O, and it is a network driver limitation. I suspect a similar problem with USB, maybe caused by poor hand-shaking in the pen drive, possibly aggravated by retries after write errors. If this is so, I cannot image that any progress monitor would work.
    – AFH
    Commented Jul 31, 2015 at 22:18
  • @AFH I hope that's not the case... It's a shame to have a USB 3.0 stick that I can write to at over 100 MB/s, only to have it reduced to an effective 5 MB/s due to it freezing.
    – Hubro
    Commented Jul 31, 2015 at 22:31
  • I agree, but I've always found pen drives and SD cards a lot less reliable than USB discs, especially when they fill up, though I have not had much of a problem in cameras, maybe because of slower write rates.
    – AFH
    Commented Jul 31, 2015 at 22:38

1 Answer 1

1

If you need it for a cli tool

USB="/dev/sdb"
ISO_IMAGE="/path/to/ubuntu-15.04-desktop-amd64.iso"
SIZE=$(du -h -B1 "$ISO_IMAGE" | awk '{print $1}')

dd if="$ISO_IMAGE" | pv -s "$SIZE" | dd of="$USB" bs=4M oflag=dsync

Here dd will ask for completely synchronous output to disk.

You've mentioned flush, you probably want to use it for some UI to write out progress line by line with pv -n.

 USB="/dev/sdb"
 ISO_IMAGE="/path/to/ubuntu-15.04-desktop-amd64.iso"
 SIZE=$(du -h -B1 "$ISO_IMAGE" | awk '{print $1}')

 (dd if="$ISO_IMAGE" | pv -n -s "$SIZE" | dd of="$USB" bs=4M oflag=dsync) 2>&1 | \
  yad --center --borders=6 --title="Image writer" --text="$(echo -e "Writing $(basename "$ISO_IMAGE"):")"\
        --width=300 --progress --no-buttons --auto-close --image=system-run --window-icon=drive-removable-media-usb

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .