← Alle Beiträge
Linux 2015-01-27 15:12 Autor: Stefan 2 Min. Lesezeit

Code Snippet für ddcode snippet for dd

Heute mal wieder ein kleines Stück Code für die Konsole.

Da ich ja und vermutlich auch Ihr öfter mal dd nutzt für das Schreiben eines neuen Images auf SD Karte oder mal ein Backup damit erstellt , kann es ziemlich nervig sein wenn man nicht weiß wie lange es noch dauert.

Als erstes brauch man noch einen kleinen Zusatz : pv

apt-get install pv

Anschließen wird die .bashrc bearbeitet

nano .bashrc

dd() { local dd=$(which dd); [ "$dd" ] || { echo "'dd' is not installed!" >&2 return 1 }

local pv=$(which pv); [ "$pv" ] || { echo "'pv' is not installed!" >&2 "$dd" "$@" return $? }

local arg arg2 infile local -a args for arg in "$@" do arg2=${arg#if=} if [ "$arg2" != "$arg" ] then infile=$arg2 else args[${#args[@]}]=$arg fi done

"$pv" -tpreb "$infile" | "$dd" "${args[@]}" }

Dies dann einfügen und schon gibt es einen schönen Ladebalken. Da dd meist nur unter root läuft muss/sollte man es dort auch in die .bashrc eintragen.

Gefunden irgendwann einmal auf stackexchange.com

 

Today i have an little piece of code

I think , i'm not the only one who burn images on sd card from time to time, but it is strange no to know how long it takes to burn in.

First ok all you need a little extra tool : pv

apt-get install pv

Now copy & paste this code to .bashrc

nano .bashrc

dd() { local dd=$(which dd); [ "$dd" ] || { echo "'dd' is not installed!" >&2 return 1 }

local pv=$(which pv); [ "$pv" ] || { echo "'pv' is not installed!" >&2 "$dd" "$@" return $? }

local arg arg2 infile local -a args for arg in "$@" do arg2=${arg#if=} if [ "$arg2" != "$arg" ] then infile=$arg2 else args[${#args[@]}]=$arg fi done

"$pv" -tpreb "$infile" | "$dd" "${args[@]}" }

Most time dd works only for root , so you have to put the same code in /root/.bashrc too

Found this code somewhere on stackexchange.com

Kommentare (0)

Moderiert & spamgeprüft

Noch keine freigegebenen Kommentare vorhanden. Schreibe gerne den ersten Kommentar!

Kommentar schreiben

Hinweis: Dein Kommentar wird vor der Veröffentlichung auf Echtheit geprüft und von einem Moderator freigeschaltet.