Backup of a partition or harddisk using dd Mini Howto for linux. (I am using ubuntu 8.04 and kde) :-) Back to Main Page
How to use the dd command to make a backup of a partition or a harddisk in ubuntu.
This is a "fairly" short version, and if you want to know more, go to the Internet etc.
This howto is without any guarantee, and you may use it on your own responsibility only.
There may be errors, but I do not want to use too much time to write this howto.
To check specific words you may try: http://en.wikipedia.org/wiki/Main_Page (search).


In order to do a dd backup, I find it easy to use a SystemRescueCd - You can download a systemrescuecd iso image here
It needs to be burnt into a systemrescue live cd - I have used a version 0.4.3 in this example.
Insert the systemrescue live-cd and start up your computer - following is a sequence of screenshots:

Just press enter

As I am using a Danish keyboard, I inserted "dk" - then press enter (please choose your keyboard country type)

Shows the command prompt of an ordinary user

To become root insert "su" - then press enter

Here is showed an empty command line, and the "#" shows that you are root (also called superuser)

Change directory to /dev

Lists
the contents of the /dev directory - in order to check out the names of
the harddisk devices (sda - sda1 - sda2 - sdb - sdb1) which are to be
used in dd

Brings
you up one level - means back to /home/yourusername directory (cd
without the two dots will always bring you back to /home/yourusername,
also)

Creates the /media directory - to be used for mounting the external harddisk (/dev/sdb1) partition

Mounts the external harddisk partition to the /media directory

Change directory to /media

Lists the contents of /media

cd
.. brings you back to the /home/yourusername directory - then follows
the first dd command which creates an exact image of the first
partition "/dev/sda1" by the name
"dd_backup_boot_partition_200608.img"
(you could choose another name of your liking - this image will be of
the exact same size as the partition

This
command creates an exact image file of the second partition by the name
"dd_backup_ubu_enc_partition_200608.img - you coul choose another name.
Please note, that the size of the image file will be of the exact same size as the partition.
So
if the size of the partition is 40 GB, and the size of the installed
data is only e.g. 4 GB, the image will still be of 40 GB, so it is
important to have an external harddisk,
which is much bigger than your internal harddisk.
Please
also be careful not to exchange "if" for "of" or vice versa, as it
might have a catastrophal impact, maybe deleting some important data.
To backup a partition of 40 GB took me some 27 minutes (time will depend on the speed of your processor etc)

Restores the "dd_backup_boot_partition_200608.img" back onto the first partition "/dev/sda1"

Restores the "dd_backup_ubu_enc_partition_200608.img" onto the second partition "/dev/sda2"
To make a backup of a complete harddisk run the following command:

This
command creates an exact copy of the whole internal harddisk "/dev/sda"
by the name "dd_backup_whole_harddisk_200608.img" on the external
harddisk "/dev/sda"
To backup a harddisk of 80 GB took me some 77 minutes

Restores "dd_backup_whole_harddisk_200608.img" back onto the whole harddisk "/dev/sda"

Change directory to /media

Lists the contents of /media - to check that the new image file is created

Change back to /home/yourusername directory

To check how much free spce is left on the external harddiskk "/dev/sdb"

Shutdown and halt (stop) your computer now
Advantage: You can backup any kind of data contained on the harddisk, even encrypted data.
Disadvantage: Uses lots of space, and is fairly slow.
6/2008