HOWTO Clone a Machine: Difference between revisions
Line 7: | Line 7: | ||
# cd / | # cd / | ||
# tar cpzf hostname.tgz / --exclude=/hostname.tgz --exclude=/proc --exclude=/lost+found --exclude=/mnt --exclude=/sys | # tar cpzf hostname.tgz / --exclude=/hostname.tgz --exclude=/proc --exclude=/lost+found --exclude=/mnt --exclude=/sys --exclude=/tmp | ||
* This will create a host image of about | * This will create a host image of about 700 MB. | ||
== Client/To Be Imaged Machine == | == Client/To Be Imaged Machine == |
Revision as of 18:52, 26 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 --exclude=/tmp
- This will create a host image of about 700 MB.
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
/dev/hda1 /boot 500M /dev/hda2 swap 2000M /dev/hda3 /tmp 4000M /dev/hda4 /
Add filesystems
# mke2fs /dev/hda1 # mkswap /dev/hda2 # mke2fs -j /dev/hda3 # mke2fs -j /dev/hda4
Mount drives:
# mount /dev/hda4 /mnt/gentoo # mkdir /mnt/gentoo/tmp # mkdir /mnt/gentoo/boot # mkdir /mnt/gentoo/proc # mount /dev/hda3 /mnt/gentoo/tmp # 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.
- Reset log files.
- Check /etc/make.conf
Make system dirs
# mkdir -p /mnt/gentoo-distfiles # mkdir -p /sys
Exit and umount drives, remove Gentoo CD, reboot the machine.