This Season
 

How to Clone a Hard Drive With Linux

How to Clone a Hard Drive With Linuxthumbnail
Clone a Hard Drive With Linux

Cloning a hard drive is a good way to create an "image," or snapshot of your current operating system as a back-up. It is also useful if you want to transfer the contents of your computer exactly as it is, complete with all your preferences, from an old drive to a new one.

Linux can do this with "dd" and "ddrescue," two free utilities. Gddrescue is newer, faster, easier to use and recommended for most users. Dd is a powerful and flexible, but slow and complicated program, and it's recommended only to tackle specific problems gddrescue can't handle.

Related Searches:
    Difficulty:
    Moderately Challenging

    Instructions

    Things You'll Need

    • Two hard drives
    • Live Linux CD, such as Knoppix or Ubuntu Live
    1. Preparation

      • 1

        Back up all your important data, in case anything goes wrong.

      • 2

        Detach any storage devices--including external drives, memory cards, cameras and memory cards--besides the drive you want to clone and the destination drive where you want to store the cloned image.

      • 3

        Boot your computer from the Linux live CD.

      • 4

        Learn the naming scheme for your computer's drives by opening a Linux terminal window and typing the following command:

        sudo fdisk -l

      • 5

        Take note of (and preferably write down) the information under the "Device" column. It will include a list of one or more items named /dev/sda1, /dev/sda2, /dev/sdb, and so forth. The letters (sda, sdb) indicate separate hard drives. The numbers (sda1, sda2) indicate separate partitions within each drive.

      Clone with Gddrescue

      • 1

        Using the information you obtained from the previous step, determine which is your source drive (which you are cloning from) and your destination drive (which you are cloning to).

        Some clues include the size of the respective drives and their partitions. For example: You are trying to clone a 60-gigabyte source drive onto a 120-gigabyte destination drive. If the previous step tells you /dev/sda has a 60-gigabyte capacity and /dev/sdb has a 120-gigabyte capacity, you can use their respective sizes to tell which is which. Another example: You are copying a three-partition source drive onto a blank destination drive. You see four rows labelled: /dev/sda1, /dev/sda2, /dev/sda3 and /dev/sdb. Next to them are numbers that correspond to each of your partitions and a blank field next to /dev/sdb. You can conclude that sda is your source drive and sdb is your destination drive.

      • 2

        Enable all repositories if you are using an Ubuntu live CD by opening the Software Source program, located under "System" and "Administration" on the top deskbar, then clicking the check boxes for the (universe) and (multiverse) repositories.

      • 3

        Open a Terminal, located under "Applications" and "Accessories," then download gddrescue by typing or copy-pasting in the following command: sudo apt-get install gddrescue

      • 4

        Type in the following command, substituting SOURCE with the name of your source drive and DESTINATION with the name of your destination drive: sudo ddrescue -v /dev/SOURCE /dev/DESTINATION

      Clone with Dd

      • 1

        Using the information you obtained from the previous step, determine which is your source drive (which you are cloning from) and your destination drive (which you are cloning to).

        Some clues include the size of the respective drives and their partitions. For example: You are trying to clone a 60-gigabyte source drive onto a 120-gigabyte destination drive. If the previous step tells you /dev/sda has a 60-gigabyte capacity and /dev/sdb has a 120-gigabyte capacity, you can use their respective sizes to tell which is which. Another example: You are copying a three-partition source drive onto a blank destination drive. You see four rows labelled: /dev/sda1, /dev/sda2, /dev/sda3 and /dev/sdb. Next to them are numbers that correspond to each of your partitions and a blank field next to /dev/sdb. You can conclude that sda is your source drive and sdb is your destination drive.

      • 2

        Open a terminal window.

      • 3

        Type in the following command, replacing SOURCE with the name of the source drive and DESTINATION with the name of your destination drive: dd bs=4k if=/dev/SOURCE of=/dev/DESTINATION conv=noerror,sync

        To clone only one partition from the source drive, specify the partition (e.g., /dev/sda1 or /dev/sda2). To clone the entire drive, specify only the drive name, with no partition number (e.g., /dev/sda).

      • 4

        Wait. Cloning a large drive using dd can take hours, and according to some accounts, even more than a day.

    Tips & Warnings

    • * This software, like any other software, is not foolproof. After the process is complete, test whether cloning took place properly by attempting to boot from your destination drive.

    • * Gddrescue is simpler and faster than dd. Use dd only when for custom cloning tasks gddrescue can't handle. See the links under resources for further information on when to use dd.

    • Giving dd or gddrescue the wrong source and destination drives can cause you to overwrite important data. Be sure to input the correct source and destination drives. Always back up your important data before attempting this process.

    Related Searches

    Resources

    • Photo Credit Jupiterimages/Brand X Pictures/Getty Images

    Read Next:

    Comments

    You May Also Like

    Follow eHow

    Related Ads