The title might be a bit confusing, so in detail: What I have done is clone a small 32GB flash module that had three partitions. I happened to have a 32GB USB lying around, so I thought it might just work; it did not. It seems 32GB from Toshiba is a bit different than 32GB from Sandisk. Anyway, so then took to a 2TB external drive and did the exact same thing. Specifically, I did the following: dd if=/dev/sdX of=/dev/sdY bs=100Maside Does the final block come across as a partial copy or is it dropped if EOF is reached first?So as to essentially clone the entire flash module -- partition table and all. The 32GB -> 2TB was easy enough since the dd utility properly halted after reading through the end of the final (third) partition. So, what I want to do now is just create a simple binary blob containing the entire flash image. My 2TB drive is now identically partitioned with respect to the original drive: sdx1, sdx2, sdx3. So, once again I just took to dd with the following:dd if=/dev/sdx of=firmware.bin bs=100MDoing so will not only copy the first 32GB I am interested in, but it will also continue on through and clone the entire 2TB drive, or so it did when I tried it. I can find the exact byte-length of the partitions of interest by the following:$ lsblk -bNAME                         MAJ:MIN RM          SIZE RO TYPE  MOUNTPOINTsdc                            8:32   0 2000398933504  0 disk  sdc1                         8:33   0     134217728  0 part  sdc2                         8:34   0    2147483648  0 part  sdc3                         8:35   0   29734297600  0 part  A definite way to solve this would be to set the blocksize of dd to one byte and then set the number of blocks to read as the sum of the three sizes above:dd if=/dev/sdc of=firmware.bin bs=1 count=32015998976But I can't image how long that would actually take. EDIT: A quick test of curiosity of the above showed a solid ~150KB/s transfer rate. tl;dr How can I exclusively copy the first three partitions of a disk that is much larger than the sum of the partition sizes?
How to clone an entire disk to a larger disk and then offload?
dd;file copy;cloning;disk image
Just copy the partitions that you need and the MBR if you need it too.The MBR is stored in the the first 512 bytes of the disk.dd if=/dev/sdX of=/path/to/mbr_file.img bs=512 count=1Copy each partitiondd if=/dev/sdX1 of=/path/to/partition1.img bs=512dd if=/dev/sdX2 of=/path/to/partition2.img bs=512dd if=/dev/sdX3 of=/path/to/partition3.img bs=512