LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-29-2004, 12:58 AM   #1
arrruken
Member
 
Registered: Apr 2003
Distribution: gentoo
Posts: 238

Rep: Reputation: 32
"Ghosting" a linux install


Has anyone done a backup or "ghost" of a linux install and/or what are the best ways to do so. Right now Im considering booting a live cd of gentoo and using "dd" to copy all /dev/hda to /dev/hdb OR using something like taper. If anyone has used something and had good success, please recommended. I dont want to use ghost, its not free.
 
Old 03-29-2004, 05:37 AM   #2
ac1980
Member
 
Registered: Aug 2003
Location: Trento, Italy
Distribution: Debian testing
Posts: 394

Rep: Reputation: 30
Don't dump hda on hdb unless the disks are actually the same size, since you're transferring PT too. You can actually dd the disk to a file or a partition
I myself simply use a cp -r --preserve=all, but tar will make the job as well (use -S if you have sparse files).
Moreover, this way you can restore your system on any partition/filesystem you want.

If you want to restore across different fs, you'll have to first mount each branch (e.g. /target/home). In case remember to update /etc/fstab
 
Old 03-29-2004, 11:48 AM   #3
arrruken
Member
 
Registered: Apr 2003
Distribution: gentoo
Posts: 238

Original Poster
Rep: Reputation: 32
Yeah, the hard drives are gonna be the same size. Will "cp -r --preserve=all" copy the boot record and everything? Or should I stick to "dd" since they are gonna be the same size? Which one would be faster?
-update- I cant use taper, because the newest stable version only supports 4 gb's. Im try to copy an 80 gig to another 80 gig, because the first is a crappy WD that is clicking up a storm.

Last edited by arrruken; 03-29-2004 at 11:50 AM.
 
Old 03-29-2004, 08:39 PM   #4
liamoboyle
Member
 
Registered: Mar 2004
Location: Wellington, New Zealand
Distribution: Debian
Posts: 127

Rep: Reputation: 15
If you use cp / scp / tar / cpio / afio etc. to copy it, it'll be faster, because you won't be copying empty space, and you'll also save duplicating bad blocks on your hard disk. It won't copy the MBR, but all you have to do is boot with a boot disk and run lilo to rewrite it on the new disk, only a couple of minutes extra work (and shorter overall).
 
Old 03-29-2004, 11:07 PM   #5
arrruken
Member
 
Registered: Apr 2003
Distribution: gentoo
Posts: 238

Original Poster
Rep: Reputation: 32
Sounds good. Ill try it out when the new hdd gets here on Thursday.
 
Old 04-02-2004, 01:48 AM   #6
ac1980
Member
 
Registered: Aug 2003
Location: Trento, Italy
Distribution: Debian testing
Posts: 394

Rep: Reputation: 30
The main problem of this approach is that you need to partition the drive and format every partition before actually copying. You can print your partition list with "fdisk -l" (as root). I suppose there is some automatic script to rebuild a PT from this sort of output, but I don't know where to find it.
 
Old 04-02-2004, 03:03 AM   #7
Flibble
Member
 
Registered: Mar 2002
Distribution: Redhat 9.0, Debian, Knoppix, YellowDog
Posts: 142

Rep: Reputation: 15
http://www.gnu.org/software/parted/parted.html

Consider it GHOST for Linux.

;>

Flibble
 
Old 04-02-2004, 07:16 AM   #8
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Actually, I consider partimage to be the best "ghosting tool" to use for Linux or Windows systems.

The part about setting up the partitions used to give me the fits until I found out you can use sfdisk to save and restore all or part of the MBR. That means you don't have to manually enter the partition table.

The reason I run sfdisk and dd... to save and restore the mbr is incase there are any issues with extended partitions. ( that's what I read anyway )

Here's how I do it.....

If you are going to clone an NTFS partition, you may want to run defrag and scandisk first.

Get a cd bootable version of linux like system rescue at http://www.sysresccd.org and bootup with that cd.

Mount the partition where the images are going to be saved to.
mount /dev/hdb1 /mnt/images/backup -t ext3

Run partimage to make the images and save it to the backup directory which was created in the previous step.

In this example, I have a dual boot system so I backed up both operating systems with partimage.

Save the ENTIRE PARTITION TABLE to a file using sfdisk.
sfdisk –d /dev/hda > /mnt/images/backup/partfile
Save the MBR to a file...
dd if=/dev/hda of=/mnt/images/backup/mbrfile bs=512 count=1

The clone script will restore that partition table and MBR from files to the new hard drive using the commands:
sfdisk /dev/hda < /mnt/images/backup/partfile
dd if=/mnt/images/backup/mbrfile of=/dev/hda bs=512 count=1


After you have saved the images and the partition table, install the new hard drive, make sure that bios sees it as the /dev/hda ( Primary Master ) so you don’t accidently zap your backup images which are saved on the /dev/hdb ( Primary Slave ) .

Bootup with the rescue cd and run the clone script to restore the images to your new hard drive.

Code:
#!/bin/bash
#
clear
echo
echo "********************************************************************"
echo "     Caution!!!     This program will erase your hard drive"
echo
echo -n "                Do you want to proceed (Y/N)?"
read answer
if test "$answer" != "Y" -a "$answer" != "y";
then exit 0;
fi
#
clear
#
#Erase the old boot sector
dd if=/dev/zero if=/dev/hda bs=512 count=1
#
#Restore the partition table from file
sfdisk /dev/hda < /mnt/images/backup/partfile
#
#Restore the MBR from file
dd if=/mnt/images/backup/mbrfile of=/dev/hda bs=512 count=1
clear
#
#Restore the images with Partimage
partimage restore -b -z2 -f3 /dev/hda1 /mnt/images/backup/windows.000
#
partimage restore -b -z2 -f3 /dev/hda2 /mnt/images/backup/linux.000
#
clear
echo "Image restore is complete"
echo
#
#End

Last edited by homey; 04-02-2004 at 07:19 AM.
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
FC4 install errors, "diabling IRQ #10" "nobody cares" error message??? A6Quattro Fedora 6 07-20-2005 12:49 PM
"Successful install" results in "Boot device not found" slackr007 Fedora 2 06-21-2005 04:05 PM
"Successful install" results in "Boot device not found" slackr007 Linux - Newbie 2 05-31-2005 08:02 PM
Can't install "glibmm" library. "configure" script can't find "sigc++-2.0&q kornerr Linux - General 4 05-10-2005 02:32 PM
does failed using urpmi messed up my "Install Software" / "mandrake update" ??? sirpelidor Mandriva 1 11-02-2003 09:00 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:26 AM.

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