EvilZone

Hacking and Security => Tutorials => : proxx November 17, 2014, 05:30:01 PM

: [Tutorial] Linux imaging/dd
: proxx November 17, 2014, 05:30:01 PM
Hello Evilzone.

Just some quick stuff on dd.
I recently did a lot with dd because I had to make a shitton of clones.

Simple image of an entire drive:
:
dd if=/dev/sda > myimage.img
Simple restore of an entire drive:
:
cat myimage.img | dd  of=/dev/sdaRidiculously easy and it just works.
We can improve this a bit by using some compression since it will drop an image the same size as the disk even if there is no data present, thats a lot of wasted space.
And the fact ofcourse that there is less data to write with a CPU cycle tradeoff.

Let do the same thing with gzip:
:
dd if=/dev/sda | gzip -c > myimage.imgAnd a restore:
:
gunzip -c myimage.img | dd of=/dev/sda
Direct disk to disk copy:
:
dd if=dev/sda of=/dev/sdb
I left out stuff about blocksizes to keep the examples clear.
For normal old fashioned HDD's you can just use a blocksize of 512 bytes.
The newer generation of HDD's with a blocksize of 4k (emulated or true) can use a BS of 4096, should not be used otherwise.
In some cases reads can be improved when a higher bs is used.
I wont go too deep into this for now, maybe add more later.
More stuff on blocksizes: http://en.wikipedia.org/wiki/Dd_%28Unix%29


I will append to this later since I thought I had more time to write this.
Main focus is the mere simplicity.
And remember kids, DD can ruin your day :)




: Re: [Tutorial] Linux imaging/dd
: flowjob November 17, 2014, 09:25:46 PM
Simple restore of an entire drive:
:
cat myimage.img | of=/dev/sda

You forgot "dd" there.
:
cat myimage.img | dd of=/dev/sda
And I like the idea of compressing the data stream on the fly, never thought of that.. +1