Ubuntu – How to use dd to clone an external USB drive installation to a local hard disk

ddexternal-hddhard drive

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?

Best Answer

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?