Announcement

Collapse
No announcement yet.

dd show progressbar

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    dd show progressbar

    Hello. Just a word of advice, i'm new to scripting. Anyway I put together a little kdialog script for dd. I know it's VERY basic but It kind of works in that it does the job but i can't get any output. here's what i have:

    #!/bin/bash

    password=$(kdialog --password "Enter root password")

    echo "$password" | sudo -S dd if=/home/yikes/Downloads/kubuntu/kubuntu.iso of=/dev/sda bs=20M status=progress

    kdialog --progressbar "Copying files" 100 --auto-close​
    I'd love to know if i can get some kind of feedback.

    I know it's not what you may call an IMPORTANT problem but I'd love to know how to do it properly.

    Thanks guys!



    #2
    Update!!! this line "kdialog --progressbar "Working..." 0

    ​"
    gives tells me that the script is running but it doesn't really give me a percentage.

    Comment


      #3
      Yet another update. I tried using "kdialog --progressbar "Processing Files" 100
      ​" but it just stays stuck at 0 percent.

      Comment


        #4
        (For: GNU Coreutils 8.24+ (Ubuntu 16.04 and newer)), do this to see the progress dd is making:

        status=progress

        (place that in your dd statement)
        An intellectual says a simple thing in a hard way. An artist says a hard thing in a simple way. Charles Bukowski

        Comment


          #5
          You can test all this stuff!
          Use an idle flash drive, and write zeros to it or something like that and watch the progress messages as it goes along until it finishes.
          An intellectual says a simple thing in a hard way. An artist says a hard thing in a simple way. Charles Bukowski

          Comment


            #6
            hey guys! Thanks for responding so soon. Qmike I'm running dd (coreutils) 9.4. Your answer left me somewhat kind of confused, bare in mind i'm just learning. I will say it's educational. As for testing I'm using an external ssd as a starting point. i swear it's gonna die after all I've thrown at the poor thing.


            Comment


              #7
              (prior to GNU Coreutils 8.24+ (Ubuntu 16.04), people used the pv utility to show dd progress (using piping; a little more complicated))
              An intellectual says a simple thing in a hard way. An artist says a hard thing in a simple way. Charles Bukowski

              Comment


                #8
                Ok so PV works, based on the script I've given could you maybe help me out a little.? how do i go about incorporating the two? please!

                Comment


                  #9
                  Hello AGAIN Qmike. Ok i ran "pv /home/yikes/Downloads/clonezilla/clonezilla.iso | dd of=/dev/sdb bs=20M

                  ​"

                  it cloned the image but the progress bar just said "[================================================== ============>] 100%
                  ​"

                  I know in my heart I'm getting close. I would really appreciate your sage like wisdom!

                  Comment


                    #10
                    ok based on what you've told me i can use both pv and DD command. I ran this "pv /home/yikes/Downloads/kubuntu/kubuntu.iso | dd of=/dev/sdb bs=20M

                    ​" it sort of worked. As in it went from 0% to 100% in a few seconds.

                    Thanks for you help QMike.

                    Comment


                      #11
                      I've never written scripts (although at one time I wrote programs in 5 languages, haha).
                      And I don't use pv because everyone now simply uses
                      status=progress
                      placed directly in your dd line.

                      pv requires some options, as explained briefly in my how-to:
                      https://www.kubuntuforums.net/forum/...472#post565472
                      An intellectual says a simple thing in a hard way. An artist says a hard thing in a simple way. Charles Bukowski

                      Comment


                        #12
                        Ok i'm gradually making headway. I used this line " echo "$password" | pv $sourcefile | dd of=$answer bs=20M" but now i'm getting "dd: failed to open '/dev/sdb': Permission denied

                        ​"

                        Comment


                          #13
                          Originally posted by TheYikes View Post
                          echo "$password" | pv $sourcefile | dd of=$answer bs=20M
                          Use: sudo echo "#password" | sudo pv $sourcefile | sudo dd of=$answer bs=20M
                          Windows no longer obstructs my view.
                          Using Kubuntu Linux since March 23, 2007.
                          "It is a capital mistake to theorize before one has data." - Sherlock Holmes

                          Comment


                            #14
                            Originally posted by TheYikes View Post
                            Code:
                            kdialog --progressbar
                            kdialog can't know what process you want it to show progress for. To use it, it has to be run first and the output, the dbus address, saved. Then to show progress, a dbus message has to be sent to it. For example
                            Code:
                            dbusref=$(kdialog --progressbar "running" 10)
                            for ((i = 1; i<=10; ++i)); do
                                sleep 1
                                qdbus $dbusref value $i
                            done
                            qdbus $dbusref close
                            (Note that on 24.10 I had to install qdbus-qt5 for the qdbus command to work without the error qdbus: could not find a Qt installation of ''.)

                            To use that with dd, you'd have to capture its progress output, parse it, and generate the dbus messages. You'd also want to check that the message succeeded, in case the dialog was cancelled or closed.

                            Also, a major warning. dd's progress is not very accurate, and can be very misleading, because the OS will automatically buffer the output with available RAM. If, say, you have 16 GB of RAM, say 10 GB free, and you're copying 8 GB to something slow, say a USB stick, dd will think it's finished long before the OS has finished writing. In theory, you could use oflag=sync, but I have no experience with that.
                            Regards, John Little

                            Comment


                              #15
                              As Snowhog said, you need sudo with dd. Fact is, with pv, many users -- so it seemed at the time -- used (in Konsole), sudo su, to get a root prompt first before running dd.
                              I haven't kept up with the pro's & con's of doing that, though.

                              I have also heard (as jlittle points out), that the progress bar may at times be misleading.
                              I have used it only infrequently as usually I forget to include it before I press the Go button on dd!

                              It seems to me, it's so much more straightforward to simply use status=progress (regarding the complexities of pv).
                              An intellectual says a simple thing in a hard way. An artist says a hard thing in a simple way. Charles Bukowski

                              Comment

                              Working...
                              X