Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pv can't show progress properly #148

Open
sonnyhcl opened this issue Apr 29, 2019 · 2 comments
Open

pv can't show progress properly #148

sonnyhcl opened this issue Apr 29, 2019 · 2 comments

Comments

@sonnyhcl
Copy link

flash/flash

Line 632 in 0b28b5c

pv -s "${size}" < "${image}" | sudo dd bs=$bs_size "of=${rawdisk}"

In my use case, the progress soon gets 100% but the dd command is still working at 10MB/s. It seems the image is preloaded in memory.

clhu@t5 ~/w/f/sample> flash --userdata static.yml -d /dev/sdd ~/Downloads/installer/hypriotos-rpi-v1.10.0.img 

Is /dev/sdd correct? y
Unmounting /dev/sdd ...
Flashing /home/clhu/Downloads/installer/hypriotos-rpi-v1.10.0.img to /dev/sdd ...
1000MiB 0:00:02 [ 400MiB/s] [=========================================================>] 100%
@sonnyhcl sonnyhcl changed the title pv can't show progress pv can't show progress properly Apr 29, 2019
@sonnyhcl
Copy link
Author

Actually, dd is now providing a progress flag to tell you the progress.

status=LEVEL
              The LEVEL of information to print to stderr; 'none' suppresses
              everything but error messages, 'noxfer' suppresses the final
              transfer statistics, 'progress' shows periodic transfer
              statistics

flash/flash

Lines 628 to 637 in 0b28b5c

echo "Flashing ${image} to ${rawdisk} ..."
if [[ -x $(command -v pv) ]]; then
sudo_prompt
size=$(/usr/bin/stat "$size_opt" "${image}")
pv -s "${size}" < "${image}" | sudo dd bs=$bs_size "of=${rawdisk}"
else
echo "No 'pv' command found, so no progress available."
echo "Press CTRL+T if you want to see the current info of dd command."
sudo dd bs=$bs_size "if=${image}" "of=${rawdisk}"
fi

It's time to change this using progress flag

echo "Flashing ${image} to ${rawdisk} ..." 
sudo dd bs=$bs_size status=progress "if=${image}" "of=${rawdisk}" 

@shafer
Copy link

shafer commented Aug 10, 2020

I don't think it is pv that is the problem. I think the problem is that dd needs flags to bypass cache(s) so that writes don't appear to finish super fast and you see the real progress. I added oflag=direct iflag=fullblock to my dd options and then the progress looks correct. I don't know if macOS supports those options. If there is interest I'm game to make a PR that adds support to the script so that the progress shown by pv reflects reality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants