This page documents the procedure for creating a new KVM guest on a mayfirst server. This document is not complete! Do not use it to actually create a new KVM guest yet. = Creating a new KVM guest = 1. In these direcitons, the host (or ) refers to the name of the kvm host computer (e.g. negri, or bolivar, etc.). The guest (or ) refers to the name of the virtualized server you are creating. The examples use negri as the host and hay as the guest. 1. Install the [https://support.mayfirst.org/wiki/install_debian_kvm_manager kvm-manager] scripts (this should already be done on existing hardware) on the host 1. Run kvm-creator to create the new LV for the guest and the needed directory and files in /etc/sv/kvm/: {{{ USAGE: kvm-creator create|destroy|demo guestname [volumegroup [disksize [ram [tap [mac] ] ] ] }}} 1. Initially it's a good idea to run the demo. This will give you a breakdown of how the server will be created. {{{ kvm-creator demo }}} 1. After determining the settings you want the machine to have, run the demo command and then the 'create' command. {{{ EXAMPLE WITH OUTPUT: 0 negri:~/preseed-repo/squeeze# kvm-creator demo hay vg_negri0 15G 512 NAME : hay VG : vg_negri0 SIZE : 15G RAM : 512 TAP : tap5 MAC : 02:01:00:00:00:06 DISK : /dev/mapper/vg_negri0-hay 0 negri:~/preseed-repo/squeeze# kvm-creator create hay vg_negri0 15G 512 Adding user `hay' ... Adding new group `hay' (1005) ... Adding new user `hay' (1005) with group `hay' ... Creating home directory `/home/hay' ... Copying files from `/etc/skel' ... Logical volume "hay" created 0 negri:~/preseed-repo/squeeze# }}} 1. Add at least one user to the access list for the new KVM guest's serial console 1. Monkeysphere way: Add a uid to the /home//.monkeysphere/authorized_user_ids file or copy /root/.monkeysphere/authorized_user_ids to /home//.monkeysphere 1. SSH key way: Add an SSH key to the /home//.ssh/authorized_keys file 1. Rebuild the monkeysphere-controlled SSH authorized_keys files: {{{ monkeysphere-authentication u USERNAME }}} 1. If you are installing an operating system to the new KVM guest: 1. Customize the details for the server you are installing 1. Edit /root/preseed-repo/squeeze/server-specifics.cfg with the new server's info. You will need to have chosen the hostname at this point. The a simple file currently looks something like: {{{ d-i netcfg/get_hostname string algernon # Static network configuration. d-i netcfg/get_nameservers string 209.51.163.29 d-i netcfg/get_ipaddress string 209.51.180.21 d-i netcfg/get_netmask string 255.255.255.240 d-i netcfg/get_gateway string 209.51.180.17 # Set Volume Group Name d-i partman-auto-lvm/new_vg_name string vg_algernon0 }}} * This is the time where you want to check the [wiki:ip_allocation] page, claim a new IP and look at the other network settings you will need for this device. * Now would also be a good time to [https://members.mayfirst.org/cp go to the control panel] and set up a DNS Entry for this server. This should me done in the "mayfirst.org hosting order. That way, when it comes time to use the new kvm guest, you will have workin nameservice to it. 1. Change into /usr/local/share/ISOs: {{{ cd /usr/local/share/ISOs }}} 1. Run: {{{ 0 negri: di-maker hay-squeeze.iso /root/preseed-repo/squeeze/preseed.cfg /root/preseed-repo/squeeze/server-specifics.cfg /root/preseed-repo/squeeze/late_command --2011-03-05 15:22:04-- http://ftp.nl.debian.org/debian/dists/stable/main/installer-amd64/current/images/netboot/debian-installer/amd64/linux Resolving ftp.nl.debian.org... 130.89.149.21, 2001:610:1908:a000::149:21 Connecting to ftp.nl.debian.org|130.89.149.21|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 2417312 (2.3M) [application/octet-stream] Saving to: “linux” 100%[=====================================================================>] 2,417,312 1.81M/s in 1.3s 2011-03-05 15:22:05 (1.81 MB/s) - “linux” saved [2417312/2417312] --2011-03-05 15:22:05-- http://ftp.nl.debian.org/debian/dists/stable/main/installer-amd64/current/images/netboot/debian-installer/amd64/initrd.gz Reusing existing connection to ftp.nl.debian.org:80. HTTP request sent, awaiting response... 200 OK Length: 6747069 (6.4M) [application/octet-stream] Saving to: “initrd.gz” 100%[=====================================================================>] 6,747,069 3.40M/s in 1.9s 2011-03-05 15:22:07 (3.40 MB/s) - “initrd.gz” saved [6747069/6747069] FINISHED --2011-03-05 15:22:07-- Downloaded: 2 files, 8.7M in 3.2s (2.76 MB/s) 38743 blocks 38772 blocks Enabling BIOS support ... xorriso 0.5.6 : RockRidge filesystem manipulator, libburnia project. 0 negri:/usr/local/share/ISOs# }}} 1. Create a symlink called cd.iso in the /home//vms// directory with a target of the desired ISO: {{{ ln -s /usr/local/share/ISOs/.iso /home//cd.iso }}} 1. Tell runit to start the guest automatically {{{ update-service --add /etc/sv/kvm/ }}} 1. Log into the new guest via ssh: {{{ ssh @.mayfirst.org }}} 1. Start screen: {{{ screen -x}}}. You should see a grub menu waiting for you to hit enter on the installer. 1. After hitting enter, watch the installer fly by. 1. Before it completes, be sure to delete the symlink you created to the cd.iso installer (as root): {{{ rm /home//vms//cd.iso }}} 1. Login with root and no password 1. The preseed file will leave all leftover space on the disk in a logical volume called "delete". You can remove this logical volume (so the extra space is available to enlarge other logical volumes): with: {{{ lvremove vg_0/delete }}} Replace with the name of the server, e.g.: {{{ lvremove vg_hay0/delete }}}