# dd, does it work to duplicate  freesbie on thumbdrive to another thumbdrive?



## vaclinux (Apr 15, 2009)

Dear guys,
I have freesbie that run well on a 2G thumbdrive, and i really want to have other thumbdrive to have a same thing as well, "freesbie liveOnUSB"?
My question is does "dd" command, can help to duplicate it ,?

```
dd if=/dev/da0s1 of=/dev/da1s1 bs=512,
```
and it doesnt work, seems dd copy the whole byte from  the thumbdrive(freesbie run on it).

I think i need to add another option in dd, to limit number of byte being copied, but i am not sure how it works.?
Any idea,

Thanks


----------



## graudeejs (Apr 15, 2009)

It'd probably doesn't work, because new thumbdrive isn't marked bootable and/or doesn't have mbr written

dd if=/boot/mbr of=/dev/ad1s1
should fix mbr (i think),but i'm not sure about bootable flag

you cad add bootable flag wit fdisk, but i don't know how to use it


----------



## Carpetsmoker (Apr 15, 2009)

You can just copy the MBR from the old drive if that one works:

`# dd if=/dev/da0 of=/dev/da1 bs=512 count=1`

Please make sure your drive actually has an MBR, many don't because Windows doesn't support it...



> dd if=/boot/mbr of=/dev/ad1s1
> should fix mbr (i think),but i'm not sure about bootable flag



boot0cfg(8) is a better way.
You can mark partitions as active with fdisk(8).


----------



## vaclinux (Apr 15, 2009)

Thanks, for the suggestions.
I will try to them later,
Thanks again.


----------



## fronclynne (Apr 15, 2009)

*I mean, obviously?  Is that what I think?*



			
				vaclinux said:
			
		

> ```
> dd if=/dev/da0s1 of=/dev/da1s1 bs=512,
> ```
> and it doesnt work, seems dd copy the whole byte from  the thumbdrive(freesbie run on it).


You are copying the first slice, which starts after the mbr. 

You meant to issue

```
# dd if=/dev/da0 of=/dev/da1 bs=512
```
Which will copy the entire contents of the drive, including the mbr and the slice table.

You could obviously create the slice table and write the bootcode seperately and then do your version above as well.


----------



## Carpetsmoker (Apr 15, 2009)

You don't need to redo everything, you can just use:
`#  dd if=/dev/da0 of=/dev/da1 bs=512 count=1`
To copy the MBR.

Also, a block size if 512 bytes will be slow, I'm not sure what the best size for USB drives is, but for hard disks a bs about the same as the buffer is *much* faster.
Try 16M, this will probably be a lot faster.


----------



## phoenix (Apr 15, 2009)

The block size depends on the flash stick.  Some use 2K, others 4K, some larger.  But using anything over 512 bytes will be faster than using 512 B.  

Someone did a "benchmark" using dd with various block sizes against various flash sticks and posted the results.  But now I can't find the results.  I'm sure it was on one of the @freebsd mailing lists.


----------



## Beastie (Apr 16, 2009)

Carpetsmoker said:
			
		

> Try 16M, this will probably be a lot faster.


Do you really mean 16*M*B... or 16*K*B?


----------

