Using DD to backup your drive

Using DD to backup your drive


This post was last updated on July 9th, 2020 at 03:47 pm

How to backup your hard drive (the type of format doesn’t matter) using dd.

Boot to some rescue mode by using the install media (generally “linux rescue”) otherwise enter rescue mode manually: //

Make sure not to be booted to your hard drive, nor to have any of those partitions mounted.

Now use any combination of dd, ssh or rsh, gzip or bzip2 to backup the drive (I recommend using ssh versus rsh; however, ssh is generally not available during the rescue mode, whereas rsh is available):

You can backup the whole drive (if you have enough space on your destination system) as follows (This method also grabs the MBR):

dd if=/dev/sda | rsh [email protected] “gzip -9 >20030220-backup-sda.dd.gz”

A restore using this method would be as follows:

rsh [email protected] “cat 20030220-backup-sda.dd.gz | gunzip” | dd of=/dev/sda

To backup individual partitions, be sure to grab the MBR because it contains the partition table, as well as any partitions you want to backup:

dd if=/dev/sda bs=512 count=1 | rsh [email protected] “cat – > 20030220-backup-mbr.dd”
dd if=/dev/sda1 | rsh [email protected] “gzip -9 > 20030220-backup-sda1.dd.gz”

A restore would go as follows – be sure to restore the MBR, reboot, then restore the other partitions.

rsh [email protected] “cat 20030220-backup-mbr.dd” | dd of=/dev/sda
reboot to re-read partition table (come back into rescue mode)
rsh [email protected] “cat 20030220-backup-sda1.dd.gz | gunzip” | dd of=/dev/sda1

Depending on which machine is the fastest and how fast your network is, you need to decide when you will do the compression. Your choices are to compress before sending over the network, but if this machine is much slower than the server you are sending to, then it may be better to send the uncompressed data over the network to the destination server and compress as the data arrives. Just keep in mind that the transfer over the network will be a little slower if sending uncompressed data rather than compressed — also the network speed affects this too — 10 Mbit vs. 100 Mbit. Use your best judgement.

Other pages to read up on are:
How to recover Linux
File Copy using SSH
Resize data using DD command

Previous How to Login with Passwordless SSH Keys
Next Static Routes in RH73 Linux

About author

Sibananda Sahu
Sibananda Sahu 186 posts

A Linux Kernel Developer and a Firmware Developer by profession. Have worked with few big companies: BROADCOM Corporation, Cypress Semiconductor, LSI Corporation, TOSHIBA Corporation, Western Digital; on various cutting edge technologies and product lines, such as: RAID storage Driver, SSD Firmware, WLAN Firmware etc. Having more than 9 years of experience in Software Engineering domain. Now, took a pledge to educate all aspirant students to teach about Linux Kernel Development.

View all posts by this author →

You might also like

Administration 0 Comments

SAMBA in Linux – Administration Checklist

This post was last updated on May 27th, 2020 at 05:04 pm Contents1 Samba startup guide checklist:2 Getting SWAT to work in RH70 Samba startup guide checklist: This applies to

Administration 0 Comments

Virtualization In Linux With Xen

This post was last updated on August 3rd, 2020 at 02:20 pmContents1 Virtualization Technology2 Hardware Virtualization2.1 1. Full virtualization –2.2 2. Paravirtualization–2.3 3. OS level virtualization –2.4 4. Hybrid virtualization

Administration 0 Comments

Network File Copy using SSH

This post was last updated on May 26th, 2020 at 02:45 pmPlease note that &&, ||, and -, are documented at the bottom of this page. Contents1 PUSH:2 PULL:3 COMPARE:4


No Comments Yet!

You can be first to comment this post!

Leave a Reply