Author Topic: [Tutorial] Linux imaging/dd  (Read 1055 times)

0 Members and 2 Guests are viewing this topic.

Offline proxx

  • Avatarception
  • Global Moderator
  • Titan
  • *
  • Posts: 2803
  • Cookies: 256
  • ФФФ
    • View Profile
[Tutorial] Linux imaging/dd
« on: 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:
Code: [Select]
dd if=/dev/sda > myimage.img
Simple restore of an entire drive:
Code: [Select]
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:
Code: [Select]
dd if=/dev/sda | gzip -c > myimage.imgAnd a restore:
Code: [Select]
gunzip -c myimage.img | dd of=/dev/sda
Direct disk to disk copy:
Code: [Select]
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 :)




« Last Edit: November 18, 2014, 05:20:41 am by proxx »
Wtf where you thinking with that signature? - Phage.
This was another little experiment *evillaughter - Proxx.
Evilception... - Phage

Offline flowjob

  • Knight
  • **
  • Posts: 327
  • Cookies: 46
  • Pastafarian
    • View Profile
Re: [Tutorial] Linux imaging/dd
« Reply #1 on: November 17, 2014, 09:25:46 pm »
Simple restore of an entire drive:
Code: [Select]
cat myimage.img | of=/dev/sda

You forgot "dd" there.
Code: [Select]
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
Quote
<phil> I'm gonna DDOS the washing machine with clothes packets.
<deviant_sheep> dont use too much soap or youll cause a bubble overflow