From Fedora Project Wiki

Getting Started

If you're new to cloud or don't have access to an online provider, this tutorial is for you. You would think, "Download the image and boot from it." would be all you need to get started. However, as soon as you attempt this you get something non-bootable.

Fedora cloud images (and many others) require the cloud-init service which is typically provided by your cloud provider. We need to emulate that in order for our image to boot. To emulate that we'll create a "seed.img" that has the user and meta data required.

Requirements

This tutorial presumes you're running Fedora 20 and have the needed resources to run a cloud image.

Getting the images

Download either the latest [[][stable image] or the latest [[][rawhide] image if you want to do some testing. While those are downloading we'll install the required packages.

Installing Libs

In order to generate the seed image we need, you need to have 'libguestfs-tools-c' installed.

sudo yum install libguestfs-tools-c

This will give you the tools you need to get started.

Create scaffolding

Once the basic tools are installed, we need to gather/generate some other assets in order to boot the image. I'm calling this a 'scaffolding' because I don't have a better word for it.

Generating the seed.img

The seed.img contains the needed meta-data that EC2 usually provides the image. To create the seed img you need two files (in their own directory): user-data and meta-data. See below for the contents of each.

inside a meta/ directory:

user-data:
       #cloud-config
       password: password
       chpasswd: { expire: False }
       ssh_pwauth: True
meta-data:
       instance-id: iid-123456
       local-hostname: testCloud

Once those files are created, you generate the seed image with virt-make-fs. Run:

virt-make-fs --type=msdos --label=cidata meta/ /tmp/seed.img
Get the correct kernel and initrd

In order to boot the image, we have to modify some boot parameters from outside the image. In order to do this we boot with an outside kernel.

To get the correct kernel and initrd, run the following command on the downloaded cloud image.

virt-builder --get-kernel <path to downloaded image>

Now you have everything you need to boot a cloud image locally.

Launching

To boot your image, run the following command:

/usr/bin/qemu-kvm -m <int for ram you want> \
    -drive file=<cloud.qcow2>,if=virtio \
    -drive file=<path to seed.img>,if=virtio \
    -kernel <path to downloaded kernel> \
    -initrd <path to downloaded initrd> \
    -append 'root=/dev/vda1 ro ds=nocloud-net' \
    -redir tcp:2222::22 -redir tcp:8888::80

This will boot your image, and will open up a qemu window. The '-redir' options allow local ports on your host machine to be forwarded to the cloud image. This way you can ssh into the image and view anything that httpd might be serving. You can also add

-no-graphic

to the command to boot without a GUI (useful for ssh testing).