Earlier, we showed you how to create persistent Ubuntu Live media disk, and use it for resetting and changing Windows 7 administrator and standard user account password. Apart from tweaking with Windows registry hives, Ubuntu Live media disk can be used to create data backup, shrink partitions, clone hard disk, scan system for viruses, imaging disk partitions and more. Although disk imaging or hard disk cloning can be done using data backup and disk copying applications, malware-infected OS often make it hard to perform essential data backup operations. For instance, if a PC is infected with boot sector virus, disk cloning application doesn’t work unless you clean the system from virus and repair boot sector.
Ubuntu Live media disk lets you clone disks and create disk images, so that you can easily restore the data after performing low-level cleaning of the system. In this post, we will look at 2 simple ways for cloning and imaging disks using Ubuntu Live USB.
The first step is to change the system boot priority from BIOS menu. On system startup, press F2, F10, ESC, DEL, or other system defined key for accessing BIOS menu. Now, open Boot menu to set USB Hard disk/Removable Drive as first boost option. Once done, save the changes, plug-in Ubuntu Live USB, and the reboot the system. Once rebooted, it will take you to Ubuntu Live boot menu, select Run Ubuntu from this USB option to load Ubuntu OS.
Create Image of local disk partition to external hard drive
Once Ubuntu 10.10 is loaded, plug-in the external hard disk on which you want to create your primary hard disk image, and then mount the external hard disk from Places menu.
We will use Ubuntu dd command to create disk image. The command is widely used to perform low-level data copying and disk cloning operations. Using if (input file) and of (output file) operands, we can use dd to create an exact copy of specified disk in IMG format. To begin, click Applications and open Terminal from Accessories menu.
Now navigate to media disk using cd /media command. Open the external hard disk using the cd <disk label> command. You can use cd command to navigate to folder in external hard disk where image is to be created.
Since we need to create disk image to external drive, we will use sudo fdisk –l command to list down all the partitions of primary hard disk. This will help us identify the partition whose image is to be created on external hard disk. Once listed, note down the partition identifier under Device column, as it will be used to specify the hard disk partition with dd command to create a disk image.
The syntax for creating disk image is as follows:
sudo dd if=<disk partition identifier> of=./<name of disk image>
If you for instance want to create a disk image for /dev/sda5. Enter;
sudo dd if=/dev/sda5 of=./BackupDisk.img
The time it takes to create a disk image depends upon the size of specified disk partition.
Once the image is created, open external hard drive location in Nautilus (Ubuntu File Explorer) to verify the disk image size. Similarly, you can create disk images for other partitions of primary hard disk in external storage medium.
The dd command also lets you restore or extract the IMG file to specified location. The syntax of extracting IMG file is as follows.
sudo dd if=.<name of disk image file> of=<output location>
You can specify the local disk where data is to be extracted or specify the folder hierarchy where you want to copy the data from IMG file.
sudo dd if=./BackupDisk.img of=/dev/sda3
It must be noted that when you restore data from IMG file using dd command, it will wipe all the free space of target drive. The screenshot below shows the cloned D drive. To reclaim the free space, copy the data from cloned drive to other disk and then format the cloned drive using Windows built-in Format utility.
Clone Local Disk Using Ubuntu Live USB
The process of cloning disk is similar to creating disk image. All you need is to mount the primary hard disk and navigate to it in Terminal using cd <disk identifier> command.
Once mounted, use sudo fdisk –l to list down hard disk partitions, so that you can note down the Device identifiers of both disks including disk which is to be cloned and target disk where data is to be copied.
For instance, if you want to create a clone of /dev/sda5 in /dev/sda3. Enter following command
sudo dd if=/dev/sd5 of=/dev/sd3
It will take /dev/sd5 as input file (if operand) and clone disk at specified location (/dev/sd3).