The most recent version of this document can be obtained at http://www.cs.umass.edu/~olc/linux_clone.txt Instructions for "cloning" a linux/win95 dualboot machine 1.01 2/3/98 Notes: Since we're using "dd" to essentially perform a sector-by-sector copy, this method will probably work completely only when the disks have the same geometry, i.e. identical mfr/model. The partition table and all data on the target disk will be overwritten. It's possible to clone the linux part of an installation to a disk with different geometry using the dump/restore pipes, but I doubt the win95 part would work. The systems don't have to be *precisely* identical (other than the disks) for this to work. There were three differences between the two systems I first tried this with. The source had 256M of RAM, an AdvanSys SCSI card and a JAZ drive attached to it; the target had 128M, no SCSI adapter, and an IDE-interface ZIP drive. Win95 automatically detected the differences, and linux automatically recognized the zip drive and left the SCSI module out of the kernel. I suppose I could have left it that way, but I felt it would be better to rebuild the kernel anyway. Do be wary of different monitors, though. If the HSync/VertRefresh rates in /etc/XF86Config are wrong for the second system's monitor, you might conceivably damage an older monitor if you start X up without reconfiguring. The initial effort was done with two EIDE disks, but I think this will work with SCSI drives as well. If you try it, let me know beforehand. You should run badblocks(1) on both drives before and after the dd command. One final note -- I know you know it, but here's an explicit reminder. *Always* triple-check your device files when using fdisk or dd; it's awfully easy to type "/dev/hda" when you meant "/dev/hdb", and dd in particular will blithely let you overwrite your carefully-setup source disk with random garbage from what you intended as a target disk. D'oh! 1. Install source machine, get it completely set up including win95 extra software, modular kernel with appropriate drivers, NFS mounts, and user and data partitions. (Cloning should happen after the source machine is ready to go out the door in all other respects.) Shut the machine down and power it off. 2. Attach the 2nd hard drive. (If EIDE, make sure it is set to either "slave" or "cable select". If SCSI, make sure it is a higher SCSI id than the source drive. Generally the source drive will need to be SCSI ID 0 anyway in order for the system to boot from it.) 3. Boot the system single-user. (At the LILO prompt, type "linux single".) Mount any local filesystems that didn't mount automatically. 4. Use "dd" to copy from the special device file of the source disk to the SDF of the target disk; i.e., at the prompt: dd if=/dev/hda of=/dev/hdb assuming hda is source and hdb is target. (For SCSI drives they would probably be /dev/sda and /dev/sdb respectively; check dmesg to be sure.) Let the dd run for a while, say two or three hours. If it appears to have hung, ^C out of it; you will at least have written the partition table. If it seems to have completed (you get the ####+# records in, ####+# records out message and the prompt back) try skipping ahead to item 5. This first time round, I canceled the dd and went through the following steps. 4a Use "fdisk /dev/hdb" to check the partition table and re-write it. (Exit with "w".) Now, format each non-swap linux partition using "mkfs /dev/hdbX", where X is the partition number. For good measure, format the Win95 partitions too, using "mkdosfs /dev/hdbX". 4b Use a dump/restore pipe to clone the linux filesystems; i.e. if (f'rinstance) /dev/hda2 is / and /dev/hda8 is /usr, you would use something like the following: mkdir /usr/tmp/mnt mount /dev/hdb2 /usr/tmp/mnt /sbin/dump 0f - / | (cd /usr/tmp/mnt; /sbin/restore xvf -) umount /usr/tmp/mnt mount /dev/hdb8 /mnt /sbin/dump 0f - /usr | (cd /mnt; /sbin/restore xvf -) umount /mnt You can repeat for any other filesystems that have installed data. 4c Use "dd" to clone the Win95 partition(s). Since Win95 likes to be installed in the first primary partition of a given disk, this will probably be /dev/hda1. Don't mount the target (/dev/hdb1); a tarball doesn't work. In fact, unmount the source if you have it mounted as a partition using linux's VFAT driver; you're going to sector-copy the partition. (This will not work if the partitions are not identical with respect to geometry.) dd if=/dev/hda1 of=/dev/hdb1 5. Shutdown and power off the source machine, and stick the newly-forged disk (pardon me while I wax poetic) back in the target machine. (If the jumpers on an EIDE disk were set to "slave", reset them to either "master" or "cable select".) 6. Use the RH 5 install floppy to boot (you won't need the CD) as follows: at the "boot:" prompt, type vmlinuz single root=/dev/hdaX where X is the root linux partition, probably 2. You may need to specify memory, i.e. vmlinuz single root=/dev/hda2 mem=128M if the source system had more memory. 7. Edit at least the following files to change the hostname, etc.: /etc/sysconfig/network: change name (and gateway if necessary) /etc/sysconfig/network-scripts/ifcfg-eth0: change IP /etc/lilo.conf: to change any boot options, such as memory, vga mode, or default OS to boot Remove /etc/ssh_host_key* If there are system-name-specific directories or mount points (e.g. /usr/vel/users1) change the names (don't forget /etc/fstab) to reflect the new hostname. 8. Run lilo to create a boot sector: /sbin/lilo -v and run /exp/rcf/common/hostInstall.sh to overwrite the previous SSH information. 9. Reboot to test that everything is functional. Rebuild the kernel if you feel it's worthwhile, and then shutdown and boot win95. 10. Under Win95, you'll need to change the following: RClick "My Computer"->Properties; change "Identification" to new hostname. Start->Settings->Control Panels->Network->TCP-IP: change DNS tabs to new IP, change hostname ID to new host. (change gateway if necessary) 11. Restart Win95 and verify that it is working correctly.