[CentOS] how do i have a clone centos server

Mon Mar 31 13:30:22 UTC 2008
Toby Bluhm <tkb at midwestinstruments.com>

Mail Administrator wrote:
> Thnaks john,
>
> u gave me a  grt idea ..
> the second one
> seems quite interestin
>
> but i do have to get additional HDD and mirror my existing server which
> has jus one disk
>
>   

This was my procedure to mirror an existing single IDE disk RH4 system.

YMMV. No guarantees. Not tested on Centos5. May eat all your data and 
drink all your beer.

Make a total backup before doing anything.

IIRC the grub setup is what gave me the most problem.

Hopefully, someone will chime in to point out any flaws here.

------------
Current System/OS on single 10GB IDE disk
 /dev/hda2 = swap @ 1GB
 /dev/hda1 = / @ 9GB
Current system/OS is not in an LVM volume.

1. Install a 2nd identical disk as hdb
2. fdisk:
 /dev/hdb1 = 9000M ; /dev/hdb2 = 1000M ( rest of disk )
 part1 = type FD (raid)
 part2 = type FD (raid)
3. Create mirror device /dev/md10 for / with 2nd disk missing:
 mdadm --create --level=1 --force --raid-devices=1 /dev/md10 /dev/hdb1
4. mke2fs -j /dev/md10
5.  Create mirror device /dev/md11 for swap with 2nd disk missing:
  mdadm --create --level=1 --force --raid-devices=1 /dev/md11 /dev/hdb2
6. mkswap /dev/md11

  It may be safer to start step 7 from a rescue disk.

7. mkdir /z
8. mount /dev/md10 /z
9. cd /
10. dump -a0f - . | ( cd /z ; restore -xvf - )
11. Update pertinent lines in

/z/etc/grub.conf:
 splashimage=(hd0,0)/boot/grub/splash.xpm.gz
 root (hd0,0)
 kernel /boot/vmlinuz-2.6.9-11.EL ro root=/dev/md10 rhgb

/z/etc/fstab:
 /dev/md10       /       ext3    defaults        1 1
 /dev/md11      swap    swap    defaults        0 0

12. Shutdown
13. swap hdb & hda around
14. Boot RHEL4 linux rescue ; let system find/mount RHEL Installations
15. fdisk hdb to be identical to hda
16. chroot /mnt/sysimage
17. grub-install /dev/hda
18. grub-install /dev/hdb
19. Setup grub:
 grub
 root (hd0,0)
 setup (hd0)
 quit
20. Create new initrd(s) to include modules raid, scsi, lvm, etc needed 
at boot time:
 mkinitrd --with=raid0 --with=raid1 --with=raid5 --with=aic79xx 
/boot/initrd-2.6.9-22.EL.img.new
 mv /boot/initrd-2.6.9-22.EL.img /boot/initrd-2.6.9-22.EL.img.old
 cp /boot/initrd-2.6.9-22.EL.img.new /boot/initrd-2.6.9-22.EL.img
21. Reboot to normal startup on the new mirrored / & swap.

  Step 21 needs to boot cleanly. Step 22 will remove your last chance to 
revert to the old setup by installing the original boot disk as hda.
  If something goes bad here, may need to restore from backup.

22. Add in 2nd disk to md10 mirror set:
 mdadm --grow /dev/md10 --raid-devices=2
 mdadm --add /dev/md10 /dev/hdb1

23. Add in 2nd disk to md11 mirror set:
 mdadm --grow /dev/md11 --raid-devices=2
 mdadm --add /dev/md11 /dev/hdb2

You can monitor the sync process:

cat /proc/mdstat:
 md10 : active raid1 hdb1[2] hda1[0]
      8789632 blocks [2/1] [U_]
      [>....................]  recovery =  0.8% (77952/8789632) 
finish=5.5min speed=25984K/sec
unused devices: <none>

24. System will be at normal state when mirror sync is finished


-- 
Toby Bluhm
Alltech Medical Systems America, Inc.
30825 Aurora Road Suite 100
Solon Ohio 44139
440-424-2240