Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Howto setup a lab by cloning a drive over a network
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
bkmmd
n00b
n00b


Joined: 08 Oct 2003
Posts: 10
Location: Honolulu, HI

PostPosted: Thu Oct 21, 2004 4:44 am    Post subject: Howto setup a lab by cloning a drive over a network Reply with quote

I haven't seen this method published, but it worked well for me for rapidly cloning one computer to a number of similarly configured, inexpensive, custom-built computers. Same processor (Athlon XP), NIC, graphics cards, monitors, etc., all connected to a switch with a router running DHCP.

First, install and completely configure gentoo on one computer. This will be your master. I partitioned all my drives using the following scheme:
/dev/hda1 as ext2 for the /boot partition
/dev/hda2 as Linux swap space
/dev/hda3 as reiserfs for the / partition

Set up all users and groups, NFS, Samba, network mount points, KDE/Gnome, VNC, OpenOffice, ALSA, and whatever else you want cloned to all the other computers. If you have 12 computers to set up, save yourself a whole lot of time by doing as much setup as possible on the master computer.

Once the master computer is properly configured, do the following on the master computer:

1) Boot the master computer with the Gentoo Live CD (I used 2004.2).

2) if necessary, bring the ethernet interface up and load an ip address from the DHCP server (I have a Realtek 8139 card):
# modprobe 8139too
# net-setup eth0
(choose the DHCP option)

3) record the ip address of the master computer
# ifconfig
(let's say that the address of the master computer is 192.168.2.101)

4) set the root password for the master computer:
# passwd

5) start the ssh server
# /etc/init.d/sshd start

6) start the rsync server
# /etc/init.d/rsyncd start

7) create a mount point for the boot partition, then mount it:
# mkdir /mnt/boot
# mount /dev/hda1 /mnt/boot

8) mount the root partition:
# mount /dev/hda3 /mnt/gentoo

9) activate the swap space
# swapon /dev/hda2

Now, do the following on each computer you want to clone to:
1) Boot up the new computer with the Gentoo Live CD (I used 2004.2)

2) Configure the partitions (I used cfdisk)

3) Format the partitions:
# mke2fs /dev/hda1
# mkswap /dev/hda2
# mkreiserfs /dev/hda3

4) if necessary, bring the ethernet interface up and load an ip address from the DHCP server (I have a Realtek 8139 card):
# modprobe 8139too
# net-setup eth0
(choose the DHCP option)

5) create a mount point for the boot partition, then mount it:
# mkdir /mnt/boot
# mount /dev/hda1 /mnt/boot

6) mount the root partition:
# mount /dev/hda3 /mnt/gentoo

7) activate the swap space
# swapon /dev/hda2

8) copy the boot partition across the network:
# rsync -auv 192.168.2.101:/mnt/boot/ /mnt/boot
you'll need to accept the ssh key, then enter the root password that you set on the master computer

9) copy the root partition across the network:
# rsync -auv 192.168.2.101:/mnt/gentoo/ /mnt/gentoo
enter the root password that you set on the master computer

10) chroot
# chroot /mnt/gentoo /bin/bash
# env-update
# source /etc/profile

11) install the master boot record
# grub
> root (hd0,1)
> setup (hd0)
> quit

12) edit, minimally, the following files to set up the correct network address and hostnames:
# cd /gentoo/etc
# nano -w hosts
# nano -w hostname
# nano -w make.conf
# cd /mnt/gentoo/etc/conf.d
# nano -w net
you may need to edit other settings, if you have different video cards, NICs, monitors, etc.

13) exit from chroot
# ^D
(type control-D)

14) unmount the boot and root partitions:
# cd /mnt
# umount boot gentoo

15) shutdown
# shutdown -h now

16) reboot without the CD; and check that everything works properly.

Let me know if you have any suggestions for improving this process.

-- Brian
Back to top
View user's profile Send private message
Dhaki
Guru
Guru


Joined: 16 Jun 2004
Posts: 325
Location: Ticino - CH

PostPosted: Thu Oct 21, 2004 6:13 am    Post subject: Reply with quote

And use a stage4? Is a bit faster, you don't think?
Yes, use a stage4 after have partitioned the hd, and we must still cange the config file, but is an other solution.
Back to top
View user's profile Send private message
Kioshen
Tux's lil' helper
Tux's lil' helper


Joined: 23 Sep 2003
Posts: 109
Location: Montreal, PQ

PostPosted: Thu Oct 21, 2004 6:03 pm    Post subject: Reply with quote

It's a good idea but you could use scp instead of rsync ... it's just a suggestion ;).

Great tuto though !
_________________
-= United we share =-

Adopt an unanswered post today!
Why emerge -U will kill your Gentoo
Back to top
View user's profile Send private message
vibidoo
Guru
Guru


Joined: 27 Nov 2002
Posts: 409

PostPosted: Sat Oct 23, 2004 1:10 pm    Post subject: Reply with quote

nice tips :P
Back to top
View user's profile Send private message
user124
Tux's lil' helper
Tux's lil' helper


Joined: 02 May 2002
Posts: 86

PostPosted: Sun Nov 14, 2004 1:20 am    Post subject: Reply with quote

rsync is nice :)

i cloned over a net like this:

dd if=/dev/hda bs=512 | nc <othermachine> <port>

but rsync will save time....
Back to top
View user's profile Send private message
BlinkEye
Veteran
Veteran


Joined: 21 Oct 2003
Posts: 1046
Location: Gentoo Forums

PostPosted: Sun Dec 05, 2004 3:10 am    Post subject: Reply with quote

how long does this procedure take? i really suggest you take a look at the stage4 howto - i've wrote a small script myself: stage4
it's a very good idea - and really usefull for a backup. and it's small, about 700-1.4GB, depending on the packages you've got installed
_________________
Easily backup up your system? klick
Get rid of SSH Brute Force Attempts / Script Kiddies klick
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum