Linux tool to show progress for cp, mv, dd
github.com
github.com
xfennec (and some friends?) I think built a game engine called Raydium, and one of their games called Mania Drive-a Track Mania clone-got distributed with OpenSuse installation CDs back in the day. When I was just like 12 years old, my dad installed that on the family computer and it was all we had, Mania Drive was one of the coolest games on there. Me and my siblings played that for literally days and months on end, making crazy levels we couldn't beat without knowing every turn. It was a huge part of our childhood.
Their game engine was in C with PHP scripting, I remember posting some levels to their forums and asking, in retrospect super dumb, questions and they were so polite and friendly. I remember us joking at the time that the French seemed like these god-like game developers, it had such a profound impact on us, I even wrote about it last year and linked a video of Mania Drive first[0]. I went on to learn Python and then lower-level languages as a result. I'm not sure I'd be coding today without them, to be honest.
Sorry it's off-topic, just really blown away to see a username like that pop up in my feed. Really goes to show that kindness + some cool open source software can have profound effect on people.
[0] https://devlog.hexops.com/2021/increasing-my-contribution-to...
> // Don't remove this print statement. Game will crash!
:-)
Those where the days you could email a webmaster and get a response, when you hung around with like minded people in self-organised communities around a thing that interested them - like reddit without the massive negativity and astroturfing.
The modern internet (or web really) has lost much of that flavour, there are a few places that still maintain it with anonymity - HN is one, specific subreddits, the IRC server I've hung around forever, I've friends on there going back more than 15 years, we where all early 20's computer geeks, now a lot of them are married with kids or have kids on the way - I know a tonne of details about them personally and sometimes don't know their real name.
I do see some echoes of that world in some modern platforms (discord for specific games (in my case Arma) captures some of it).
% stty status '^t'
btw, for Linux dd(1) I know about "status=progress", but for me it is a bit hard to remember and specific to dd(1). But, nice little utility :)
Inevitably it turns out my idea was not as useful as it seemed when it first popped in my head, so after a few weeks/months that Pi is turned off and returned to the pi drawer.... ready for the next brilliant idea.
(ps. I typically use the `pv` command to see progress with stuff other than dd)
Love that philosophy of keeping an inventory (recycled in this case) of Raspberry Pi’s !
Do you buy a Pi when first starting a project?
The nice thing with ^T versus status=progress is that ^T will work even when dd was invoked from some script that you don't necessarily want to edit, etc.
I first came to love it learning how to fix my bootloader and undo all sorts of horrible things I'd done to my system when I was a teenager exploring Linux well over a decade ago. I also worked in repair for a while and there it was indispensable for data recovery purposes along with its cousin ddrescue.
Now I just use it for my constant tinkering needs.
dd conv=sparseWhy does it matter? Use `bs=$((4 * 1024 * 1024))`. It'll work perfectly for any imaginable block size.
My issue with dd is that it's possible to write corrupted data with some weird flags which I did once. Something with conv=sync I believe which does unexpected things. But if you're not trying to be too smart, dd works fine.
Info defaults to dumping generic stuff, it’s completely safe (unless a dev decided to handle it by dying but I would not want to use their software).
dd if=<input> | pv | dd of=<output>
to get a count of bytes passing through, or pv <input> | dd of=<output>
to get actual completion progress. For tarchives, pv <tarchive> | tar x
Compression progress pv <file> | bzip2 > <file>.bz2tar c foo | pv | gzip | socat - tcp-listen:9999
socat tcp:bar:9999 - | pv > foo.tar.gz
If pv shows that you aren’t saturating your network and are cpu limited, replace gzip with lzop. If vice versa, replace gzip with something more aggressive.
tar c foo | pv -cN raw | gzip | pv -cN compressed | whatever else
It’s handy to see multiple progress bars at once.
Try
cp $BIGFILE ${BIGFILE}_1 & pv --watchfd $(pidof cp)
Similarly you could alias rsync instead of copy and move:
alias pcp='rsync -au --info=progress2'
alias pmv='rsync -aP --info=progress2 --remove-source-files' 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
and pv pv - monitor the progress of data through a pipe
So with pv, you can do something like dd if=/dev/zero count=2 bs=512 | pv | dd of=/dev/null
to visualize your dd progress.I recall I started using ddrescue because one of my distros would not autocomplete with the if= prefix, but I can't seem to replicate it currently - so it's probably been fixed (or my memory is failing me).
Meanwhile, the Linux kernel has removed Shift-PgUp scrollback from the console.
* https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux...
There's already kmscon but I haven't looked closely into what prevented that transition from moving forward as the default. Presumably there's a bunch of edge cases a kernel based console doesn't suffer from, like having to avoid oom killer or getting paged out/becoming unresponsive on systems falling over etc.
The console process will have to be something exceptionally configured, pinned memory, realtime priority, oom-immune, all that jazz.
* https://jdebp.uk/Proposals/linux-console-daemon.html
What happened to kmscon is that the systemd people, having adopted it with much hullabaloo, dropped it a while later with far less fanfare.
That said, there are a range of options for people who want to build Linux without CONFIG_VT.
* https://jdebp.uk/Softwares/nosh/user-vt-screenshots.html
* https://jdebp.uk/Softwares/nosh/guide/user-virtual-terminals...
(-:
UNIX-like is not a convention of UNIX - it's a convention of "we didn't get to making that useful thing yet, there's other stuff to do."
[user@machine ~]$ dd if=/dev/zero of=/dev/null &
[1] 3254428
[user@machine ~]$ kill -USR1 %1
19061394+0 records in
19061393+0 records out
9759433216 bytes (9.8 GB, 9.1 GiB) copied, 6.06968 s, 1.5 GB/s
[user@machine ~]$ kill -USR1 %1
25868762+0 records in
25868762+0 records out
13244806144 bytes (13 GB, 12 GiB) copied, 8.97352 s, 1.5 GB/s
[user@machine ~]$ kill %1
[1]+ Terminated dd if=/dev/zero of=/dev/nullTry stty tostop
kaz@sun-go:~/txr$ stty -tostop
kaz@sun-go:~/txr$ dd if=/dev/zero of=/dev/null &
[1] 14604
kaz@sun-go:~/txr$ kill -USR1 %1
kaz@sun-go:~/txr$ 1142200+0 records in
1142200+0 records out
584806400 bytes (585 MB, 558 MiB) copied, 2.62053 s, 223 MB/s
kaz@sun-go:~/txr$ kill -USR1 %1
2054884+0 records in
2054883+0 records out
1052100096 bytes (1.1 GB, 1003 MiB) copied, 4.70066 s, 224 MB/s
kaz@sun-go:~/txr$
kaz@sun-go:~/txr$ stty tostop
kaz@sun-go:~/txr$ kill -USR1 %1
kaz@sun-go:~/txr$ kill -USR1 %1
[1]+ Stopped dd if=/dev/zero of=/dev/null
kaz@sun-go:~/txr$ kill -USR1 %1
[1]+ Stopped dd if=/dev/zero of=/dev/null
kaz@sun-go:~/txr$It works by reading /proc/PID/fdinfo/*
you want some kind of managed buffer (aqm/sqm/qos) in your bottleneck router.
openwrt or any linux can do it as the needed parts (fq_codel or cake qdisc) are in upstream for some years now and wrappers like firewall distros or libre-qos make it available via gui.
there is also some proprietary soho gear that allegedly works, big-iron is still on red/pie w/o fair queueing afaik
yes and no. "throttling up the stack" is crude but effective in a narrow set of circumstances (just takes an additional transfer from another device to render it ineffective).
ack thinning (dropping ack segments) is supported in cake but it's not a mechanism of throttling but for very asymmetric lines such as docsis where surplus ack's can saturate the upstream.
dropping of regular packets is the only way to reliably communicate "slow down" between tcp-endpoints (yes ecn exists) but this is not the main selling point here. every queue has to drop packets at some point, codel does it in a smart way.
fair queueing dissects diverse packet streams into flows (same set of src/dst ip/port) and separates them in order to minimize interference. this is what you want basically everywhere as ip-networks are by definition "best effort" and no amount of userspace whishmakeing (dscp,l4s) is going to fix it.
thou it suggests to me that you might want to investigate your i/o scheduling arrangements
I found that `iotop` is great for this kind of thing. Sure, you have to either start it before your process starts or your accumulated total is off, but usually I'm not tracking progress for files less than 1GB so being off by kilobytes is fine.
My go-to's are `sudo iotop -aoP` for general monitoring, adding the `-p` flag if it's just a specific process, or `-u` if I'm monitoring something that is possibly transient.
You can invoke `sync` to watch the buffered-writes queue burn down when you have lots of pending writes.
see: `LESS=+/meminfo man proc` or https://github.com/torvalds/linux/blob/master/Documentation/... for more info
Wasn't expecting something as simple that at all. Bloody ingenious.
Did anyone else look at the code and ask themselves- what is the actual formatting standard being used?
Looked like a mix of “open brace on same line, 4 chars indent for code” then “open brace on new line, code at same zero indent”
Not a big deal obviously. Just something that tripped up my eyes scanning the code.
Looks like a combination of Whitesmiths and ChatGPT.
Show HN: Linux tool to show progress for cp, rm, dd, etc. - https://news.ycombinator.com/item?id=8023713 - July 2014 (53 comments)
(as it doesn't seem to have been posted by the creator, Show HN was a mislabel there)
iirc, dd on *BSD will show progress on ^T because it sends a SIGUSR1
Downside of SIGUSR is that it will kill the process if there's no handler, rather than ignoring it, so "just try it" is always risky.
Then I switched to using sddm for my display manager/login screen. It didn't have a USR1 handler. If you kill your display manager, you're forcefully and suddenly logged out of your session.
I stopped using 'killall -USR1 dd' for dd status.
https://www.kylheku.com/cgit/pw/about/
Pipe Watch continues to read from the pipe even when backgrounded.
Pipe Watch shows you snapshots of the text that is passing through it. You can set triggers and filter and such. The triggers work even when it's in the background, not refreshing the display..
pv largefile.sql > mysql -u root -psecret
[1]: https://opensource.apple.com/source/xnu/xnu-7195.81.3/libsys...
I even recall cp having been patched with a progress bar maybe a decade back in Gentoo, but for some reason that didn't stick.
has been in my ~/.bashrc for the majority of my career for large file transfers.
There are vast numbers of improvements to softwares that never get sent to the places where they will do the most good (or at least have a proper record of why they were rejected by their authors). A quick perusal of the bug trackers of Debian or Ubuntu will reveal tonnes of local patches that the original authors of the softwares often never even hear about.
Things don't "stick" often times simply because they get lost.
I was looking at something like that just the other day. Here's a bug report that describes a problem with "doas" not opening the controlling terminal to do its authentication dialogue. This is actually a problem with a package named LinuxPAM, and doesn't occur when "doas" uses OpenPAM or BSD Auth. It's LinuxPAM that's where the code in question is. Fixing LinuxPAM would improve the lives of everyone that uses LinuxPAM, because the behaviour of not allowing standard input through in a command pipeline is not confined to "doas" but affects everything that uses LinuxPAM to do login authentication.
But time and again stuff like this languishes in the wrong place, for years and decades.
* https://github.com/jarun/advcpmv
This one got lost because the original author's WWW site just vanished, according to the doco.
I think commands could have progress but only as explicit option. I wish curl and 'docker pull' didnt spew so much text by default, filling up so many jenkins server's disks.
curl -sS -w '%{http_code} %{http_version}' https://www.goog le.com -o /dev/null
https://everything.curl.dev/usingcurl/verbose/writeout
I’ve only recently had to use curl’s features more in-depth, so I’m still fascinated by its potential.
Creating ticket... (200 OK)
The philosophy surrounding these tools wouldn't lend well to each implementing that. Fortunately `pv` exists, is perfect for this use-case, and included in many distributions. :)
It is an open question whether progress is 'interesting' or not. My own opinion is that it is not interesting if the operation is nearly instantaneous. If any operation can take more than 5 seconds, it should have a progress bar and an estimated time of completion.
Earlier versions of Windows did this very well. Often these progress bars were a joke, but sometimes they were useful. It gave us valuable input on whether there is enough time to go get a cup of coffee, which as we all know, is the most important question for us all.
Almost. For some reason the Win95 and Win98 installer needed 75% of the time to go to 99% and 25% of the time to go from 99% to 100%.
If an operation is silent and hogging my prompt without any indication what is going on, is stuck, is the speed too slow etc. it is simply frustrating.
What I was thinking of is, a user invoking a script interactively which happens to call a tool (like CURL) may not want to see curl's big progress song and dance for every HTTP call the script makes, though a user invoking `curl` literally, would likely appreciate it. But I think in both cases curl sees a TTY, right? Oops.
You imply a great point that at least doing `2>/dev/null` in those scripts is at least consistent, and I just need to make a better habit of doing so.
coreutils refused the patches as saying they are feature complete, whilst they dont have progress support, nor Unicode support. Stubborn
How did you set up your website xn0 to deliver the /rp file?
I gave it a try on a ddrescue job (unfortunately not recognized by default) and the estimated remaining time varies quite a bit between what ddrescue says and what progress says. I think ddrescue uses a larger moving average window and it seems to give more accurate estimates, although they are still far from perfect.
I’ve used a signal handler (SIGHUP aka control-c) before as a “show progress” mechanism that I found very useful to monitor long running processes that were compute not io related (launched in screen fwiw to stay the active process).
I SSH into many many different machines (desktops, routers, servers, IoT devices etc..), and unless something is in the default install of RHEL, Debian, Arch etc..,I tend to not rely on it, as my muscle memory will cause me problems.
But since it is separate, I can install it where and when I need it, perhaps with the transfer already in progress. That might be hard for IoT/containers, but do I really need to see file copy progress in those kinds of places?
Also, agreed on the need for this on IoT stuff. But it's about muscle memory. I want to type the same way on. all devices. Not "oh, I'm on a server, use this command. Oh, I'm on an IoT device, use a different command"
Had blogged about it here, along with a Python program inspired by it, that I wrote:
https://jugad2.blogspot.com/2018/05/a-python-version-of-linu...
progress -wc ffmpegWhen I need it in the middle of process, I just `ls /proc/_pid_/fd` and then take that _fd#_ to `cat /proc/_pid_/fdinfo/_fd#_`
is a related tool.
I have all my basic commands, cp, mv, rm aliased to add the -v argument.