Archive

Uncategorized

I’m going to assume you already have a working KVM host, with virsh and a networking bridge setup. If not this is a great how-to to get KVM and virsh setup: http://www.charleslabri.com/installing-and-working-with-centos-7-x64-and-kvm/

First, download the KVM cloud image, go to getfedora.org for the latest image link.

# cd /opt/guests/disk
# wget http://download.fedoraproject.org/pub/fedora/linux/releases/test/22_Beta/Cloud/x86_64/Images/Fedora-Cloud-Base-22_Beta-20150415.x86_64.qcow2

I keep my images in /opt/guests/disk and isos in /opt/guests/iso/, you may keep them elsewhere.

Its a good idea to make a copy of this image for each VM because the VM will read and write to this image.

# cp Fedora-Cloud-Base-22_Beta-20150415.x86_64.qcow2 myf22.qcow2

The image is only 3GB by default, you probably want to expand the disk, so lets do that now (you can skip this step if you’re OK with 3GB):

# qemu-img create -f qcow2 -o preallocation=metadata f22tmp.qcow2 20G
# virt-resize –expand /dev/sda1 myf22.qcow2 f22tmp.qcow2
# mv f22tmp.qcow2 myf22.qcow2

Now you’ll need to create an iso for cloud-init. cloud-init will setup your ssh user and networking.

First create the user-data and meta-data files for the iso, update the configuration accordingly.

# cat meta-data
instance-id: myfedora22
local-hostname: myfedora22.domain.tld
network-interfaces: |
iface eth0 inet static
address 192.168.1.100
network 192.168.1.0
netmask 255.255.255.0
broadcast 192.168.1.255
gateway 192.168.1.1

# cat user-data
#cloud-config
users:
– name: travis
shell: /bin/bash
sudo: [‘ALL=(ALL) NOPASSWD:ALL’]
ssh-authorized-keys:
–   (insert ssh public key here)

Now generate the iso:

# genisoimage -output /opt/guests/iso/myf22.iso -volid cidata -joliet -rock user-data meta-data
# chown qemu:qemu /opt/guests/iso/myf22.iso

And create the VM:

virt-install –name MyF22 \
–ram 2048 \
–disk /opt/guests/disk/myf22.qcow2 \
–vcpus 2 \
–os-variant fedora21 \
–connect qemu:///system \
–network bridge:br0,model=virtio \
–cdrom /opt/guests/iso/myf22.iso \
–boot hd

After the VM boots you can press ^] to exit the console.

Now you can log into the VM:

ssh travis@192.168.1.100

Now the only issue is that on reboot, the cloud-init iso won’t be mounted and your networking settings won’t be provided to the guest. You will need to launch virsh and edit the XML description for the vm and add the source manually.

# virsh

virsh # edit MyF22

Find the disk section that describes the cdrom , it will look like this:

<disk type=’block’ device=’cdrom’>
<driver name=’qemu’ type=’raw’/>
<target dev=’hda’ bus=’ide’/>
<readonly/>
<address type=’drive’ controller=’0′ bus=’0′ target=’0′ unit=’0’/>
</disk>

Change the disk type to “file” and add a source tag with your cloud-init iso as the source:

<disk type=’file‘ device=’cdrom’>
<driver name=’qemu’ type=’raw’/>
  <source file=’/opt/guests/iso/myf22.iso’/>
<target dev=’hda’ bus=’ide’/>
<readonly/>
<address type=’drive’ controller=’0′ bus=’0′ target=’0′ unit=’0’/>
</disk>

This information was gathered from the following sources:

Advertisements

I recently downloaded the Fedora 21 XFCE4 Alpha iso and used the LiveUSB Creator to write the iso to a USB disk. When I tried to boot the USB image I hit an error I haven’t seen before:

vesamenu.c32: not a COM32 image

The quick fix is pretty simple, but not at all obvious: just provide the kernel and arguments manually:

vmlinuz0 initrd=initrd0.img root=live:CDLABEL=LIVE rootfstype=vfat ro rd.live.image quiet  rhgb rd.luks=0 rd.md=0 rd.dm=0 nomodeset

Just type the above in in the “boot:” prompt (all on one line) and it should boot the image to a desktop. Not sure why this happens but it is Alpha.