An image of your hardrive are all your files on your computer packed into one large file. If something were to happen to your computer, for example a blue screen of death, or your computer becomes infected with spyware, malware or virus's, you may come to the point where you have no other option but to start from scratch. You are left with a time consuming job which involves re-installing a fresh copy of your operating system, including all the other programs you use, not to mention updating the operating system. Making an image of a hardrive will take you back to the time when you made the image, this process can cut the time it takes to get back on your feet in half. In this article I will explain how to do this, without having to pay a cent for software.
Ive tried to explain this in such a way that a person who has little to no knowledge of Linux can follow. For the people who are already familiar with Linux, just skip the parts you already know.
In this tutorial we will use the command dd to make a backup of your hardrive. If you do not prefer this method, you can find PartImage on the System Rescue Cd, it should be pretty straight forward to use, just follow the prompts.
THE AUTHOR OF THIS ARTICLE WILL NOT BE LIABLE FOR DATA LOSS, DAMAGES, LOSS OF PROFITS OR ANY OTHER KIND OF LOSS FROM THE INFORMATION PROVIDED BY THIS ARTICLE.
What you will need?
- A large enough space to store the image
(Note: This has to be larger then the hardrive partition you plan to backup)
- A blank CD
- System Rescue CD Software
What is System Rescue CD?
A live bootable linux distro, sort of like a running operating system on your hardrive but instead, on a CD.
You can download System Rescue Cd from here:
http://www.sysresccd.org/Download
How to copy System Rescue Cd Image to a Cd?
1. Open up Magic ISO, click on try it.
2. Browse and select the System Rescue CD image
3. Insert a Cd into the CD drive
4. Click on Burn it!
I have created a script which will allow you to copy one or more hardrive partition's unattended.
It also updates the status of the job every minute.
You can download the script here (Updated 8/2/10):
Click here to download script
Copy this script to the root directory of the hardrive partition you are placing the backup image file on.
Lets start:
1.
Insert the System Rescue CD into your Cd drive and reboot.
2.
Press enter when prompted, press enter to select default keyboard.
(Note: You may have to change your boot priority in order to boot from a CD, using the bios)
3.
Type in startx and press enter, you will see a Linux desktop.
(Note: This may take some time to load)
4.
Now you need to figure out which hardrive partition contains your OS which you want to make a backup of, as well as the hardrive partition were you want to store the image file on and its format type. (e.g ntfs, fat)
The simplest way to do this is to open up Gparted, it should be on the taskbar, or look through the menu on the bottom left corner.
You can also use the command fdisk -l to list all the hardrive partition's. Type this in terminal (Yellow Box)
What you are looking for is the location of the estimated size that matches your hardrive partition.
(e.g /dev/sda1)
5.
For this example we will use:
/dev/sda1 as the operating system parition we want to backup
and
/dev/sdb1 as the hardrive partition location where we will place the backup image file.
Mounting will allow us to access the files of the hardrive at the location /mnt/windows. We need to mount the hardrive partition (/dev/sdb1) we plan to place the image backup file on.
In terminal (Yellow Box)
If the partition is ntfs, type:
ntfs-3g /dev/sdb1 /mnt/windows
If the partition is fat, type:
mount /dev/sdb1 /mnt/windows
6.
Now that we mounted the hardrive, we will navigate to the root directory of the hardrive partition (/dev/sdb1)
To get into the directory type:
cd /mnt/windows
7.
We need to edit the script, type:
nano backup.sh
8.
WARNING, MAKE SURE YOU FOLLOW THIS STEP VERY CAREFULLY AS YOU COULD LOSE ALL YOUR FILES:
Where it says jobs=("dd if=/dev/urandom of=/dev/null") , we will replace this with:
jobs=("dd if=/dev/sda1 of=backup bs=1024K")
What this means is we are copying /dev/sda1 and placing the hardrive image into a file called backup on the hardrive partition of /dev/sdb1 located at /mnt/windows.
If you want to compress the file instead replace ("dd if=/dev/urandom of=/dev/null") with:
jobs=("dd if=/dev/sda1 bs=1024K | gzip -c9 > backup.gz")
(Note: Compressing the file image will take longer)
If you want to shutdown the computer after the backup is complete, edit doshut=false to:
doshut=true
Once you are done editing the script, press ctrl+x to exit the editor, you will then be asked if you want to save the file, press y to do this.
9.
Now we need to execute the script by typing:
bash backup.sh
You have now started to copy your backup image file, this will take some time. You may want to find a way to entertain yourself while your waiting.
10.
If for some reason you didn't want to shutdown after the backup is complete, once you are done, type these commands one after the other to shutdown safely:
cd /
umount -l /mnt/windows
shutdown -h now
The first command will leave /mnt/windows directory so we can unmount the hardrive using the second command, the third command will shutdown the computer.
How to restore the backup image to your hardrive partition:
Follow steps 1-10
For step 8:
Were it says jobs=("dd if=/dev/urandom of=/dev/null") , replace this with:
jobs=("dd if=backup of=/dev/sda1 bs=1024K")
If you chose to compress the file, replace jobs=("dd if=/dev/urandom of=/dev/null") with:
jobs=(“gunzip -c backup.gz | dd of=/dev/sda1 bs=1024K”)
This will get the image file backup that you have created and replace it with /dev/sda1