Using 'dd' to clone a USB drive

-cfdisk:

resized the destination partition to be of same size

made the partition bootable

same 'type' ext3

ran 'mkfs.ext3' after exit cfdisk

then

dd if=dev/sda1 of=/dev/sdb1

result booting: Missing operating system.

The source USB device boots on multiple laptops

USB destination filesystem looks the same....

Any idears?

link|improve this question
1  
Why are you gooing through all the effort to setup partitions and filesystems? Just copy the entire disk. dd if=/dev/sda of=/dev/sdb – Zoredache May 12 '10 at 21:16
You are probably right, but this is the result...the 2nd USB is slightly smaller in size dd if=/dev/sda of=/dev/sdb dd: writing to `/dev/sdb': No space left on device 15654849+0 records in 15654848+0 records out 8015282176 bytes (8.0 GB) copied, 3430.66 s, 2.3 MB/s – MentalBlister May 12 '10 at 23:47
feedback

3 Answers

You copied the partition, but not the MBR. Copy the first 440 bytes of the device itself.

link|improve this answer
Is this correct? dd if=/dev/sda of=/dev/sdb bs=512 count=1 – MentalBlister May 12 '10 at 22:25
No, that will wipe the partition table as well. And I'm not psychic, so I don't know if those are the correct devices. You're definitely on the right track though. – Ignacio Vazquez-Abrams May 12 '10 at 22:38
1  
Everything past byte 440 is unique to the drive and should not be copied. And I speak not only from experience... en.wikipedia.org/wiki/Master_boot_record – Ignacio Vazquez-Abrams May 12 '10 at 23:44
1  
As the story goes....did dd if=/dev/sda of=/dev/sdb bs=512 count=1, tried booting from it...All I got was 'GRUB' So then tried example from first comment of Zoredache above: result --> cfdisk /dev/sdb "FATAL ERROR Bad primary partition 1: Partition ends after end-of-disk Press any key to exit cfdisk back to my Pretty good friend Google. – MentalBlister May 12 '10 at 23:54
1  
'should not' be copied? you're cloning the thumb drive, i've done similar things in the past, and granted it's been a long time, but i don't seem to remember any issues of two thumb drives sharing the same MBR, bit for bit. MentalBlister: DROP THE count=1 you're only copying the first 512 bytes with count=1 get rid of the count parameter completely. – cpbills May 13 '10 at 0:38
show 3 more comments
feedback

If the drives are the same size, why not just clone the entire drive?

dd if=/dev/sda of=/dev/sdb bs=(whatever) count=(whatever)

I've used this to clone HP ThinState configuration disks for HP thin clients that "don't work" with devices over 2GB - so long as I have a small enough drive to use as a master, I can clone it onto e.g. a 4GB drive and the thin client will happily boot from it.

Edit: Reading the above on "unique" IDs in/near the MBR, I don't see a problem with cloning an identical device if it's truly a clone - as long as you don't try to copy things between the two.

link|improve this answer
The devices are not the same, though they are supposed to be the same size 8 GB. – MentalBlister May 13 '10 at 3:34
Use the smaller of the two as the master and the unfilled space won't matter. Using the larger of the two as the master... could have problems. – Andrew May 17 '10 at 2:46
feedback

You can use sfdisk to backup the partition table, then copy th boot sector (first block). Then restore the partition table with sfdisk. If you are using a DOS MBR, then the mbr program will write the MBR code onto the USB for you.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.