From: <tb...@ti...> - 2001-10-17 01:54:10
|
I admin a small ISP. In the past few weeks, we have had three Seagate drives bite the dust (all the same model/batch), so the assumption is that the other drives are following soon. Replacement drives are only about $100 at Fry's, but who wants to rebuild a dozen machines. The new drives are also bigger, so using dd to image the drives would work, but I wouldn't get the benefit of the increased drive space. Enter Trinux ( Thank you Matt! ). Here is how to clone your hard disks, and get the benefit of the increased capacity of the newer disk. Note that I am actually cloning RedHat installations. It doesn't matter. First, make sure you have available the following packages: diskutil ext2tools fileutil modutil and fsmods <-- from the pkg/2.4.5 folder Open your computer case, and install your new hard disk. Unplug the CDRom (usually connected to primary on the second controller) and plug in your old hard disk instead. Boot Trinux from floppy and load the above packages. The boot kernel doesn't support ext2 filesystems, so you must add the support via a module. Install the ext2.0 module with the command: insmod /lib/modules/ext2.o Now prep your new hard disk with fdisk (or your favorite disk partion app). I set my disks to: fdisk /dev/hda Partition 1 <-- /boot 250M (make this partition active) Partition 2 <-- Swap 250M (change to type 82) Partition 3 <-- / Whatever remains. As big as possiible X86 boxes, and the ancient requirements that all bootable load modules be located in the first 1024 cylinders, need to have the kernels loaded in the first part of the disk. This is why the separate boot partition. Once you have the partitions set, format them with ext2 filesystems with the command: mke2fs /dev/hda1 mke2fs /dev/hda3 and create the swap partition. mkswap /dev/hda2 Be extra careful here, because if you put the disks in backwards, you could be formatting the old data... To be really careful, don't plug in the old data disk until after you have formatted the new one. I do this extra step when the data is critical, and I don't have backups.... Now make two mount points.. mkdir /new mkdir /old mount up the old disk with: mount /dev/hdc3 /old mount /dev/hdc1 /old/boot It might be prudent to e2fsck them first... Then.. mount up the new partitions with: mount /dev/hda3 /new mkdir /new/boot <-- need to create new mountpoint for boot mount /dev/hda1 /new/boot now cd to /old and execute the following: find . -depth -print | cpio -pmduv /new This will copy the contents, file by file from the old disk to the new one. The -depth parameter helps insure that all directories get chowned and chmoded properly, otherwise, cpio will make them owned by the same owner as the first file it writes to the folder. (It is faster if you leave off the "v", but then you stare at a prompt for a long time..) After the file copy is complete, then you need to run lilo, or whatever bootloader you are using. I use the command: cd /new/etc lilo -r /new The "-r /new" causes lilo to do a chroot to /new before running lilo, which is required since you have your new root partition mounted on /new, not the root. Lilo also requires that the disk being bootstrapped be connected to the controller it will boot from. This is why the new disk needs to be put in place on the primary controller, and not the other way around. One last caveat.. RedHat 7.0 is using disk labels in the /etc/fstab file instead of the good old devs. I just edit the labels out and replace them with /dev/hda1 and /dev/hda3 in the fstab file. Or you could label the partitions, but I didn't figgure out how to do that yet... sync and unmount the disks. Shut down the system and remove the old disk. Plug the CDRom back on and boot her up... Back online with all configs, log files, etc, just like when you shut it down. I hope this helps someone out, somewhere... I have been using this method for about a dozen years, since my days at Locus. cpio is the only app I have found that makes perfect mirror images (devs, procs and all), but only if you use -depth with the find... I noticed ntfs tools are available. This might work with Windows disks too. I haven't tried. And Thanks again to Matt, for putting up find and cpio on the pkg site for me. -- -------------------- Timothy Burt Internet Specialist |