How to Easily Clone and Restore a Linux Disk Image With dd

How to Easily Clone and Restore a Linux Disk Image With dd

When the time involves wipe, backup, or restore information on Linux, there are a number of apps you may decide. GParted is without doubt one of the most confirmed choices on the market. GNOME Disks is a extra fashionable various that appears nice within the GNOME desktop atmosphere. However irrespective of which Linux working system you run, there’s one possibility that at all times works—dd.

You should use Linux with out ever needing to dip into the terminal. However when you add sure instructions to your repertoire, not solely will you save time, however you’ll be taught abilities that you should use throughout any model of Linux.

Why Use dd?

Whether or not you are on a desktop or a server, dd merely works. dd started as a Unix command, so along with Linux, it helps different Unix-like working methods similar to FreeBSD and macOS.

dd additionally takes mere seconds to provoke a wipe or create a disk picture. As soon as you understand what to kind, you may open a terminal and erase a drive within the time it takes you to kind in a seek for directions on-line.

With nice energy comes nice accountability. The command to clone a drive is not all that totally different from the one to erase one. It’s essential pay further consideration to what you kind when working with instructions that may delete recordsdata.

Associated: Learn how to Format Storage Drives Utilizing the Linux Terminal


Are you nervous? Good. Even as soon as you are a dd knowledgeable, you at all times wish to kind out instructions fastidiously. An absent thoughts can, at worst, smash {hardware} and, extra probably, lead to information loss. Now, let’s get began.

Cloning a Drive With dd

Cloning a drive is a sure-fire method to make a backup of your laptop. You’ll be able to again up information to a transportable laborious drive or Dropbox, however this solely saves your recordsdata.

To save lots of your apps, you need to discover ways to again up every particular person app. For some, meaning exporting a selected file. For others, meaning copying a hidden folder. Then there are these apps that you could’t again up in any respect.

dd will get round this by creating an actual copy of your complete laborious drive or partition. Whenever you restore this copy, you deliver your laptop again to precisely the way it was. You’re going to get again your recordsdata, your apps, your looking historical past, and even your system settings. Every little thing.

To clone your drive, you will want a second drive that has more room than the one you are copying. Seemingly, this might be a transportable laborious drive or a big flash drive.

Begin by opening the terminal. You have to administrator rights to execute any dd instructions. You’ll be able to kind su to register as an administrator or kind sudo initially of the dd command.

Whenever you’re prepared to repeat, kind the command under. Observe, it would erase any pre-existing information on the second drive, so ensure to again up any information beforehand.

dd if=/dev/sdX of=/dev/sdY

Now, let’s make sense of what is going on on. dd is the command. if is the enter, as within the location you wish to copy. of is the output or the placement you are changing together with your copy.

sdX and sdY consult with the drives you’re interacting with. Drives are sometimes given a reputation similar to /dev/sda, /dev/sdb, or /dev/sdc. Yow will discover out the names utilizing a partition editor. Or, because you’re already within the terminal, you should use the lsblk command.

Making a Disk Picture

One other method to clone a drive is to create a disk picture that you could transfer round and restore as you’d do with a bootable USB.

Creating picture recordsdata means that you can save a number of backups to a single vacation spot, similar to a big transportable laborious drive. Once more, this course of solely requires one command:

dd if=/dev/sdX of=path/to/your-backup.img

To save lots of house, you may have dd compress your backup.

dd if=/dev/sdX | gzip -c > path/to/your-backup.img.gz

This command shrinks your backup into an IMG.GZ file, one of many many compression codecs Linux can deal with.

Restoring a Drive With dd

What good are the backups if you cannot use them? Whenever you’re prepared to revive a picture with dd, you have got two choices. In the event you used the primary strategy, merely swap the 2 locations.

dd if=/dev/sdY of=/dev/sdX

When restoring from a picture file, the identical idea applies:

dd if=path/to/your-backup.img of=/dev/sdX

In case your picture file is compressed, then issues get somewhat totally different. Use this command as a substitute:

gunzip -c /path/to/your-backup.img.gz | dd of=/dev/sdX

To be clear, gunzip is “g unzip,” as within the reverse of “g zip.” This command decompresses your backup. Then dd replaces the prevailing drive with this picture.

Parameters to Take into account

You’ll be able to alter your command by sticking a parameter on the finish. By default, dd can take some time to switch information. You’ll be able to velocity up the method by growing the block measurement. Accomplish that by including bs= on the finish.

dd if=/dev/sdX of=/dev/sdY bs=64

This instance will increase the default block measurement from 512 bytes to 64 kilobytes.

conv=noerror tells dd to proceed regardless of any errors that happen. The default habits is to cease, leading to an incomplete file. Understand that ignoring errors is not at all times protected. The ensuing file could also be corrupted.

conv=sync provides enter blocks with zeroes at any time when there are any learn errors. This fashion information offsets stay in sync.

You’ll be able to mix these final two as conv=noerror,sync in the event you so need. There is no such thing as a house after the comma.

Attending to Know dd

In case you are , dd’s identify refers to a statement in IBM’s Job Control Language. In the event you do not perceive what is going on on there, no sweat. That does not make the command any more durable to make use of.

Want extra data to assist with dd? The wiki page is fairly thorough. There’s additionally an amazing write-up on the Arch Linux wiki. Once more, it does not matter in the event you’re utilizing Arch or not. dd works the identical means no matter your Linux working system.

If it seems dd is not for you, you are not out of luck. There are different methods to clone a tough drive!

Learn how to Clone Your Linux Exhausting Drive: 4 Strategies

Must clone your Linux laborious disk drive or partition? Use one in all these drive cloning instruments to clone your Linux disk.

Learn Subsequent

About The Creator

Leave a Comment

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