Linux dd посмотреть прогресс

How to Show Progress for dd

If you have reached this page I expect that you already know what dd is. But you if you don’t, dd is a command-line utility that is used to convert and copy files. It’s commonly found on various (Linux) distro help pages that show new users how to setup USB (or Micro SD) drives to install or run (like Raspberry Pi) the OS.

One of the main problems is that when running the dd utility, it does not provide any information on the current status of the copy process. This can make users anxious not knowing if it’s done or not.

The Solutions

1. Running dd with the status option

This requires you to be running dd version 8.24 and above. If you are running a modern Linux distro you are most likely covered.

You can check your version with dd —version :

➤ dd --version dd (coreutils) 8.32 Copyright (C) 2020 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Written by Paul Rubin, David MacKenzie, and Stuart Kemp. 

We will also need to use oflag=sync to make sure that we are really syncing as data is being copied so we get a better sense of when it’s done. Otherwise dd goes blank at the end as it’s trying to sync.

Note: while using oflag=sync makes the copy slower, using a higher block size will help speed up the process ( bs=4M instead of bs=1M )

The command:
dd bs=4M if=/path/to/input of=/path/to/output status=progress oflag=sync 

Example: here are backing up the contents of /dev/sdf to a file (ubuntu-server-20.04.1-updated.iso)

sudo dd bs=4M if=/dev/sdf of=ubuntu-server-20.04.1-updated.iso status=progress oflag=sync 

The output:

1. Running dd with pv

In reality this should be option 1 as it gives a nicer output with a progress bar, ETA and other data. pv is a terminal-based tool for monitoring the progress of data through a pipeline. It can potentially be used with any pipe.

Читайте также:  Chess on linux mint
The command:
pv -tpreb /path/to/input | sudo dd of=/path/to/output bs=4M oflag=sync 
  • -t — “Turn the timer on”
  • -p — “Turn the progress bar on”
  • -r — “Turn the rate counter on”
  • -e — “Turn the ETA timer on”
  • -b — “Turn the total byte counter on”

Example: Here we are copying the image file to /dev/sdf

pv -tpreb ubuntu-20.04.1-preinstalled-server-arm64+raspi.img | sudo dd of=/dev/sdf bs=4M oflag=sync 

The output:

Putting all in a Bash alias for re-use

Add the function below to your ~/.bash_aliases and it will be available whenever you need. Call it with dd_iso [image] [device] and it will use pv if it’s already installed in your syste.

