# Creating a New FreeBSD VM Guest on Ganeti ## Create the Guest VM Use the silly script ~root/do-add ``` ./do-add vm0 100 2 work0.psg.com ``` Which looks like ``` #!/bin/sh # makeVM node diskGB ramGB nameFQDN NODE=$1 DISK=$2 RAM=$3 NAME=$4 gnt-instance add \ -t plain \ -o noop \ -s ${DISK}G \ -B maxmem=${RAM}G,minmem=$((${RAM}/2))G \ -n $NODE \ -H kvm:vnc_bind_address=0.0.0.0 \ --no-install \ --no-start \ --no-ip-check \ --no-name-check \ ${NAME} ``` ## Start the Guest VM With the CD-ROM Mounted You should get the latest and greatest ISO of the opsys you wish to install and put in in /ISOs on the node to which you are installing. And then ``` gnt-instance start -H boot_order=cdrom,cdrom_image_path=/ISOs/FreeBSD-10.0-STABLE-i386-20140712-r268571-disc1.iso work0.psg.com ``` ## Find the Console Port of the Running VM ``` gnt-instance info work0.psg.com | grep console ``` Which will produce something similar to ``` console connection: vnc to vm1.sea.rg.net:11024 (display 5124) serial_console: default (True) ``` You are interested in the 11024, not the 5124. ## Tunnel VNC over SSH From your laptop ``` ssh -N -L 5900:127.0.0.1: ``` Of course you will need an account on the vm node ## Run VNC to the Guest VM From your laptop, use a VNC client to connect to localhost, display 0, password as set for the VM host. ## Do the Install It should have booted the CD-ROM. Now do the install of the OpSys in your usual fashion. When it finishes, if you just let it reboot, it will likely just boot the CD-ROM again. So restart the guest by ``` gnt-instance reboot work0.psg.com ``` ## DRBD Mirror Guest to CLuster You will likely want the reliability of mirroring the guest to another node in the cluster. I have a script I use ``` #!/bin/sh # do-drbd guest-name to-node gnt-instance shutdown $1 gnt-instance modify \ -t drbd \ --no-wait-for-sync \ -n $2 \ $1 gnt-instance start $1 ```