I. Overview
This article aims to quickly clone all the content of another running Linux server, and then change the corresponding configuration file to quickly set another server with identical configurations.
2. Environment
This article uses the latest Redhat Linux 7.1 CDROM, the first installation disk to start, the cloned server is any Linux system, this article is also Redhat 7.1.
Step 3
1. On the cloned linux server A (192.168.0.1) that is already running, the IP address of server B (the tentative IP address is 192.168.0.2) can be rsh first.
A. Run/usr/bin/ntsysv on the server and select rexec, rlogin, and rsh.
B. Run #/sbin/service xinetd restart to start the three services.
C. run # echo "rexec">/etc/securetty; echo "rlogin">/etc/securetty; echo "rsh">/etc/securetty allow rsh in (only required by redhat 7.1)
D. Run # echo "192.168.0.2">/root/. rhosts on the server to allow the IP address to enter rsh without a password.
2. Set/etc/hosts on server A and add A record. You can obtain any host name, for example:
# Echo "192.168.0.2 test">/etc/hosts
In this way, address mismatch is avoided during forward/reverse DNS resolution. Otherwise, when you change from B rsh to A, B will prompt you with the "host address mismatch" problem.
3. use the first CDROM in Redhat Linux 7.1 to start machine B. We can enter "text" to quickly enter the text installation interface. Since it is not a real installation, no graphic interface is required, we only use the first CDROM to start and use rsh/tar to copy machine A. Press enter until the automaticpartitioning part appears, select "Continue" or "Manual Partition" and press Alt + F2 To Go To The character page.
4. Set the IP address of the NIC to ensure that the IP address can be pinged to 192.168.0.1.
Use the default Nic supported by Linux, such as 3com and Intel:
# Ping 192.168.0.1 after ifconifg eth0 192.168.0.2 up
Now test rsh. for Redhat 7.1, you must do the following:
# Cd/etc # echo "login 513/tcp"> services # echo "shell 514/tcp"> services
Then you can # rsh 192.168.0.1 without a password.
Note: If you use VA Linux 6.2.3, you do not need to do the above. You have not tried other versions yet. I believe RedhatLinux 6.2 does not need it.
5. Set the/dev/hda device so that you can manually perform fdisk/mke2fs
For Redhat Linux 7.1 to the character interface, you still cannot perform fdisk/dev/hda. The system prompts "cannot open the device". Now you can run rsh to 192.168.0.1 and do the following:
# (Rsh 192.168.0.1 cd/dev; tar cf-hda * sda *) | tar xvfp-
Now you can do # fdisk/dev/hda, and then use mke2fs to format all partitions into the ext2 file system. If a partition already exists in the hard disk and you want to delete it all quickly, you can do it # dd if =/dev/zero of =/dev/hda, and press ctrl + C to interrupt immediately, then, the partition table is cleared.
Note: If you use VA Linux 6.2.3, you do not need to do the above rsh part. You have not tried other versions yet. I believe Redhat Linux 6.2 is not required.
6. Preparations before Replication
Assume that your partition is/boot 25 M (/dev/hda1), SWAP 1G (/dev/hda2),/4G (/dev/hda3) after mke2fs for each partition and mkswap for the swap partition, do the following mount work.
# Cd/# mkdir hda3 # mount/dev/hda3 hda3 # cd hda3 # mkdir boot; mount/dev/hda1 boot
Note: if you cannot create A directory in the root directory, restart the Directory and then run it again. You do not need to copy the/dev/hda */dev/sda * file on A after the restart *, because you have already done fdisk/mke2fs.
7. Copy another machine
Run the following command:
# Cd/hda3 # (rsh 192.168.0.1 cd/; tar cf--- exclude proc.) | tar xvf-
Note: It is used to ensure that-it is not interpreted by bash shell as another character. If you have a directory other than proc that does not need to be copied, such as the data directory, the command is:
# (Rsh 192.168.0.1 cd/; tar cf--- exclude proc -- exclude data.) | tar xvf-
8. end work
# Cd/hda3 # mkdir proc # chroot. (chroot is used as the root directory to facilitate/sbin/lilo)
Change the corresponding file such as/etc/hosts,/etc/fstab,/etc/sysconfig/network,/etc/sysconfig/network-scripts/ifcfg-eth * to change/etc/lilo. conf, run/sbin/lilo, and restart.
9. FAQ
A. If your CDROM cannot be mounted after cloning, check whether the/dev/cdrom symbolic link is copied to the wrong device and use dmesg to check whether the CDROM device name on machine B is relinked.
B. If your source server uses an IDE hard disk and the cloned server uses a SCSI hard disk, you need to set it.
/Etc/modules. alias scsi_hostadapter aic7xxx in conf (If your SCSI chip class is), run mkinitrd to create an image file and update/etc/lilo. add initrd = To the conf file. Otherwise, you cannot boot from the SCSI disk.