dd_iso () < usage="usage: dd_iso [image] [device]"; if [[ $# -lt 2 ]]; then echo "$usage"; return 0; else if [[ $# -eq 2 ]]; then iso="$1"; device="$2"; fi; fi; if [[ $!= iso && $ != img ]]; then echo "The first parameter should be an iso"; return 1; else if [[ ! -b "$device" ]]; then echo "The second parameter needs to be a device"; return 1; fi; fi; device_type="$(basename "$(readlink -f "/sys/class/block/$/..")")"; if [[ "$device_type" != "block" ]]; then echo "Do not specify a parition as the device"; return 1; fi; sudo dd bs=4M if="$iso" of="$device" status=progress oflag=sync > 

Источник

How to Use DD Show Progress Command in Linux?

Home » SysAdmin » How to Use DD Show Progress Command in Linux?

The dd command-line utility is used to convert and copy files on Unix and Unix-like operating systems. By default, the dd command doesn’t show any output while transferring files.

This could be problematic when copying large files since you cannot monitor the process.

In this tutorial, you will learn how to use the dd command to show progress.

How to Use dd show progress command in linux

  • A system running Linux
  • A user account with sudo or root privileges
  • Access to a terminal window / command line
  • GNU Coreutils version 8.24 or above

Check dd Version

To see the progress bar while copying files and directories with the dd command, you need a version of dd (coreutils) no older than 8.24. Check the version with the command:

Check Coreutils version.

At the time of writing, the latest version of dd (coreutils) is 8.30 as seen in the image above.

Note: If you need to install coreutils, run: sudo apt-get install -y coreutils .

Option 1: Use the dd Command to Show Progress

The basic syntax for using the dd command is:

dd if=/path/to/input of=/path/to/output

However, the default settings do not show a progress bar or any output while the process is taking place.

Читайте также:  Пакет интеграции ос linux со средой виртуализации microsoft

To see the progress bar, add the status=progress attribute to the basic command:

dd if=/path/to/input of=/path/to/output status=progress

While the system is copying the specified file, it shows the amount of data that has been copied and the time elapsed.

dd command showing progress while copying a file.

Once the process is complete, the terminal displays the total amount of data transferred and the time duration of the process.

Output from dd command showing the process has completed.

Option 2: Use dd Command with pv to Show Progress

The pv command allows a user to see the progress of data through a pipeline. You can use it with the dd command to show the progress of a specified task.

To do so, you need to install pv.

On Ubuntu/Debian systems run:

On CentOS/Redhat systems run:

Install pv on Ubuntu.

To use pv with the dd command follow the syntax:

dd if=/path/to/input | pv | dd of=/path/to/output

After reading this article, you should know how to show progress while running the dd command, with or without the pv command.

Download a free copy of Linux Commands Cheat Sheet to help you with managing your instance of Linux.

Sofija Simic is an experienced Technical Writer. Alongside her educational background in teaching and writing, she has had a lifelong passion for information technology. She is committed to unscrambling confusing IT concepts and streamlining intricate software installations.

Setting file and directory permission properly is important in multi-user systems such as Linux. You can set.

If you want to keep your filesystems clean and without errors, you need to scan it on regular basis. In this.

Want to learn how to copy files in Linux OS? This guide will show you how to use the Linux commands to copy.

Tutorial on securely transferring files between Unix or Linux systems using the SCP command. The SCP or.

Источник

How to Show Progress Bar for dd Command in Linux

Show Progress Bar for dd Command in Linux1

dd command can be used to copy a file, converting and formatting according to the operands on Linux.

Linux pv Command

pv command can be used to monitor the progress of data through a pipe. pv allows a user to see the progress of data through a pipeline, by giving information such as time elapsed, percentage completed (with progress bar), current throughput rate, total data transferred, and ETA.

Show Progress of dd Command

If you want to show progress using dd command , and you need to use gnu dd command from coreutils version 8.24 or above, and then pass the status=progress option to dd command so that to dispaly the progress on your Linux system. the below is a example for dd command to show progress:

dd if=/dev/unrandom of=/dev/null status=progress
[root@localhost ~]# dd if=/dev/urandom of=/dev/null status=progress 1550493696 bytes (1.6 GB) copied, 13.000031 s, 119 MB/s

To check the version of coreutils on your Linux system, and you just need to issue the following command:

[root@localhost ~]# dd --version dd (coreutils) 8.24 Copyright (C) 2016 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Written by Paul Rubin, David MacKenzie, and Stuart Kemp.

If you are not able to install the latest version of coreutils package through your default repository of Linux system, and you can install it by compling source package of coreutils with the following command:

wget ftp://ftp.gnu.org/pub/gnu/coreutils/coreutils-8.24.tar.xz tar -xf coreutils-8.24.tar.xz cd coreutils-8.24 ./configure && make -j $(nproc)

Show Progress of dd or other Linux Command Using Pv

You can also use another tool named pv to monitor the progress of dd command and check its status. before using it, and you need to install it by using the following command, type:

Читайте также:  Linux users group permissions

For Ubuntu or Debian Linux:

For CentOS or Redhat Linux:

[root@localhost ~]# yum install pv Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * centos-sclo-rh: mirrors.aliyun.com * centos-sclo-sclo: mirrors.ustc.edu.cn * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Resolving Dependencies --> Running transaction check ---> Package pv.x86_64 0:1.4.6-1.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: pv x86_64 1.4.6-1.el7 epel 47 k Transaction Summary ================================================================================ Install 1 Package Total download size: 47 k Installed size: 93 k Is this ok [y/d/N]: y Downloading packages: pv-1.4.6-1.el7.x86_64.rpm | 47 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : pv-1.4.6-1.el7.x86_64 1/1 Verifying : pv-1.4.6-1.el7.x86_64 1/1 Installed: pv.x86_64 0:1.4.6-1.el7 Complete!

To show progress bar using pv command for dd command, and you need to put pv command between input and output only dd commands. Let’s see the below dd command example:

$ dd if=/dev/urandom | pv | dd of=/dev/null
[root@localhost ~]# dd if=/dev/urandom | pv | dd of=/dev/null 244MiB 0:00:03 [82.1MiB/s] [ ] Conclusion

You should know that how to use pv command to display progress bar while using dd command or other Linux commands on your Ubuntu or Debian Linux. If you want to see more detailed information about pv or dd command, you can use the following commands:

Источник

Оцените статью
Adblock
detector