1

I am trying to create a new file (blank file) with:

dd if=/dev/zero of=file.txt count=10240 bs=10240

I also want to use dialog output --gauge, something like this:

dd if=/dev/zero | pv | dd of=output.dat count=10240 bs=102400 iflag=fullblock | dialog --gauge "testing" 10 70 0

I have also tried variations of:

(pv -n /dev/zero | dd if=/dev/zero of=output.dat  bs=1000M  count=1) | dialog --guage "Creating a file..." 10 70 0

However it doesn't work, is just lets me know when the file is completed.

Thanks.

3
  • Try unbuffer. Jun 18, 2018 at 13:47
  • Never knew about unbuffer, but tried it now same result
    – warhansen
    Jun 18, 2018 at 13:54
  • dialogis not a UNIX command. Please explain what you are interested in.
    – schily
    Jun 18, 2018 at 14:20

3 Answers 3

1

I suggest that you skip dialog and use a 'plain' pv progress view in the command line like so

# dd if=/dev/zero bs=10240 count=102400| bash -c 'pv -s 1g  > /media/sudodus/usbdata/output.dat'
 320MiB 0:00:07 [39,2MiB/s] [=========>                        ] 31% ETA 0:00:15
...
1000MiB 0:00:34 [29,1MiB/s] [===============================>  ] 97%            
102400+0 records in
102400+0 records out
1048576000 bytes (1,0 GB, 1000 MiB) copied, 34,4327 s, 30,5 MB/s

I wrote to a USB pendrive to make things slower and easier to 'see'.

1

Since I've been myself trying to do this, here is a solution.

pv writes to stderr, so you need to redirect the output to stdout.

I want to write zeros into a cyphered partition. So:

#dd if=/dev/zero of=/dev/mapper/swap_crypt bs=1M
    dd: error al escribir en '/dev/mapper/swap_crypt': No queda espacio en el dispositivo
    4269+0 registros leídos
    4268+0 registros escritos
    4475322368 bytes (4,5 GB, 4,2 GiB) copied, 4,1489 s, 1,1 GB/s

Since I don't need the output, I tell dd not to print anything but errors with status=none:

# dd if=/dev/zero of=/dev/mapper/swap_crypt bs=1M status=none
# 

Nice, no output! So now I use pv to monitor the progress and since I also know how many bytes were written you can tell to pv to print a percentage base on the bytes transmitted: -n writes the percentage and -s bytes to transmit:

# dd if=/dev/zero | pv -n -s 4475322368 | dd of=/dev/mapper/swap_crypt bs=1M  status=none
16
32
43
52
61
69
77
84
88
dd: error al escribir en '/dev/mapper/swap_crypt': No queda espacio en el dispositivo
100
# 

Now we redirect the stderr to stdout and pipeline to the dialog --gauge:

#(dd if=/dev/zero | pv -n -s 4475322368 | dd of=/dev/mapper/swap_crypt bs=1M  status=none) 2>&1 | dialog --title "Status"  --gauge "Writing zeros..." 10 60 0 

Now you only need to figure out (easy task) before the transfer how many bytes it is going to take and replace the number in the -s parameter of pv.

0

Slightly off-topic, but you can use the status=progress operand in dd and you'll get something like this:

748901888 bytes (749 MB, 714 MiB) copied, 3 s, 250 MB/s
7
  • dd if=/dev/zero of=/dev/null status=progress count=10240 bs=10240results in: dd: bad argument: "status=progress"
    – schily
    Jun 18, 2018 at 14:19
  • @schily Then your version of dd doesn't support it.
    – user147505
    Jun 18, 2018 at 14:23
  • If you mention a feature that is not supported by the standard dd then you should name that special dd clone.
    – schily
    Jun 18, 2018 at 14:32
  • @schily It's a standard GNU on Debian 9. But man dd on my FreeBSD says status is an extension to POSIX.
    – user147505
    Jun 18, 2018 at 14:38
  • So you are not using a standard UNIX implementation. The FreeBSD implementation does not support it as well and other dd implementations (like e.g. sdd) use a different command line argument for that feature since 38 years which is approx., 12 years longer than GNU dd exists.
    – schily
    Jun 18, 2018 at 14:47

You must log in to answer this question.

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