Quickest way to try it out:
install qemu-kvm (or just qemu if your machine doesn’t support hardware virtualisation), libvirt and virt-manager and make sure libvirtd is running
Make sure you have the relevant policy-kit
permission: org.libvirt.unix.manage
.
At time of writing, you’ll have these if you
are working from the console, but not if you are
ssh’d in, say.
polkit-auth --grant org.libvirt.unix.manage
should get you it.
sudo service libvirtd
start
” can start it with the wrong selinux
user, so you may have to reboot. To check, this
secon --pid $(pgrep libvirtd)
Should output
user: system_u
role: system_r
type: virtd_t
sensitivity: s0
clearance: s0:c0.c1023
mls-range: s0-s0:c0.c1023
rm -r ~/.virt-manager ~/.libvirtd
The solution to this is to configure the guest to have a tablet rather than a mouse (assuming that your guest OS supports the available tablet, which isn’t particularly likely).
These web pages are darcs repository, so if you install
darcs (sudo yum install darcs
), you can
then
darcs get --lazy http://www.chaos.org.uk/~jf/Virtual-machine-notes
You’ll need to install livecd-tools (sudo yum install livecd-tools). If you want something with more than the minimal set of rpms that I talk about here, you should consider installing the spin-kickstarts rpm
Now change to the directory created by darcs (Virtual-machine-notes) and have
a look around. You’ll want to edit the makefile to
change YUM_CACHE_DIR
to somewhere to keep a
cache of rpms downloaded the first time you make something,
and then
make livecd-fedora-webserver.iso
should make a livecd of a minimal machine with a webserver, and you can use the recipe above to make a virtual machine out of it.
The directory webserver-templates is used for files that you
want to install into the .iso; for
example webserver-templates/etc/sysconfig/network
would be copied to /etc/sysconfig/network
on
the virtual machine, so you may want to create it and
add HOSTNAME=…
to it.
Most files are just copied from the template directory into
the virtual machine, but if a file is
called something-or-other.append
our kickstart
file’s post-install script will append it
to something-or-other
in the virtual machine.
There are several ways of doing this — probably the best would be to assign a disk partition to the webserver virtual machine, but here I’m going to describe what I think is currently the easiest way.
dd if=/dev/zero of=webserver-state.img bs=1024 seek=$[256*1024] count=1
mke2fs -j -L var-www-html webserver-state.img
(answer y to “Proceed anyway?”, you do want to create a filesystem on something that isn’t a block-special device.
mount it somewhere
mkdir /tmp/webserver-state
sudo mount webserver-state.img /tmp/webserver-state/ -o loop
Put some web content into that directory
echo "First webpage" > /tmp/webserver-state/index.txt
Make sure the selinux security context is correct
chcon --recur -t httpd_sys_content_t /tmp/webserver-state/
You’ll get an error about not being able to change
the context of lost+found
; this is OK.
sudo umount /tmp/webserver-state/
This is important. Bad things can happen if you have two different OSs accessing the same filesystem at once.
Use an .append
file in the template directory
to modify /etc/fstab on the virtual machine:
echo "LABEL=var-www-html /var/www/html ext3 defaults 0 0" > webserver-templates/etc/fstab.append
Re-make the virtual machine
make livecd-fedora-webserver.iso
Make sure the virtual machine isn’t running, and
use virt-manager to add webserver-state.img
as
a new hard disc.