The Gluster Blog

Gluster blog stories provide high-level spotlights on our users all over the world

KVM Clusters on the Fly : virt-install + Kickstart with static IPs


Automated cluster creation in VMs by scriptifying your KVM setups.

Automatically provisioning VM clusters comes up alot:

  • When you want to simulate / practice installing a clustered app or utility.
  • When you want to confirm that workload distribution is occuring properly.
  • To confirm that RPC and other communication intensive apps are configured correctly. 

A few weeks ago we went through setting up single node, rebuildable gluster VM directly from source using KVM.

But — the guilt of having to click the Virtual Machine Manager UI just to browse for a path to an ISO was unbearable… So… I finally forced myself how to figure out how to automatically deploy VMs using virt-install.
Enter KVM + virt-install + Kickstart

After trying it out – I can honestly say that KVM’s virt-install with kickstart on Fedora/RHEL is an excellent alternative to Vagrant (albeit KVM specific). See the vagrant gripes regarding overabstractions here, many of which are solved by kickstart’s much simpler paradigm.

However, the use of kickstart with KVM requires a little extra research because of its lower level and more powerful feature subsets.  In any case, I’m no virtualization expert and I got it working. Like most things, once you get a solid template to work from, its easy to incrementally learn and customize.

So here’s how to “scriptify” Fedora16 VM creation ~ using the virt-install utility (which is like a programmatic version of the Virtual Machine Manager).

virt-install –name VM-MyNewVM-1 –hvm –ram 1024 –disk path=/VirtualMachines/VM-MyNewVM-1.img,size=10,size=10 –network network:default –vnc –os-type=linux –os-variant=fedora16 –location -x “ks=

^^ Yup – thats it.  That ONE LINE of shell script created a 1GB VM for you with (if you include the “pastebin” script whose contents are below) disk partitions and a static ip.

(note, I’ve since updated this with some snippets from this excellent minimal fedora kickstarter template to make the install leaner)

# Kickstart file automatically generated by anaconda.
lang en_US.UTF-8
keyboard us
network --onboot yes --device eth0 --bootproto dhcp --noipv6
timezone --utc America/New_York
rootpw --iscrypted $6$9bRPXTZZMy0FNl2A$lgY.MS3pZ.0PVg4o3AQeJOydPwGVphdKT07tHlJUmdoRTz4UQQ/L54ny0QHkdubMquqkr4jw37DxmM0FL5kRn1
selinux --enforcing
authconfig --enableshadow --passalgo=sha512
firewall --service=ssh
# The following is the partition information you requested
# Note that any partitions you deleted are not expressed
# here so unless you clear all partitions first, this is
# not guaranteed to work
# Uncommented by j
clearpart --all
#Static IP address with gateway to the outside world - is the default KVM gateway.
network --bootproto=static --ip= --netmask= --gateway= --nameserver=
bootloader --location=mbr --timeout=5 --append="rhgb quiet"


Dayumnnn… How does this work?

Here’s whats embedded in the action packed virt-install command above:

  • –location: Direct access link to the to-be guest’s OS source code – not an ISO.  Get the correct root link to the  Fedora source tree.  This took more than a couple of google searches (evidently, the tree root is not Fedora/, but rather, Fedora/<arch>/os/.
  • “ks=” An http accessible(also this can be put on an NFS mount, but I find http / pastebin to be easier) kickstart file by stealing one from an existing fedora OS and putting it in a universally accessible location (either NFS or aURL on the web).   See for details on different ways to specify kickstarter scripts.
  • (Inside of the pastebin url, whose contents are below): Update the partitioning in your kickstarter template file so that partitioning happens automatically – that is – so that you don’t have to do any interactive disk partitioning.  For more in depth partitioning and a general understanding of the very powerful partitioning API in kickstart: See
  • Note this “-x” or “–extra-args” trick only works with source installations : if you want to automate installs from ISOs, you have to roll your own ISO with the kickstart embedded.  The reason is that qemu has no way to pass arguments into the kernel (credit: this thread).

So, in summary – to start with, the only parameters you need to modify above are – You can change:

    1. The fedora url, which points to the install tree for the particular OS your using (make sure and get the path right), and 
    2. The “pastebin” address above is just silly way to put up a kickstart script. 

Kickstarting your kickstart scripts…

So -> how do you build a create a kickstart script from scratch ? You don’t have to 🙂 … 

 Fedora/RHEL create a kickstart script for you when you do a manual install, just setup your first VM manually and use its autogenerated kickstart (which is created based on how you setup the OS, and written to /root/anaconda.cfg).

Once I ran this file, I found it wasn’t completely automated, i.e. the disk partitions were being requested by Fedora interactively.  To squelch this, I added the zerombr and the clearpart commands into the kickstart, In the end, my bare bones kickstart template looked a little like this…



KVM supports post scriplets and “ks_append” tags.  These essentially will run shell commands for you after the box is setup.  For example, you can append this to the end of your file. 

touch /tmp/file_i_created_after_kickstarting.txt

Testing that it worked: 

Make sure you got your static IPS and disks right —>

1) ifconfig | grep 192 #Confirm that the static ips were assigned properly from the kickstart script. 

2) df -h /root #Confirm that /root has several gigs of space in it. For fancier provisioning, replace the autopart (which I found was necessary, along with clearpart –all, to avoid the fedora interactive “Storage Device Warning” dialog.

Parting Words …

Virt-install can be used with a kickstart script to automate VM creation with static ips, disk partitions, memory, and a whole host of other goodies, right off the bat – and that means that virt-install can set up an entire cluster for you.  

Admittedly, the syntax is not as elegant and its not platform neutral as the similar vagrant tool…  But who cares?  You can customize it to any degree – both on the hardware side and the user space packages.  For example, there are  kickstarter templates for complex deployments, minimal servers and combining your kickstart script with shell commands to do installations of packages at the end of OS setup.


  • 06 Dec 2020
    Looking back at 2020 – with g...

    2020 has not been a year we would have been able to predict. With a worldwide pandemic and lives thrown out of gear, as we head into 2021, we are thankful that our community and project continued to receive new developers, users and make small gains. For that and a...

    Read more
  • 27 Apr 2020
    Update from the team

    It has been a while since we provided an update to the Gluster community. Across the world various nations, states and localities have put together sets of guidelines around shelter-in-place and quarantine. We request our community members to stay safe, to care for their loved ones, to continue to be...

    Read more
  • 03 Feb 2020
    Building a longer term focus for Gl...

    The initial rounds of conversation around the planning of content for release 8 has helped the project identify one key thing – the need to stagger out features and enhancements over multiple releases. Thus, while release 8 is unlikely to be feature heavy as previous releases, it will be the...

    Read more