1 00:00:00,000 --> 00:00:15,100 Another amazing utility is DD. DD is what you use to clone devices or parts of devices. 2 00:00:15,100 --> 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,439 is DD. IF is dev SDA. OF is dev null. BS is 1M, which is going to do what? Well, it's 7 00:00:50,439 --> 00:00:56,639 kind of useless. It's cloning the entire SDA device to the dev null device. The reason 8 00:00:56,639 --> 00:01:05,519 I'm showing you is that I rather don't show you this. DD. IF is dev 0. OF is dev SDA. 9 00:01:05,519 --> 00:01:10,720 Don't do it. Don't press enter. Because if you press enter and you do have an SDA device, 10 00:01:10,720 --> 00:01:19,480 it will be wiped. Dev 0 is the device that generates 0s. And dev SDA, well, LSB OKs revealing 11 00:01:19,480 --> 00:01:25,559 that on this system, dev SDA is my primary hard disk. It is a very efficient way to wipe 12 00:01:25,559 --> 00:01:30,720 your entire hard disk, though. Now, if you want to clone your device, that is actually 13 00:01:30,720 --> 00:01:42,519 kind of cool. You can use DD. IF is dev SDA. OF is dev SDB. I would advise use BS is 1M. 14 00:01:42,519 --> 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 1 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,919 --> 00:02:27,479 MBR backup. BS is 512 and count is 1. Now, what is so cool about it? Well, what is so 20 00:02:27,479 --> 00:02:34,320 cool about it is that I just made a clone of the first 512 bytes of my SDA disk. That's 21 00:02:34,320 --> 00:02:40,520 my master boot record. And hey, if I show you XXD, which is the hexadecimal viewer minus 22 00:02:40,520 --> 00:02:48,000 L512 on dev SDA, here you can see the master boot record. And I know it's pretty unreadable, 23 00:02:48,080 --> 00:02:55,240 but believe me, the stuff that you see right here is your partition table. So yeah, what 24 00:02:55,240 --> 00:03:07,520 is going to happen if I use DD? IF is dev 0, OF is dev SDA, BS is 512 and count is 1. 25 00:03:08,240 --> 00:03:15,520 Then, oops, I just copied zeros into the master boot record. But fortunately, we can easily 26 00:03:15,520 --> 00:03:28,279 recover using DD. IF is MBR backup. What was the name again that I created? Slash boot slash MBR 27 00:03:28,279 --> 00:03:42,759 backup. So DD. IF is slash boot slash MBR backup. OF is dev SDA. And that should recover access to 28 00:03:42,759 --> 00:03:50,759 my hard disk, as we can see by using XXD right now. Now, you might feel that DD is kind of a 29 00:03:50,759 --> 00:03:56,440 dangerous utility. And that is absolutely true. But it's also a very powerful utility and 30 00:03:56,440 --> 00:04:04,839 combination with a utility like XXD or hexdump, which are hexadecimal viewers, it allows you to 31 00:04:04,839 --> 00:04:11,679 perform chirurgical operations on data blocks on your hard disk. And for troubleshooting, that can 32 00:04:11,679 --> 00:04:12,679 be so nice.