Author |
Message |
abast62
|
Posted: Sat Feb 12, 2005 1:23 pm |
|
Joined: Tue Jan 04, 2005 4:01 pm
Posts: 54
|
Hello guys:
Wondering how do I go about making an exact mirror of my hard drive on to another drive? If my current drive fails all I would have to do is place the mirror drive and be up and running.
_________________ AMD Athlon 666mghz
asus a7a266 motherboard
1gig ram
160 gig drive
pvr 250
nvidia gforce 4 mx
|
|
Top |
|
 |
cesman
|
Posted: Sat Feb 12, 2005 3:55 pm |
|
Joined: Fri Sep 19, 2003 7:05 pm
Posts: 5088
Location:
Fontana, Ca
|
dd if=dev/hda of=/dev/hdb
man dd for more...
_________________ cesman
When the source is open, the possibilities are endless!
|
|
Top |
|
 |
abast62
|
Posted: Tue Feb 15, 2005 2:16 pm |
|
Joined: Tue Jan 04, 2005 4:01 pm
Posts: 54
|
dd if=dev/hda of=/dev/hdb
--------------------
Will this allow me to make an image of my current hard drive and use the new drive to boot my computer if the old drive crashes?
_________________ AMD Athlon 666mghz
asus a7a266 motherboard
1gig ram
160 gig drive
pvr 250
nvidia gforce 4 mx
|
|
Top |
|
 |
