- Sartar is useful.
Rsync is cool, but dd is really awesome.
Let me tell you about dd,
which is really one of the most powerful utilities on Linux.
Dd was developed to work with complete devices
so you can use it to clone devices,
and using dd makes it possible
to make an ISO of an optical disk
or to clone a complete hard disk.
Never use dd for copying files or making archives of files.
That's what Rsync and TAR are for.
But dd is for the most powerful of all things.
Let me demonstrate.
But before demonstrating, let me warn you.
Things might go wrong.
If things do go wrong, you lose everything.
So only do this on an isolated system
where it doesn't matter if you lose everything.
So I'm going to open a root cell,
and before doing anything I'm going to use dd,
IF is dev SDA.
OF is slash boot slash MBR backup.
BS is 512,
and count is one.
You know what?
Let's make this compatible to GPT systems
and make a backup of first megabyte.
So what did I just do?
Well, I made a backup of the critical data that is required
while booting your disk.
Good. LSBLK is showing that we have an SDB device.
SDA is 20 gigabytes, SDB is 20 gigabytes.
And you know,
that means that we can use dd IF is dev SDA,
OF is dev SDB.
Then very important, BS is 1M
because by default, dd will stream byte by byte.
And that's extremely slow.
If you use BS is 1M, that's block size is one megabyte
then it is using one megabyte blocks,
and that's a lot faster.
You will see that the entire SDA is clung to SDB
within a minute or so.
There we go. We have our perfect clone.
Let's do LSBLK again.
And LSBLK is indeed showing
that SDB is SDB1, SDB2, SDB3.
Now before continuing I want to verify XXD on dev SDA.
XXD is a cool hexadecimal viewer,
and oops, if you just run it like that
it's going to do a hex dump of your complete SDA device.
I don't wanna do that.
I want to dump it through the less utility.
And this is what I wanted to see.
This is the master boot record,
and this is what I should have on my SDA,
but also on my SDB.
And there you can, you go, and okay,
we cannot do a byte comparison, but they're identical.
We just dd them.
And that means that we now can do awesome stuff
like dd IF is slash dev slash zero.
OF is slash dev slash SDA. BS is 1M, and count is 50.
Oh my goodness, what did I just do?
Well, dev zero is the device that generates zeros,
and I use that as input fell,
and I wrote 50 megabytes of that to SDA.
So if at this point we do XXD on dev SDA,
it feels pretty lonely in there.
Nothing but zeros.
That's exactly what I just did.
But fortunately we have this clone on SDB
so it's easy to revert.
Dd, IF is dev SDB. OF is dev SDA.
BS is 1M, and count is 51.
Okay, that's all reasonable.
You can do 50 as well, but I like doing 51.
It's just the overlap that makes me feel more comfortable.
And now you can see that the master boot record
on SDA is restored.
So that means at this point you can reboot,
and everything is still working all right.
There's one more thing that I would like to show you,
and that is dd, IF is dev SR0.
OF is slash my CD dot ISO, and BS is 1M.
You can probably guess what that is doing.
Oh boy.
If at least media is inserted. Let me go fix that.
Now I have connected to the CD-ROM device, and there we go.
Dd is making an ISO out of it.
And that is how you can easily use
this very powerful dd utility on Linux.