Skip to the content.

Automate Virtual Machine Linux Images


Author: Cesar Jorge Martínez

Site: https://cesarjorgemartinez.github.io/automate-virtual-machine-linux-images

Read the LICENSE GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007

Index

1. Introduction

This project helps to build automatically multiple Virtual Machine Images of Operating Systems that are compatible with different virtualization systems, as OpenStack, KVM, VirtualBox, VMware, VMware ESXI, Nutanix, etc.

The image formats that are generated are the following:

The virtualization system VirtualBox also uses the vdi format but it is not necessary since the VirtualBox itself converts the vmdk format into vdi.

You can deploy and boot directly these images in these virtualization systems without doing anything special or extra, thanks to the use of two systemd units:

These images are ideal to work as servers in Cloud, traditional or development environments, and is very useful to work with Docker, because the size of the image created is very small and clean. These images are builded with a Linux admin account provided as parameter at the time of build. The cloud-init software use other account provided as optional parameter at the time of build (not created because the cloud-init do this work at the first boot of the virtual machine) that by default is cloud-user. Also these images come with six network intefaces named eth0, eth1, eth2, eth3, eth4 and eth5 by default.

To work with this software you need Windows 10 64 bits and CygWin 64 bits to use Linux-Bash commands.

1.2. Tested software versions

This project has been tested with the following software versions:

2. Operating Systems that can be built

Actually you can build the following Operating Systems:

3. Create and configure the environment

You need to do the next tasks.

3.1. Install VirtualBox

Go to this URL https://www.virtualbox.org/wiki/Downloads and install latest VirtualBox for Windows. You need to ensure that in addition to installing VirtualBox you also install Oracle VM VirtualBox Extension Pack.

3.2. Install VMware Workstation Player

Go to this URL https://www.vmware.com/go/downloadworkstationplayer and install latest VMware Workstation Player for Windows.

This is optional step only if you will be use VMware or VMware ESXI.

3.3. Install CygWin 64 bits

To install CygWin 64 bits you need to do the following tasks:

When terminate these tasks, then:

3.4. Disable Windows Python installation

To prevent that CygWin use the Python installed in Windows (if exist), do the following to disable access to Windows Python installation:

3.5. Install needed CygWin packages

You need to do the following tasks:

3.6. Install Python system pip packages

To work with Python install basic pip packages in a system level:

TODO: Check if this tasks are obsoleted using last CygWin version. In a existing CygWin installation is not necessary.

3.7. Configure your Git environment to work with github

To work with https://github.com you need to do the next tasks. Example to use Git with SSH.

mkdir -p ~/.ssh
echo "StrictHostKeyChecking no
UserKnownHostsFile /dev/null
ServerAliveInterval 30
ServerAliveCountMax 3
ControlMaster no

Host github.com
  IdentityFile ~/.ssh/id_rsa_private_github
" > ~/.ssh/config
chmod 600 ~/.ssh/*
chmod 700 ~/.ssh
git config --system color.ui "true"
git config --system alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative"
git config --system user.name "<your user.name>"
git config --system user.email "<your user.email>"
git config --system http.sslVerify false

3.8. Howto generate SHA-512 password hashes with Python3 in CygWin command line

To generate SHA-512 password hashes you need to do the following tasks:

python3 -c 'import crypt; print(crypt.crypt("password", crypt.mksalt(crypt.METHOD_SHA512)))'

4. Getting started

After you have completed the previous sections, follow the next steps.

4.1. Clone and enter into the git root directory of this repository

Do the following tasks:

git clone git@github.com:cesarjorgemartinez/automate-virtual-machine-linux-images.git
cd automate-virtual-machine-linux-images

4.2. Install QEMU for Windows

The QEMU for Windows is needed to convert the vmdk to qcow2 image format. Launch this command:

download-and-install-qemu.sh

Then a QEMU for Windows installer window appears and do the following:

5. Build CentOS 7 Minimal image

This section explains howto build this Virtual Machine Image: Build CentOS 7 Minimal image.

6. Build CentOS 8 Minimal image

This section explains howto build this Virtual Machine Image: Build CentOS 8 Minimal image.

7. Build Ubuntu 20 Minimal image

This section explains howto build this Virtual Machine Image: Build Ubuntu 20 Minimal image.