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?


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 or gparted 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?

  • 2
    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
  • 4
    @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. – ish Sep 10 '12 at 12:58
  • 2
    With all due respect, your nit-picking is off-topic since the question clearly involves making a bootable clone, and that is the goal my answer aims to achieve. We are not discussing the general usage or merits of dd when copying arbitrary data. – ish Sep 10 '12 at 13:01
  • 1
    Please add your own answer (or feel free edit mine). This discussion is unproductive. – ish Sep 10 '12 at 13:14
  • 5
    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. – RobotHumans Sep 10 '12 at 13:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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