rusty0101
|
Posted: Tue Feb 15, 2005 4:01 pm |
|
Joined: Mon Jan 05, 2004 1:30 pm
Posts: 139
Location:
New Hope, MN
|
abast62 wrote: dd if=dev/hda of=/dev/hdb --------------------
Will this allow me to make an image of my current hard drive and use the new drive to boot my computer if the old drive crashes?
Yes. There are a few gotchas however. First of all you want both hard drives to be identical. If you do a 'fdisk -l /dev/hda' and it comes back with something like:
Disk /dev/hda: 120.0 GB, 120034123776 bytes
you want /dev/hdb to be the same capacity. You may be able to get away with having more space on hdb, but you will end up with problems if you move to a smaller hard drive.
The next issue is that this will be a static image. If you are doing security updates, installing or removing software, etc. your static image is going to go out of date fairly quickly. Likewise if you are recording to /dev/hda4 (or some other partition on hda) your recordings made after you do the dd are going to be missing.
If you are interested in having an active RAID-1 mirror of your hard disk, you will need to either do software raid-1, or use appropriate raid-1 capable hard ware (say a promis tx2 ata adapter, or similar to get that going. Here are a couple of URL's to investigate [url]http://www.tldp.org/HOWTO/Software-RAID-HOWTO.html,/url] and [url]http://www.tldp.org/HOWTO/ATA-RAID-HOWTO/index.html[/url]. As I presume you already have your system set up, you may also want to look into the process for migrating to RAID-1 at http://www.tldp.org/HOWTO/Linux-Promise-RAID1-HOWTO/index.html The focus of that URL is a version of RedHat, but the general principles are going to be applicable.
Enjoy.
-Rusty
_________________ Master:
- AMD 1800XP on a MSI KT4V motherboard, via KT400 bios
- 120 G Segate Baracuda /, /cache, /myth, swap
- 200 G Segate Baracuda /myth/tv
- 3 Haupauge! WinTV PVR250s
- 19" Daewoo Monitor (1280x1024 ni)
|
|
Top |
|
 |
Xsecrets
|
Posted: Tue Feb 15, 2005 6:06 pm |
|
Joined: Mon Oct 06, 2003 10:38 am
Posts: 4978
Location:
Nashville, TN
|
also if you want to blank hda really quick just reverse the command.  muhaaahaa beware d(isk)d(estroyer) lol 
_________________ Have a question search the forum and have a look at the KnoppMythWiki.
Xsecrets
|
|
Top |
|
 |
davem
|
Posted: Tue Feb 15, 2005 7:54 pm |
|
Joined: Mon Nov 17, 2003 8:59 am
Posts: 206
Location:
Michigan
|
At work we install a backup disk in our customer machines. We use mkcdrec to make a recovery cd of the main drive, then swap cables, boot the cd and install to the backup drive. After that's complete, the cables swap back and we run from the main drive.
Every night there's a cron job that mounts the backup drive, rsyncs the main drive to the backup drive, then umounts the backup drive. For those unfamiliar with rsync, it can be used to only update files that differ so the amount of transfer from one disk to the other is minimal. Only files that have been added or modified since the last sync are transferred.
With this scheme if the main drive dies or the customer screws it up they only have to swap cables and they can boot from the backup hard disk that is at most 24 hours out of date.
|
|
Top |
|
 |
khrusher
|
Posted: Tue Feb 15, 2005 8:51 pm |
|
Joined: Tue Apr 13, 2004 6:51 pm
Posts: 890
Location:
Groton, MA
|
keep in mind that raid and mirror disks ARE NOT SMART. they mirror bad data as well as good.
you dd scheme will provide a static snapshot that will not be effected if you issus a "rm -rf /" command
you need to decide what you want, a static back up it your data gets hosed via a normal (but not sane) command/process (DD) or recovery from a disk hardware failure (RAID)
_________________ R5F1 - Dell P4 2.4Ghz 500MB - PVR250 x 2 - GeForce FX 5200 - Onboard sound/NIC 80GB ATA/250GB ATA/400GB SATA
|
|
Top |
|
 |
abast62
|
Posted: Tue Feb 15, 2005 9:08 pm |
|
Joined: Tue Jan 04, 2005 4:01 pm
Posts: 54
|
Davem:
Can you explain how to install mdcdrec and the cron jon??
Thanks
_________________ AMD Athlon 666mghz
asus a7a266 motherboard
1gig ram
160 gig drive
pvr 250
nvidia gforce 4 mx
|
|
Top |
|
 |
abast62
|
Posted: Tue Feb 15, 2005 9:27 pm |
|
Joined: Tue Jan 04, 2005 4:01 pm
Posts: 54
|
Davem:
Sorry about my typos. I found a tutorial on installing mkcdrec. Any suggestions on how to setup the cron job?
_________________ AMD Athlon 666mghz
asus a7a266 motherboard
1gig ram
160 gig drive
pvr 250
nvidia gforce 4 mx
|
|
Top |
|
 |
abast62
|
Posted: Tue Feb 15, 2005 9:53 pm |
|
Joined: Tue Jan 04, 2005 4:01 pm
Posts: 54
|
Could I load up Knopppix on my mythbox and create a recovery cd?
_________________ AMD Athlon 666mghz
asus a7a266 motherboard
1gig ram
160 gig drive
pvr 250
nvidia gforce 4 mx
|
|
Top |
|
 |
tjc
|
Posted: Wed Feb 16, 2005 1:02 am |
|
Joined: Thu Mar 25, 2004 11:00 am
Posts: 9551
Location:
Arlington, MA
|
BTW - Make sure that both disks are otherwise IDLE before doing a dd. You don't want to try to make an image copy of a disk while it's being modified. The results can be... ugly. This probably means booting from the CD, and running from a ramdisk image.
|
|
Top |
|
 |
Greg Frost
|
Posted: Wed Feb 16, 2005 1:10 am |
|
Joined: Mon May 10, 2004 8:08 pm
Posts: 1891
Location:
Adelaide, Australia
|
you can also stop all of the services that are running and remount all of the partitions on that disk as readonly. This is a bit of a pain, because it will only let you remount readonly if the filesystem is not being used (hence the need to stop all services). I have done this before but I can't remember the commands of the top of my head sorry.
|
|
Top |
|
 |
abast62
|
Posted: Wed Feb 16, 2005 11:24 am |
|
Joined: Tue Jan 04, 2005 4:01 pm
Posts: 54
|
rusty
you mentioned and i've read that both drives have to be identical. However, I read an article that made me thing that what needs to be identical are the partitions and not the memory size of the hard drive:
Here's a summary of what I found:
The simplest, cheapest backup of all..... A summary...
1. Acquire Knoppix as before.
2. Acquire a second hard drive and install on the second IDE controller as master. The new disk drive is /dev/hdc
3. Boot knoppix.
Open a terminal window, and enter "cfdisk /dev/hda." Note the partition size.
Open a second terminal window and enter "cfdisk /dev/hdc." Create the new partition exactly the same size as the one above, and set the type the same. Make it bootable. Write the partition table.
In a third terminal window, switch to root via "su." Issue the command "dd if=/dev/hda of=/dev/hdc" This command will duplicate your main disk drive onto the hdc disk drive. It takes about an hour for every 10- 20 GBytes of disk size. Keep in mind that this duplicates the entire disk drive partition, including all the empty sectors.
To switch to the new disk drive, simply switch the IDE cables on the motherboard! That is it!!
You now have the second disk created exactly like the first disk. You can even change the IDE cables inside the PC, and the PC should boot from the new disk drive. You should go into the BIOS and make sure the BIOS rereads and sets the disks correctly, since I doubt your disks are identical. Once XP starts, it will detect the new hardware, and will probably ask you to reboot the PC.
This is a great way to get a new hard disk into your system. Even though you had to create the new disk with the exact same partition sizes, you can use "parted" or partition magic tools to resize the partition to a larger size.
http://www.pccitizen.com/driveimage.htm
_________________ AMD Athlon 666mghz
asus a7a266 motherboard
1gig ram
160 gig drive
pvr 250
nvidia gforce 4 mx
|
|
Top |
|
 |
rusty0101
|
Posted: Wed Feb 16, 2005 12:16 pm |
|
Joined: Mon Jan 05, 2004 1:30 pm
Posts: 139
Location:
New Hope, MN
|
It depends upon how you are using 'dd'. If you use the command 'dd if=/dev/hda of=dev/hdb' then the destination drive needs to be as large, or possibly larger than the source drive. Part of what you are copying with that command is the partition table, which means that the drive layout needs to be at least capable of holding the capacity you start with. The question come in when you go to start using that drive, whether the system will complain that ther is empty space on the end of the HD that is not indicated in the partition table.
If you use the command 'dd if=/dev/hda1 of=dev/hdb1' and similar for remaining partitions, and you have set up the partitioning on the destination drive to match the source drive partitioning, (capacity wise) then you will probably run into fewer problems.
Not having made a practice of mirroring drives in this way for the most part I don't know that my comments are accurate. You could very well be right.
-Rusty
_________________ Master:
- AMD 1800XP on a MSI KT4V motherboard, via KT400 bios
- 120 G Segate Baracuda /, /cache, /myth, swap
- 200 G Segate Baracuda /myth/tv
- 3 Haupauge! WinTV PVR250s
- 19" Daewoo Monitor (1280x1024 ni)
|
|
Top |
|
 |
davem
|
Posted: Wed Feb 16, 2005 3:38 pm |
|
Joined: Mon Nov 17, 2003 8:59 am
Posts: 206
Location:
Michigan
|
I just peeked at our script for the first time in a while and it's kind of bloated, with several wrapper scripts and lots of error checking. Here is the basic idea. These shell commands will sync a single partition (/myth) from the main drive to the backup drive on /dev/hdb. It assumes fstab is set up for hdb so you can mount it by mount point name.
Code: mount /mnt/hdb4 rsync --archive --delete --one-file-system --hard-links --verbose /myth/ /mnt/hdb4 # pause for journal to be written sleep 10 umount /mnt/hdb4
The cool thing about this is that it only copies the files that have changed. So if you have 200 gig of files and only 10k worth of files differ between the two disks then only 10k get updated on the backup disk.
|
|
Top |
|
 |