How to extract img disk image from zip file, write to disk and show detailed progress?

170 Views Asked by At

How to show detailed progress and write disk image directly from zip file? See following tutorial

1

There are 1 best solutions below

0
On

Everyone knows that dd command does not show progress very well. Here is guide how to show detailed progress with pv and write image directly from zip file:

This method will show you the progress of writing the unzipped contents to a disk. We'll use a generic name file.zip for the zip file.

Bash Shell:

Install pv: pv (Pipe Viewer) is a tool for monitoring the progress of data through a pipeline.

sudo apt-get install pv

Check the Unzipped Size: Find out the size of the unzipped content.

unzip -l file.zip

Write to Disk:

Now, pipe the unzipped content to dd with a progress indicator.

unzip -p file.zip | pv -s $(unzip -l file.zip | awk '{print $1}' | tail -n 1) | sudo dd of=/dev/mmcblk0 bs=4M

Fish Shell:

Install pv:

sudo apt-get install pv

Check the Unzipped Size:

unzip -l file.zip

Write to Disk: In Fish shell, command substitution is done with parentheses ().

unzip -p file.zip | pv -s (unzip -l file.zip | awk '{print $1}' | tail -n 1) | sudo dd of=/dev/mmcblk0 bs=4M

In these commands:

unzip -p file.zip unzips the file and outputs the content to stdout. pv -s SIZE shows the progress. We obtain SIZE by running unzip -l file.zip which lists the contents of the zip file and then use awk and tail to extract the size of the unzipped content. sudo dd of=/dev/mmcblk0 bs=4M writes the unzipped content to the disk /dev/mmcblk0 with a block size of 4M. Make sure to replace /dev/mmcblk0 with the actual path to your disk and adjust the block size bs accordingly if necessary.