0

I read that to transfer an iso image to a pendrive and print progress I should execute pipeline below.

$ dd if=$IMG bs=4M | pv -s 668M | sudo dd of=/dev/sdc bs=4M

pv should print and update a progress bar in terminal. However, my progress bar jumped to 100% and the command hanged. I could not kill the dd writing to the pendrive so I looked under the hood.

journal

Jan 13 01:57:32 nixos systemd[1]: systemd-udevd.service: Watchdog timeout (limit 3min)!
Jan 13 01:57:32 nixos systemd[1]: systemd-udevd.service: Killing process 1830 (systemd-udevd) with signal SIGABRT.
Jan 13 01:57:54 nixos sudo[3787]: pam_unix(sudo:session): session closed for user root
Jan 13 01:57:54 nixos kernel:  sdc: sdc1 sdc2

iotop

    TID  PRIO  USER     DISK READ  DISK WRITE  SWAPIN     IO>    COMMAND                                                                                       
   1830 be/4 root        0.00 B/s    0.00 B/s  0.00 % 99.99 % systemd-udevd
   3788 be/4 root        0.00 B/s    0.00 B/s  0.00 % 99.99 % dd of=/dev/sdc bs=4M
      8 be/4 root        0.00 B/s    0.00 B/s  0.00 % 99.99 % [kworker/u64:0+flush-8:32]

I tried with sudo or as root. Same effect. pv shows 100% immediately but dd of=... blocks for about 3 minutes. That is not consistent with what I read on the internet and saw myself on other machines. What happened?

PS.

$ sudo hdparm -W /dev/sdc

/dev/sdc: write-caching = not supported

PPS. Tried status=progress - same effect (100% and hangs until write is complete).

  • 1
    You'd be better off using sudo sh -c 'pv >/dev/sdc' <"$IMG". More efficient and less prone to short reads on the pipe causing a mis-write – Chris Davies Jan 17 '22 at 23:58
  • 1
    Google for "Linux dirty buffers". – Artem S. Tashkinov Jan 18 '22 at 01:18
  • 2
    Also this command is total bonkers, this is how I run it: pv -petrab file > destination. No need to pipe twice and use three commands instead of one. Also, just also dd can actually slow down things. – Artem S. Tashkinov Jan 18 '22 at 01:19
  • Also read this https://unix.stackexchange.com/questions/480399/why-were-usb-stick-stall-problems-reported-in-2013-why-wasnt-this-problem-so - this might be exactly what you're experiencing. – Artem S. Tashkinov Jan 18 '22 at 01:21

0 Answers0