Ubuntu – Use DD to clone only Linux partition to external USB drive

dddual-boothard drivepartitioning

I have a 1 TB internal drive that has two 1/2 TB partitions, one for Windows and the other for Ubuntu 14.04 LTS. The station has become primarily a Linux station and I never boot into Windows anymore.

I wanted to create an image backup so I used DD to clone the internal drive to an external 1 TB USB drive. Unfortunately the USB drive appears to be just a few Gigabytes shy of the internal drive and DD ended with a "Not enough space on drive" error message. Now I am seeing something odd. When I ejected the USB drive and plugged it back in, I see two 1/2 GB partitions that appear to be duplicates. They have identical GUID's and Nautilus shows identical directory structures and content. I'm guessing that something about the incomplete copy of one of the partitions has left the external drive in a broken state.

How can I use DD to just clone the Linux partition to the external drive? That's all I really want.

Best Answer

As first you need to find out data about your HDD, you can do this by typing in terminal:

sudo fdisk -l

You should get an output like this:

Disk /dev/sda: 149,1 GiB, 160041885696 bytes, 312581808 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x06bd4abe

Device     Boot     Start       End   Sectors   Size Id Type
/dev/sda1  *         2048 230055935 230053888 109,7G 83 Linux
/dev/sda2       292970494 312580095  19609602   9,4G  5 Extended
/dev/sda3       230055936 292968447  62912512    30G 83 Linux
/dev/sda5       292970496 312580095  19609600   9,4G 82 Linux swap / Solaris

Partition table entries are not in disk order.

So lets say /dev/sda3 is the drive you want to clone, then you can do:

dd bs=512 if=/dev/sda of=/dev/sdb1/partition.ddfile seek=230055936 count=$(expr 292968447 - 230055936)

Remind this here are only examples you would need to fit that to your situation.