Netboot Imaging
Netboot Imaging
OUT OF DATE
Please Look at Cloning for single machines and Multicast for cloning a entire lab
Quick Clone
sudo /var/local/ecc/120G/clone.sh #Clone resizes the windows partition to TOTAL_SPACE * 0.95. sudo /var/local/ecc/120G/clone-noresize.sh #Does not resize partition.
Manual Clone
#!/bin/bash dd if=/dev/zero of=/dev/sda count=256 bs=1M #Zero out the first 256MiB. dd if=/var/local/ecc/120G/mbr.bin of=/dev/sda bs=512 count=1 #Copy the MBR, which includes the partition table. sync #Sync writes hdparm -z /dev/sda #Notify the kernel of the partition table changes. dd if=/var/local/ecc/120G/ecc-p1.dd of=/dev/sda1 status=progress bs=1M #Copy the first parition, the windows bootloader sync dd if=/var/local/ecc/120G/ecc-p2.dd of=/dev/sda2 status=progress bs=1M #Copy the second partition, the root filesystem sync #Calculate the amount of reserved space. TOTAL_SPACE - (TOTAL_SPACE * 0.5) FREE_SPACE=`parted /dev/sda unit B print free | grep 'Free Space' | tail -n1 | awk '{print $3}' | sed 's/.$//'` TOTAL_SPACE=`parted /dev/sda unit B print free | grep 'Free Space' | tail -n1 | awk '{print $2}' | sed 's/.$//'` RESERVED_SPACE=`awk "BEGIN {printf \"%.0f\n\", $TOTAL_SPACE*0.05}"` echo "Total Space: ${TOTAL_SPACE}" echo "Reserved Space: ${RESERVED_SPACE}" PART_TWO=`awk "BEGIN {printf \"%.0f\n\", $TOTAL_SPACE-$RESERVED_SPACE}"` echo "Partition size: ${PART_TWO}" #Resize partition 2 parted -s /dev/sda "resizepart 2 ${PART_TWO}B" sync #Resize the filesystem to match the partition. ntfsresize -ff -v /dev/sda2
Ansible
#Zero out drive ansible labd_linux -m shell -u root -a "dd if=/dev/zero of=/dev/sda bs=1M count=1024" #Copy MBR ansible labd_linux -m shell -u root -a "dd if=/var/local/ecc/mbr.bin of=/dev/sda bs=512 count=1" #Sanity Check ansible labd_linux -m shell -u root -a "fdisk -l /dev/sda" #Copy partition 1 ansible labd_linux -m shell -u root -a "ntfsclone --restore-image --overwrite /dev/sda1 /var/local/ecc/ecc-p1.img" #Copy partition 2 ansible labd_linux -m shell -u root -a "ntfsclone --restore-image --overwrite /dev/sda2 /var/local/ecc/ecc-p2.img"
Tags
None
Subscribers
None
- Last Author
- • igrant
- Last Edited
- Jul 5 2018, 2:41 PM