HOWTO Clone a Machine: Difference between revisions
No edit summary |
|||
Line 47: | Line 47: | ||
* Static ip address. | * Static ip address. | ||
Exit and umount drives, reboot the machine. | Exit and umount drives, remove Gentoo CD, reboot the machine. |
Revision as of 18:40, 3 October 2006
Using standard Linux tools, this guide explains how to copy a working Linux machine onto a brand new machine, in less than an hour.
Server/Golden Machine
First, create an image of a good working system or use an existing image, if you have one. At Research we have images stored at musashi:/export/mirror/image/fresh-deployable-gentoo-images
- Do this as root.
# cd / # tar cpzf hostname.tgz / --exclude=/hostname.tgz --exclude=/proc --exclude=/lost+found --exclude=/mnt --exclude=/sys
- This will create a host image of about 1.5 GB.
Client/To Be Imaged Machine
Boot the machine you want the image deployed on with a minimal Gentoo CD. Mount that hard drive and partition it appropriately.
# fdisk /dev/hda
Add filesystems
# mke2fs /dev/hda1 # mkswap /dev/hda2 # mke2fs -j /dev/hda3
Mount drives:
# mount /dev/hda3 /mnt/gentoo # mount /dev/hda1 /mnt/gentoo/boot # swapon /dev/hda2 # mount -t proc proc /mnt/gentoo/proc
Copy over the hostname.tgz file onto this machine.
# scp root@hostname:/hostname.tgz /mnt/gentoo
Extract it into the root of the new machine /mnt/gentoo
# cd /mnt/gentoo # tar -xzf hostname.tgz
Chroot into the new environment.
# chroot /mnt/gentoo /bin/bash # env-update && source /etc/profile
Verify /boot/grub/grub.conf and /etc/fstab
Setup grub on the hard drive:
# grep -v rootfs /proc/mounts > /etc/mtab # grub-install /dev/hda
Finish Configuring the machine:
- Set a root password.
- Set the hostname.
- Static ip address.
Exit and umount drives, remove Gentoo CD, reboot the machine.