Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Hardware
User Name
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?


  Search this Thread
Old 06-10-2008, 04:28 PM   #1
Registered: Jul 2005
Posts: 164
Blog Entries: 1

Rep: Reputation: Disabled
Question Copy an internal hard drive as backup? Restore an internal drive?

I have a desktop computer which has an old Mandriva install (actually, Mandrake 10.0 with 2.6.3-7 kernel). This computer has a 40 GB internal hard drive (Western Digital). Since the install is rather old, I am concerned that I might not be able to reconstruct it from the installation disks (especially since something seems to be wrong with one of them!) if the hard drive ever failed.

Nightmare scenario: the hard drive fails and although I regularly back up personal files to CD, I find that I am not able to reinstall all the software (e.g. due to conflicts with the older software I need with currently supported software).

A little late in the game, I'd like to copy the entire drive to another hard drive, using the unix command dd (or another if more appropriate), so that I have a backup.

Can I copy the conents of the entire 40 GB drive to another hard drive (including the master boot record, the boot loader, the operating system, and all the contents of /bin and so on), store that somewhere far away from any magnets, and have a reasonable expectation of being able to replace the orginal drive with a new 40 GB hard drive if/when it fails, copy the backup to the new drive, and be able to boot up normally, and (after updating personal files from CD backup) to be able to get back to work?

What about copying to an external hard drive? The ones I've seen are much larger than 40 GB. If I tried to copy a 40 GB drive to a 160 GB drive, is the worst that can happen that I waste a lot of space? What about copying from the 160 GB drive back to a 40 GB drive?
Old 06-10-2008, 06:27 PM   #2
Senior Member
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
This is not so difficult. I use tar for my routine backups on my systems. If I want to make a restore disk that includes several operating systems then I use a rescue cd distribution (System Rescue CD) and partimage.

Let's say that your system is installed on /dev/hda1 and you have an external hard disk on /dev/sda1. Let's also say that you already have a mount point at /mnt/backup and that you encrypted the external partition with True Crypt. This is what I do.

First I mount the external disk partition on /mnt/backup.

Second I make a backup of the system disk's Master Boot Record using dd. If you have logical partitions you will also need to use sfdisk, which I will include in my example. These copies of the MBR and partition table are written to the / directory in files named <date>-hda-mbr.dd and <date>-hda-partitions.sfdisk.

Third I use tar to make a backup of the / file system storing the archive file in /mnt/backup/<date>-rootfs.tgz, using the --one-file-system parameter to prevent tar from backing up the contents of /mnt/backup et. al.

truecrypt -t /dev/sda1 /mnt/backup

dd if=/dev/hda of=/`date +%F`-hda-mbr.dd bs=512 count=1 conv=notrunc,noerror

sfdisk -d /dev/hda > /`date +%F`-hda-partitions.sfdisk

tar czv --one-file-system f /mnt/backup/`date +%F`-rootfs.tgz /
Of course if you don't use True Crypt to encrypt /dev/sda1 then you can just mount that partition using the mount command.

Using partimage is also pretty easy. I boot a CD containing System Rescue CD. We need to do this because partimage won't back up a mounted partition/file system. Partimage is particularly good if you have a dual boot system and you just want to get a snapshot of your systems before viruses or misconfigurations begin to accumulate in your operating system.

Boot System Rescue CD.

Run partimage.

The menu is pretty self explanatory. The only caveat is that you cannot use bz2 compression if you want to be able to retrieve your MBR and partition table from the partimage backup. In all respects the partimage archive is comparable to a Norton Ghost archive. It contains the files and the MBR and the partition table. It does not copy empty disk blocks. If you want to put the archive files on CD then you may want to limit the archive file size to 2000 blocks. Then if the backup requires more space partimage will create more 2000 block archive files.

I have used both of these methods to restore systems that I have backed up. Both methods are reliable. Partimage is a little bit less trouble to restore. After all, remember that with the tar archive file the disk partition information and MBR are inside the archive file. You have to extract them from the archive file in order to use them, then restore the archive file to the new disk, so it is one extra step to recover the system. On the other hand the tar method is quicker to do and you can perform a tar archive backup while the system is running. You can't do that with partimage.

Last edited by stress_junkie; 06-10-2008 at 06:33 PM.
Old 06-15-2008, 03:28 PM   #3
Registered: Nov 2002
Location: Italy
Distribution: Linux Mint 17 Xfce
Posts: 284

Rep: Reputation: 30
I have used clonezilla and i have found it really good. It's a live distro designed to backup and restore.

But i don't know what happens if you want to restore a 40gb image on a 160gb hd. Sorry.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Copying files from internal Hard drive to USB 2.0 Hard Drive is NOT Behaving tubatodd Ubuntu 4 02-19-2007 04:32 PM
Internal Hard Drive issue alfredofernandeza Linux - Hardware 13 12-09-2006 03:55 PM
Installing grub to external USB hard drive for later use as internal hard drive dhave Linux From Scratch 2 12-10-2005 08:48 AM
seperate internal hard drive cerealdaemon Linux - Hardware 2 08-06-2005 12:05 PM
Installation of internal HP DAT 40i DDS internal tape drive netkepala Linux - Hardware 3 11-08-2004 12:22 PM > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 03:52 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration