Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

can I use the dd command to clone my ubuntu installation from my external disk to my local hard drive. will it even boot? I think I can, but not sure. do I need to make the output partition on my local disk the exact size as the input partition on the usb? I'm thinking install and boot off a liveusb on a different small flash drive and run something like sudo dd if=/media/usbexternaldisk of=/media/localdisk would that work as is?

also if I make an iso image of my external ubuntu installation using dd, can I burn it onto disk or unto another hard drive and have that boot up?

share|improve this question

1 Answer 1

up vote 6 down vote accepted

Using dd to clone an Ubuntu installation

Yes, you can use dd to clone an installation, but it's not the fastest/easiest way to do it. It's better to do it via backup/restore with a live-tool such as Clonezilla.

  • If you wish to use dd, note that the target disk must be the same size or larger than the source.
  • Also, to make it bootable, you must copy from device-to-device (e.g. /dev/sdX), NOT from partition to partition (/media/...)
  • Use sudo fdisk -l to find out which block devices your target internal hard disk (usually /dev/sda) and external USB hard disk (usually /dev/sdb) are.
  • Then use dd with exactly the following syntax, where x is the letter for the USB drive and y the letter for the internal drive which you have determined in the previous step:

    sudo dd if=/dev/sdx of=/dev/sdy bs=8M && sync
    

    and wait for it to complete.

  • To answer your other question, no, simply dd'ing to an ISO (or CD or DVD, etc.) will NOT work; it will be unbootable. For that, you need to use a tool such as remastersys. See this question for more information:

    How do I convert my Ubuntu installation into a Live-USB or Live-CD?

share|improve this answer
1  
dd is the fastest, it's low-level. Your second point is incorrect. You can copy from partition to partition via /dev/sd[X][N]... /media/... is not a partition, it's a mount pointing to a partition AKA /dev/sd[X][N] or for some people who work with virtual machines just /dev/sd[X]. –  Jordon Bedwell Sep 10 '12 at 12:46
    
@JordonBedwell: Can you copy from partition to partition? Yes. Will that result in a bootable clone? No. –  izx Sep 10 '12 at 12:53
2  
@JordonBedwell: Also, dd is not the fastest because it's low-level. It will copy every single bit, including free space, which smarter tools won't. –  izx Sep 10 '12 at 12:58
    
Nobody implied it would create a "bootable clone" so you are making a moot point, my goal was to help you better your answer by correcting the things that were wrong. Though if you you want to get technical... you neglect to mention that if he does your exact command from an internal disk to usb hd that it will make a bootable copy since it will copy the mbr too since you didn't add a count and you start from the beginning. –  Jordon Bedwell Sep 10 '12 at 12:59
2  
He never claimed it wouldn't directly copy partitions. a)it will copy partitions with /dev/sdXY format, b)it will NOT copy the boot sector when using that format(/dev/sdX would), c)it will, in all probability, NOT be boot-able (disk UUIDs would be different for one thing, there are more), d)dd is NOT faster than higher level tools unless the disk is mostly full, e)dd will hang if it fails to read due to a failing disk, f)I don't think you're helping anyone better understand anything. –  hbdgaf Sep 10 '12 at 13:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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