How to Clone a Node
From Nuclear Physics Group Documentation Pages
Jump to navigationJump to search
The procedure is a bit more involved than I had hoped. Put the harddrive of the destiny node in the second bay of node2. Then run the following, with "node3" replaced everywhere with node#
#Prepare drive: # remove the old partitions parted /dev/sdb rm 1 parted /dev/sdb rm 2 # create new partitions: parted /dev/sdb mkpart primary 1049kb 525MB parted /dev/sdb mkpart primary 525MB 100% # Boot Drive: mkfs.ext4 /dev/sdb1 e2label /dev/sdb1 boot test -r /mnt/boot || mkdir -p /mnt/tmp_boot mount /dev/sdb1 /mnt/tmp_boot rsync -avxHAX --numeric-ids /boot/ /mnt/tmp_boot # Check to make sure it is all there. # Rename node stuff cd /mnt/tmp_boot/grub sed 's/node2/node3/g' grub.conf > tmp.conf && mv grub.conf grub.conf.orig && mv tmp.conf grub.conf sed 's/node2/node3/g' menu.lst > tmp.lst && mv menu.lst menu.lst.orig && mv tmp.lst menu.lst cd / parted /dev/sdb toggle 1 boot umount /dev/sdb1 # Create Logical volume sets: pvcreate /dev/sdb2 vgcreate vg_node3 /dev/sdb2 lvcreate -L 8G -n lv_swap vg_node3 lvcreate -L 30G -n lv_root vg_node3 lvcreate -l 100%FREE -n lv_home vg_node3 mkswap -L swap /dev/vg_node3/lv_swap mkfs.ext4 -L root /dev/vg_node3/lv_root mkfs.ext4 -L home /dev/vg_node3/lv_home # Copy data: cd / test -r /mnt/tmp_root || mkdir -p /mnt/tmp_root mount /dev/vg_node3/lv_root /mnt/tmp_root mkdir mkdir /mnt/tmp_root/proc /mnt/tmp_root/dev /mnt/tmp_root/tmp chmod 1777 /mnt/tmp_root/tmp chmod 555 /mnt/tmp_root/proc mkdir /mnt/tmp_root/cgroup /mnt/tmp_root/net /mnt/tmp_root/srv /mnt/tmp_root/sys /mnt/tmp_root/boot rsync -avxHAX --numeric-ids bin data etc lib lib64 media misc opt root sbin selinux usr var /mnt/tmp_root mount /dev/sdb1 /mnt/tmp_root/boot mount -o bind /dev /mnt/tmp_root/dev mount -o bind /proc /mnt/tmp_root/proc chroot /mnt/tmp_root # grub-install --recheck /dev/sdb # === Should work but fails grub << EOF root (hd1,0) setup (hd1) quit EOF # Exit chroot exit # Fixup /etc cd /mnt/tmp_root/etc rm -f udev/rules.d/70-persistent-net.rule fixup mtab fstab sysconfig/network sysconfig/network-scripts sed 's/node2/node3/g;/vg_node3/d’ mtab > tmp.tmp && mv mtab mtab.orig && mv tmp.tmp mtab sed 's/node2/node4/g;' fstab > tmp.tmp && mv fstab fstab.orig && mv tmp.tmp fstab cd sysconfig sed 's/node2/node4/g;' network > tmp.tmp && mv network network.orig && mv tmp.tmp network cd network-scripts sed 's/10.0.0.2/10.0.0.4/g;/HWADDR/d;/UUID/d' ifcfg-eth0 > tmp.tmp && mv ifcfg-eth0 xx_ifcfg-eth0.orig && mv tmp.tmp ifcfg-eth0 sed 's/10.1.0.2/10.1.0.4/g;/HWADDR/d;/UUID/d' ifcfg-ib0 > tmp.tmp && mv ifcfg-ib0 xx_ifcfg-ib0.orig && mv tmp.tmp ifcfg-ib0 cd / umount /mnt/tmp_root/boot umount /mnt/tmp_root echo “ALL DONE - Shutdown the mother node, take out the 2nd hard drive, put it in the destiny node and boot that node. Repeat for next node.”
I'll put this in a script, someday.