Saturday, February 16, 2019
Home > Technology > Clone Your Linux Hard Drive by 4 Methods.

Clone Your Linux Hard Drive by 4 Methods.

alt

Just because you’re running a Linux operating system doesn’t mean that you won’t run into problems from time to time. It’s always good to have a backup plan, just in case a problem strikes. Perhaps a rare Linux virus will attack; perhaps you’ll be targeted by ransomware scammers.

Your Linux installation might develop a bug; you could be upgrading your hard disk drive to a larger volume. Or your HDD might simply fail. Whatever the problem, if you have a backup of your Linux installation — or even the entire disk — then getting things back up and running again will be relatively simple.

Whether you use functions that are built into your Linux operating system, or you install a third-party tool, it shouldn’t be long before you’re able to get your system back up and running.

1. dd, The Native Linux Cloning Tool

Perhaps the most powerful Linux tool of them all, dd (sometimes referred to as “disk destroyer”) can clone an entire HDD or disk partition to another. But if misused, it can delete the contents of your disk.

As such, you should use with extreme care. You’ll find dd built into most Linux operating systems. If not, install it from the package manager. To clone your computer’s hard disk, use the command:

dd if=/dev/sdX of=/dev/sdY bs=64K conv=noerror,sync

Here, sdX is the source disk, while sdY is the destination. The numerical value 64K, corresponds to the block size command, bs. The default value is 512 bytes, which is very small, so it’s best to include 64K or the larger 128K as a condition. However: while a larger block size makes transfer quicker, a smaller block size makes the transfer more reliable.

If you only want to clone a partition of your drive, use

dd if=/dev/sda1 of=/dev/sdb1 bs=64K conv=noerror,sync

As you can see, the partition sda1 (that is, partition 1 on device sda) will be cloned to sdb1 (a newly created partition 1 on device sdb), for instance a secondary, or external, HDD attached to your computer.

Tap Enter to run the command. How long it takes will depend on the size of the disk or partition. Just make sure that destination volume is large enough to store it!

2. Partimage, Partition Backup Tool

If you have run into problems trying to get your head around the instructions with dd, or would prefer to avoid accidentally deleting your HDD with typo, partimage is also available for most distros, and doesn’t carry any “disk destroyer” risks!

alt

However, partimage does not support the ext4 filesystem, so avoid using it for cloning disks or partitions of that type. However, if necessary, it can be used to clone Windows disk formats (FAT32 or NTFS, although this is experimental) as well as the more widely used Linux filesystem ext3, and other, older alternatives.

Before starting, ensure that the partition you wish to clone us unmounted (with the umount command). Otherwise you’ll need to exit partimage to do so before continuing with the process. You can exit at any time with the F6 key.

For Ubuntu, install with

sudo apt-get install partimage

You should then launch from the command line with

sudo partimage

This is a mouse-driven application, which requires you to first select the partition to be cloned.

alt

Tap right on the arrow keys to move to the next section, Image file to create/use, and give it a name (or enter the filename of the image to be restored).

alt

You can then select the correct Action to be done (ensure the chosen option has an asterisk) and press F5 to proceed. In the following screen, select the Compression Level, and your preferred Options. There is also the choice of setting an image split mode, and setting an instruction for what should happen after the backup is made.

alt

Tap F5 to continue, confirm the details, then tap OK to begin the process. The speed of this will depend on the power of your computer.

If you’re looking for a quick and dirty — but safe — disk cloning solution for Linux, partimage is the best choice.

3. Partclone, Software for Partition Imaging and Cloning

For a more mature alternative to dd that supports backups of the ext4 filesystem, partclone is simple to use, but again requires text commands rather than a keyboard or mouse driven interface. Install with

sudo apt-get install partclone

…and launch with

partclone.[fstype]

…where [fstype] is the filesystem type of the partition you wish to clone.

The following command will create a disk image of hda1 (hard disk drive 1, partition 1) called hda1.img:

partclone.ext3 -c -d -s /dev/hda1 -o hda1.img

You might want to restore that image, so use

partclone.extfs -r -d -s hda1.img -o /dev/hda1

Further details on usage can be found on the partclone website.

4. Clonezilla, Popular Disaster Recovery Solution

For a more flexible solution, why not try Clonezilla? This disaster recovery, software is based on Partclone, and is suitable for a range of disk cloning tasks. All of the expected filesystems are supported, across Linux, Windows, and macOS (and beyond).

Unlike dd and partclone, however, Clonezilla is available as a bootable ISO, which you can burn to DVD or write to a USB stick. Clonezilla is straightforward to use, opting for keyboard-driven menus, rather than obscure commands, meaning that anyone can get to grips with it.

You can also use Clonezilla in a professional capacity, to quickly image multiple similar PC setups with the same operating system.

While you might prefer to simply sync your vital data to the cloud, it is always a good idea to have a full disk backup that you can quickly restore in the event of system errors. Remember to use these tools with care, however, as they can easily cause you to accidentally lose your data.

 

Please follow and like us:
1071

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Enjoy this blog? Please spread the word :)

RSS1k
Follow by Email1k
Facebook9k
Facebook
Google+6k
Google+
https://pjera.com/clone-linux-hard-drive-4-methods">
YouTube2k
YouTube
Pinterest
Pinterest
Instagram3k
LinkedIn