Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a completely configured Linux system installed on a 16GB USB drive. I have the same brand/type of USB drive 10 times and the exact same mainboard 10 times.

Now I want to copy the USB drive to the others so I can have 10 systems use the same image.

What I did was create an image of the USB drive using WinDiskImager32 and then I tried writing it back to the original USB drive. That worked because it's the same drive but as soon as I tried to write it to the other USB drives it failed because the image was too big for those drives. Even though they are all 16GB, in reality of course there are always minor differences.

Obviously this is not the correct way of doing this, so I'm wondering how do I correctly "clone" my original USB so that I can deploy it on the others?

(Note, the system is configured to deal with the fact that it's installed on a new computer, so that's not an issue here, just need to get an exact copy)


Based on WesleyDavid's answer I check the drive with gparted and remebered that I originally copied the image from a 8GB device using WinDiskImager32 so the partition is already small enough.


The problem is that WindDiskImager copies the entire drive, not just the partitions.

Now the 'dd' solution fixes that by only copying a partition but then how do I get both the ext2 and swap filesystem on the target usb?

Using dd to copy the entire device results in the full 16GB again which won't always fit on the other devices

Update 2

Using dd as sugested by WesleyDavid works,
just had to use the count parameter of dd, as described here

Basically it means running "fdisk -u -l /dev/sdb" (replace sdb with your device)

> Disk /dev/sdb: 16.3 GB, 16257318912 bytes 64 heads, 32 sectors/track,
> 15504 cylinders, total 31752576 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 Disk identifier:
> 0x000392d4
>    Device Boot      Start         End      Blocks   Id  System
> /dev/sdb1   *        2048    13672447     6835200   83  Linux
> /dev/sdb2        13674494    15818751     1072129    5  Extended
> /dev/sdb5        13674496    15818751     1072128   82  Linux swap

In my case the end of the last partition is at '15818751' so I used:

dd if=/dev/sdb of=/home/myusername/usbimage.img count=15818752

adding one more just to be safe. That gave me an image that I can install.

share|improve this question
dd can copy an entire device, not just a partition. – Wesley Nov 9 '12 at 3:11
E.g. dd if=/dev/sda of=/dev/sdb and that gets every partition and even the MBR. Everything from stem to stern. – Wesley Nov 9 '12 at 3:13
But that results in the image being the full 16GB again (it included the unallocated space) – TimothyP Nov 9 '12 at 3:33
up vote 2 down vote accepted

Easiest option that is tried and true: use gparted to make your source partitions 15GB just to be sure. Then clone to the other USB drives.

In essence, this is not a cloning issue, this is a partition sizing issue. Once the partition / disk size is below the maximum size by a comfortable about, just dd if=source of=destination (assuming Windows) and rock on with your bad self.

share|improve this answer
I'll see if I can do that will come back to check the answer if it works – TimothyP Nov 9 '12 at 2:26
I've updated the question as I now understand how to copy a partition using dd, but what about the swap? – TimothyP Nov 9 '12 at 2:56
If you set the root device /dev/sdb it should copy everything on it, I believe – Journeyman Geek Nov 9 '12 at 2:59
Trying that now, I'm just hoping it doesn't copy all the device sectors but only the partitions (because windiskimager was copying everything) – TimothyP Nov 9 '12 at 3:17
It seems to be copying the entire disk including the unallocated space... – TimothyP Nov 9 '12 at 3:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .