1
00:00:00,000 --> 00:00:15,080
Another amazing utility is DD. DD is what you use to clone devices or parts of devices.

2
00:00:15,080 --> 00:00:20,559
So DD was developed to move blocks between devices. And using DD makes it possible to

3
00:00:20,559 --> 00:00:26,559
make an ISO of an optical disk or to clone a complete hard disk. It's not a utility for

4
00:00:26,559 --> 00:00:32,279
copying individual files or for making archives of files. But if you want to directly work

5
00:00:32,279 --> 00:00:40,400
with block devices, it is an extremely cool utility. Let me show you. So the first command

6
00:00:40,400 --> 00:00:50,639
is DD. IF is dev SDA. OF is dev null. BS is 1M, which is going to do what? Well, it's kind

7
00:00:50,639 --> 00:00:57,279
of useless. It's cloning the entire SDA device to the dev null device. The reason I'm showing

8
00:00:57,279 --> 00:01:06,360
you is that I rather don't show you this. DD. IF is dev 0. OF is dev SDA. Don't do it.

9
00:01:06,360 --> 00:01:11,279
Don't press enter. Because if you press enter and you do have an SDA device, it will be

10
00:01:11,279 --> 00:01:19,959
wiped. Dev 0 is the device that generates 0s. And dev SDA, well, LSB OKs are revealing that

11
00:01:19,959 --> 00:01:25,720
on this system, dev SDA is my primary hard disk. It is a very efficient way to wipe your

12
00:01:25,720 --> 00:01:31,040
entire hard disk, though. Now, if you want to clone your device, that is actually kind

13
00:01:31,040 --> 00:01:42,559
of cool. You can use DD. IF is dev SDA. OF is dev SDB. I would advise use a BS is 1M.

14
00:01:42,559 --> 00:01:48,320
Because DD by default will stream data. And that means that it will copy byte by byte.

15
00:01:48,440 --> 00:01:54,760
That's not very efficient. If you use it this way with the IF is dev SDA and OF is dev SDB

16
00:01:54,760 --> 00:02:01,839
and a BS is 1M, you tell it to use a one megabyte block size. And once it is done, SDB will

17
00:02:01,839 --> 00:02:07,400
be an identical copy of SDA. And that is useful if it's a physical hard drive that next you

18
00:02:07,400 --> 00:02:16,919
want to connect to another computer. I also like DD. IF is dev SDA. OF is slash boot slash

19
00:02:16,960 --> 00:02:27,839
MBR backup. BS is 512 and count is 1. Now, what is so cool about it? Well, what is so cool

20
00:02:27,839 --> 00:02:34,880
about it is that I just made a clone of the first 512 bytes of my SDA disk. That's my master

21
00:02:34,880 --> 00:02:43,160
boot record. And hey, if I show you XXD, which is a hexadecimal viewer, minus L512 on dev SDA,

22
00:02:43,479 --> 00:02:49,240
here you can see the master boot records. And I know it's pretty unreadable. But believe me,

23
00:02:49,279 --> 00:02:56,119
the stuff that you see right here is your partition table. So yeah, what is going to happen

24
00:02:56,119 --> 00:03:10,440
if I use DD? IF is dev 0, OF is dev SDA, BS is 512 and count is 1. Then, oops, I just copied

25
00:03:10,440 --> 00:03:18,199
zeros into the master boot records. But fortunately, we can easily recover using DD. IF is

26
00:03:19,119 --> 00:03:30,440
MBR backup. What was the name again that I created? Slash boot slash MBR backup. So DD. IF is

27
00:03:31,039 --> 00:03:44,080
slash boot slash MBR backup. OF is dev SDA. And that should recover access to my hard disk, as

28
00:03:44,080 --> 00:03:51,919
we can see, by using XXD right now. Now, you might feel that DD is kind of a dangerous utility.

29
00:03:51,919 --> 00:03:58,839
And that is absolutely true. But it's also a very powerful utility in combination with a utility

30
00:03:58,839 --> 00:04:06,360
like XXD or hexdump, which are hexadecimal viewers. It allows you to perform chirurgical

31
00:04:06,399 --> 00:04:12,639
operations on data blocks on your hard disk. And for troubleshooting, that can be so nice.

