Setup Minimal Fedora 18 Server VM
Setup Minimal Fedora 18 Server VM
I will be creating this server on a VM initially before transferring the image to a physical server. If you just want to install directly on to the physical server skip to Install Fedora. I will describe how to transfer the image in a later post.
More detailed information can be found in the Fedora documentation, here: Fedora Installation Guide.
1. Create VM
First off, download the Fedora18 netinstall image.
I use Red Hat’s Virt-Manager with Libvirt as it makes it easy to keep track of all my VMs (rather than clutter up my profile with a load of aliases). It’s not required however - only a convenience - but if you’re not using it you can run the following commands in your terminal to set up a standalone VM:
$ qemu-img create -f qcow2 <image_name> <size> $ qemu-kvm -cpu <model> -smp <#cpus> -m <ram> \ > -drive file=<image_name>,if=virtio -display vnc \ > -cdrom <iso_image> -boot once=d
Then, to start the VM on subsequent occasions you can use:
$ qemu-kvm -cpu <model> -smp <#cpus> -m <ram> \ > -drive file=<image_name>,if=virtio,boot=on -display vnc
Note: If you create a VM in this manner you will not be able to avail of Libvirt’s features unless you convert it to be managed by Libvirt.1
To set up a VM using Virt-Manager select create new VM from the menu and follow the instructions in the dialogs as follows:
- Select the Fedora netinstall iso as your install media.
- Set ‘OS Type’ to Linux. As there is no Fedora 18 option as yet, we will go with the ‘Generic 2.65 or later kernel with virtio’, as Fedora 18 has virtio support.
- Set RAM and number of CPUs. How much RAM and the number of CPUs you will need depends on the intended applications, but it can easily be changed later so 1 CPU and 1GB is a good default.
- Create Disk. Set disk to qcow2 format2, this format supports internal snapshots which we will use later. To do this:
- Select ‘managed or other existing storage’ and create a new volume.
- Set the max and allocated size of your disk. The sizes again depend on the expected workload. If disk space is at a premium only allocate what you immediately need (1-2GB is fine), and set the max size so to give yourself some headroom later (say, 8GB). This can save a lot of space, especially with lots of VMs. Just be aware of the actual storage use of your VMs as you could run out quickly.
If you want the VM to target a particular hardware profile select Customise configuration before install and set the CPU topology.
You may want to change the default graphics from Spice to VNC (I was having some issues with latest spice version). Your Virt-Manager may not default to spice so this may be unnecessary.
2. Install Fedora
Start the VM from Virt-Manager and it will boot from the image.
Set the following options during the Fedora install if appropriate:
- Change Keyboard layout e.g. UK English (it’s really annoying when I forget that).
- At the Software selection screen choose ‘Minimal Install’.3The minimum configuration in Fedora includes some basic network tools like ssh and the ability to mount NFS shares. More information on the Fedora Wiki.
- Set your root password.4
If you are doing a minimal installation you will not be greeted with Fedora’s firstboot configuration tool, in which case you will have to perform some additional steps depending on your requirements. You may also want to create a snapshot at this stage.
* Create new non-root admin user
It’s not a good idea to use the root account all the time so create a new user account for administering the server:5
# useradd -G wheel <username> # passwd <username>
Install the NTP daemon in order to synchronise the time on the server:
# yum install ntp # systemctl start ntpd # systemctl enable ntpd
If you have more specific requirements (e.g. you want to use a different NTP server) the config files are located in
/etc/ntp.conf. In most cases using the default Fedora NTP servers is fine.
* Set up Hostname
The firstboot tool normally sets up the system’s hostname for you. To set it manually use the
# hostnamectl set-hostname <hostname> --static
Create a snapshot of your VM using the following commands:
# virsh snapshot-create-as <image_name> <snapshot_name> <comment>
Or, if you are not using Libvirt:
# qemu-img snapshot -c <image_name>
Your VM is now set up and you can ssh into your Fedora VM.
One last Tip, I would recommend subscribing to the Fedora Announce mailing list so you can be informed about security issues and new releases. Personally I just want security issues to hit my inbox so I use filters to be notified of just these issues rather than every release announcement.
A discussion of Libvirt is outside the scope of this tutorial. However, if there is interest I can do a follow up post on it. For info on converting a qemu image see:
When I did this myself I had deselected ‘allocate entire disk now’ not realizing the default image type is raw rather than qcow2. I only noticed after installing Fedora.
So to convert the image I used the
qemu-imgcommand as so:
qemu-img convert -O qcow2 Fedora18.img Fedora18.qcow2. Then removed existing disk from VM in Virt-Manager and added the qcow2 one.↩
If you’re unfamiliar with setting up Apache and MySQL you could select the ‘Web Server’ profile here which will set up a working web server configuration↩
Those familiar with Debian based distros may be asking why not use the
adduserscript here. But on Red Hat distros like Fedora the
addusercommand is simply a symlink to
useraddand has no extra functionality.↩