Tag Archive for 'kvm'

Booting Fedora 24 cloud image with KVM

Fedora 24 is on the way, here’s how you can play with the cloud image on your local machine.

Download the image:
wget https://alt.fedoraproject.org/pub/alt/stage/24_RC-1.2/CloudImages/x86_64/images/Fedora-Cloud-Base-24-1.2.x86_64.qcow2

Make a new local backing image (so that we don’t write to our downloaded image) called my-disk.qcow2:
qemu-img create -f qcow2 -b Fedora-Cloud-Base-24-1.2.x86_64.qcow2 my-disk.qcow2

The cloud image uses cloud-init to configure itself on boot which sets things like hostname, usernames, passwords and ssh keys, etc. You can also run specific commands at two stages of the boot process (see bootcmd and runcmd below) and output messages (see final_message below) which is useful for scripted testing.

Create a file called meta-data with the following content:
instance-id: FedoraCloud00
local-hostname: fedoracloud-00

Next, create a file called user-data with the following content:
#cloud-config
password: password
chpasswd: { expire: False }
ssh_pwauth: True
 
bootcmd:
 - [ sh, -c, echo "=========bootcmd=========" ]
 
runcmd:
 - [ sh, -c, echo "=========runcmd=========" ]
 
# add any ssh public keys
ssh_authorized_keys:
  - ssh-rsa AAA...example...SDvZ user1@domain.com
 
# This is for pexpect so that it knows when to log in and begin tests
final_message: "SYSTEM READY TO LOG IN"

Cloud init mounts a CD-ROM on boot, so create an ISO image out of those files:
genisoimage -output my-seed.iso -volid cidata -joliet -rock user-data meta-data

If you want to SSH in you will need a bridge of some kind. If you’re already running libvirtd then you should have a virbr0 network device (used in the example below) to provide a local network for your cloud instance. If you don’t have a bridge set up, you can still boot it without network support (leave off the -netdev and -device lines below).

Now we are ready to boot this!
qemu-kvm -name fedora-cloud \
-m 1024 \
-hda my-disk.qcow2 \
-cdrom my-seed.iso \
-netdev bridge,br=virbr0,id=net0 \
-device virtio-net-pci,netdev=net0 \
-display sdl

You should see a window pop up and Fedora loading and cloud-init configuring the instance. At the login prompt you should be able to log in with the username fedora and password that you set in user-data.

Linux on Mac Pro with multiple drives

Update: This is possible using EFI only installs, yay!

The Apple Mac Pro at work has four bays for 3.5″ hard drives. My plan was to have OS X on the main drive with Linux on a secondary drive for virtualised environments. Native Linux could run on drives in the other slots if necessary.

I installed OS X on the primary drive and install rEFIt to manage all operating systems. So far so good.

Next I installed Fedora 12 on the secondary drive, but no matter the installation layout (whether MBR or GPT) I couldn’t for the life of me get rEFIt to boot it.

The install would be detected and come up in the pretty menu, but booting it resulted in a completely black screen. Nothing I tried seemed to fix the issue (for some reason even a single drive with Linux and EFI only wouldn’t work).

At my wits end I decided to Google the issue and came across an entry in the Debian wiki which explains my issue:

rEFIt assumes that you have only one disk drive. If you try and install linux onto a secondary drive, you will probably have found that rEFIt lets you try and boot your newly-minted linux partition/drive, only for you to get a “Missing operating system” error message. This is actually a Syslinux error message. What happens is that rEFIt looks on the primary disk for an MBR record, fails to find one (obviously!), so sticks the syslinux MBR onto the primary disk, and tries to boot that.

So the problem appears to be with rEFIt 🙁 Hopefully this will be fixed at some point, because being able to boot the OS from any drive on a Mac Pro would be oh, so handy.

In the mean time, I’ve installed Fedora on the same drive as OS X and will then use the other drives for virtualisation. I guess in theory putting /boot on a small partition on the primary drive with OS X might also work.

-c