Home >> Scripts

Optimizing scripts execution time

Writen on year 2010 in Scripts

 1.Make directory trees in a single command   tired of time consuming: ~ $ mkdir tmp ~ $ cd tmp ~/tmp $ mkdir a ~/tmp $ cd a ~/tmp/a $ mkdir b ~/tmp/a $ cd b ~/tmp/a/b/ $ mkdir c ~/tmp/a/b/ $ cd c ~/tmp/a/b/c $ use the -p option to mkdir  ~ $ mkdir -p tmp/a/b/c Or [...]

Back-up/Restore the MBR (Master Boot Record)

Writen on year 2010 in Scripts

Back-up dd if=/dev/hda of=backup-mbr count=1 bs=512 Restore full (including existing partition table) dd if=backup-mbr of=/dev/hda Restore MBR (not including partition table entry) dd of=/dev/hda if=backup-mbr bs=446 count=1

Cloning disk/partition over SSH

Writen on year 2010 in Scripts

Copying an 10GB disk should only take at most 15 minutes with a god internet connection. ssh server -c blowfish “dd if=/dev/hda0/snapshot” | dd of=/dev/hda0/target-disk bs=4096k conv=notrunc,noerror