Retrieve an installation disk, e.g. Centos 6.4:
$ wget http://mirror.corbina.net/pub/Linux/centos/6.4/isos/x86_64/CentOS-6.4-x86_64-minimal.iso
Create an empty image:
$ IMG_NAME=centos-6.4-i386 $ qemu-img create -f qcow2 ${IMG_NAME}.qcow2 12G
Boot with kvm. Note that you should mention virtio for best performance. Replace the latter :50
for VNC with any free VNC display number:
$ qemu-kvm -drive file=${IMG_NAME}.qcow2,if=virtio -net nic -net user -cdrom CentOS-6.4-x86_64-minimal.iso -m 1G -boot d -vnc 0.0.0.0:50
To see busy VNC display numbers you can run:
$ ps aux | grep vnc | sed -r 's/.*vnc [0-9.]+:([0-9]+).*/\1/' | sort -n
If you are running the instance on remote computer, use a VNC client such as Vinagre and connect to it.
Follow installation instructions. Create single partition and do not pay attention to “no swap partition” complains.
That’s better to configure network during installation. You should use DHCP and agree to connect automatically. However, network can be tuned after installation.
Confirm to reboot after installation.
RHEL or CENTOS
Login as root. Tune the network (that’s important that configs do not refer to MAC addresses):
# cat > /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE="eth0" BOOTPROTO="dhcp" ONBOOT="yes" (Ctrl+D) # /etc/init.d/network restart
and check the network:
# ifconfig eth0
eth0 should have an IP.
Now do
# yum clean all # yum update -y
Perform some small changes:
# sed --follow-symlinks -i 's/^SELINUX=.*$/SELINUX=disabled/' /etc/selinux/config # echo > /etc/sysconfig/iptables # rm -f /etc/udev/rules.d/*-persistent-*
and halt the system.
Ubuntu
I recommend to use Ubuntu for Cloud (http://www.ubuntu.com/download/cloud).
Login as user you have created during installation. Issue
$ sudo bash
Set a sample password with the `passwd` command.
Upgrade the system.
# apt-get upgrade
Perform some small changes:
# rm -f /etc/udev/rules.d/*-persistent-*
and halt the system.
If you are not satisfied by image real size, you can recompress it. This procedure can reduce image size a bit.
$ mv ${IMG_NAME}.qcow2{,.bak} $ qemu-img convert -O qcow2 ${IMG_NAME}.qcow2.bak ${IMG_NAME}.qcow2