lunedì 29 dicembre 2014

Clone MBR and GPT with DD (and monitor the process).

I recently had to clone a 8 GB USB GPT formatted content to a 32 GB...

And thanks to the amazing "dd" Unix command, this was easier than I thought.
Basically the structure of my USB was something like this:
-GUID partitioning scheme
-BIOS boot partition 1 Mb
-Linux file system 7400 Mb
-EFI boot partition 300 Mb

What I've done:

dd if=/dev/disk8gb of=/dev/disk32gb bs=8192 conv=notrunc,noerror

You might know:
if=input file, the disk to be copied
of=output file, the disk to be copied to
bs=block size, in this case, 8192 gave me copying 8 GB in less than an hour and a half, without any problem.

But the problem is: the two disks aren't of the same size, and the GPT partitioning scheme need to know how big is the USB. I initially thought of using gdisk to fix things, but it turns out that the solution was actually pretty simple: the 32 GB USB was recognized as a 8 GB one, and the rest of the space... it was like having a gigantic empty space, or at least full of random data and stuff, like the difference between Earth (8 GB recognized) and Outer Space (24 GB unrecognized)... pretty deep thoughts after all, but how to fix this?
If you are either cloning a bigger disk to a smaller one or in this case vice versa, you should follow this guide to fix the partitioning scheme:

And finally, you can monitor the dd process like this:
-If you are using a Mac, press CTRL+T during the process to monitor the process (temporary kill the process).
-Use pipe viewer:
-Use the iostat command to watch in real time the input process (run dd and iostat at the same time so that the output of iostat corresponds to the bytes copied with dd) like this:
iostat -Iw 5 diskpointer
to have an update every 5 seconds (resource:

Nessun commento:

Posta un commento