Archive for April 2013

Realtime stats of dd

There are at least two ways of getting the progress of the dd command. One is sending the dd command the -USR1 kill signal, which will cause it to print out its current progress to stderr:

kill -USR1 `pidof dd`

The other way is to examine the fdinfo file (either 0 or 1) for the dd process under /proc to see how much data has currently been copied. This is more efficient and way faster than sending dd a signal as it’s pulling directly from /proc and instead of waiting for dd to catch the signal.

root@debian:~# printf '%0.3fGB\n' $(bc -l <<< "$(awk '{if ($1 ~ "pos") print $2}' /proc/`pidof dd`/fdinfo/0) / 1073741824") 15.310GB root@debian:~#

Run it in a loop for stats every few seconds:

while :; do clear; printf '%0.3fGB\n' $(bc -l <<< "$(awk '{if ($1 ~ "pos") print $2}' /proc/`pidof dd`/fdinfo/0) / 1073741824"); sleep 2; done

Drastically increase mkfs.ext4 speed

Every now and then, you might want to create an ext4 filesystem on a block device spanning several terabytes, and this is almost always a really long process, taking up to several hours or even days.

There is a little known trick that can significantly reduce the amount of time needed to create ext4 filesystems:

mkfs.ext4 -E lazy_itable_init=1

The lazy_itable_init flag is default on newer versions of e2fsprogs, and the above snippet works on systems as old as Centos5.