OpenStack Part 2: Virtual machines

OpenStack is a Cloud Framework, it doesn’t define the system, it is just a collection of cloud tools that integrate together into whatever cloud system you need. As the OpenStack Architecture Design Guide suggests, there are a multitude of possibilities.

My idea is to go through that list one by one, unlocking more services and growing my little cloud as I go further. First up is a general purpose cloud. This includes the most basic OpenStack components, and should allow me to launch virtual machines, configure some basic networking, file and object storage, etc. This is basically an IaaS (Infrastructure as a Service) model.

At this point my idea is to run OpenStack in different VMs on my physical machine. This way, if something goes wrong and I mess up the installation too much, I can just restore a VM and start over. Additionally I can also create compute nodes at will (as far as the HW will allow it).
This means I’m going to need nested KVMs.
This short guide told me how to enable it. More information can be found here.

This is what you need to end up with:
$ cat /sys/module/kvm_intel/parameters/nested
Y

Creating virtual machines: https://wiki.debian.org/KVM
$ sudo apt-get install qemu-kvm libvirt-bin
$ sudo adduser panic1 kvm
$ sudo adduser panic1 libvirtd
$ echo "LIBVIRT_DEFAULT_URI=\"qemu:///system\"" >> .profile
$ sudo vim /etc/default/libvirt-guests

From this point forward I used the virt-manager application to create a VM (make sure you select to copy the host cpu information), and install a minimal debian or ubuntu on it. Repeat the same steps needed to enable nested VMs.

The same can ofcourse be achieved just the same with VMs in VirtualBox, running on a Windows machine.

OpenStack Part 1: Installing Debian on a RAID volume

For a quite a while I’ve had an old desktop machine gathering dust in a corner. It hasn’t been powered up in about a year, and I’ve even been thinking about what I could still do with it. The machine itself is still quite capable, it has a first generation core i7 CPU at 2.8GHz, and 4GB of RAM.
And recently a new option presented itself, my employer is starting up self-study gatherings and knowledge sharing sessions about “Cloud”. They’ve been doing these kinds of knowledge sharing gatherings for everything Linux Kernel for quite a while, the quadcopter was a project that I’ve started in light of that Linux Kernel knowledge sharing.
For this Cloud knowledge sharing I was thinking to set up OpenStack on this desktop machine. I ordered some more RAM, and a couple of SSDs to upgrade the machine so it can handle a few virtual machines.

There are couple of options when it comes to virualization, there are hypervisors like Hyper-V from Microsoft, ESXi from VMWare, XEN from Citrix, and there are virtualization tools like Qemu, KVM, VirtualBox, VMWare Player. From all this, only two options that are free, open source, and perfectly supported by OpenStack, stand out: Xen and KVM. Qemu fits into those requirements too, but this is an emulator, and performance is quite low, but fun can be had with this for very specific purposes later. I’ve decided to go with KVM running of off Debian, just because…

So there I go, installing Debian. I’ve configured the BIOS of my desktop to create a RAID0 volume with the two SSDs I bought, and followed this guide.
It took me alot longer than it should’ve but eventually it worked when I just put everything in one partition, without LVM (I didn’t know what it was at first).

I wasn’t too happy with this, I really like the idea of having my /home folder in a separate partition. And I’ve been reading up on this LVM thing, and this seemed like something that could come in really handy. LVM creates a layer on top of physical disks/partitions: a volume group. The volume group can be dynamically extended or reduced at will. Within that volume group you can create logical volumes, which are also easily extended/reduced. Within such a logical volume you typically have your favorite file system.

OK, now things start getting hairy, when setting up those LVM volumes during the Debian install everything that guide says still seems to apply. After that rescue step to install Grub, I reboot the machine. Grub comes up, Debian starts to boot, but ends up in an emergency mode:
Welcome to emergency mode! After logging in, type "journalctl -xb" to view system logs
The logs says something like:
debian systemd[222]: Failed at step EXEC spawning /bin/plymouth: No such file or directory

Plymouth seems to have nothing to do with the error here, plowing through the logs I noticed that all the disk checks on those LVM partitions are failing, and I believe this is more likely the cause, but I haven’t investigated this any further.

I came across this link instead. I reverted the RAID configuration in the BIOS, and I went with the software RAID option instead. This worked, Debian boots up completely, I have RAID, LVM.

But I used the guided partitioning from the Debian installer, the /home partition was 470GB large because of this, and I’d rather have a separate partition for the images and instances for the virtual machines I’ll be setting up next. But resizing a logical volume does require that the volume is not used (it’s file system mounted), and unmounting a filesystem is only possible when it’s not in use by anything or anyone.

Crtl-Alt F1 gets you in a terminal, log in with your user credentials:
$ pwd
/home/panic1
Normally when you are logging in as a user, the current working directory for the shell is your home dir
$ cd /
This changes the current working dir of the shell
$ sudo su
Become root
# systemctl isolate multi-user.target
This kills off the complete graphical desktop and all applications within
# fuser /home
Shows you which users are still using /home. Should return empty
# lsof /home
Lists open files. Should return empty
# umount /home
With no open files, /home can be unmounted
# lvreduce -L 100G -r /dev/PANICLOUD-vg/home
Resize the home volume and the filesystem to 100GB
# lvcreate -n images -L 100GB PANICLOUD-vg
Create new “images” logical volume
# lvcreate -n instances -L 100GB PANICLOUD-vg
Create new “instances” logical volume
# systemctl isolate default.target
This will start the graphical desktop again

Within the graphical desktop I used the Disks utility to format and mount the volumes to /opt/images and /opt/instances respectively.