Automate virtual machines creation
From Mandriva Community Wiki
If you want to contribute, simply click on the edit tab. View the other pages to improve and maintain.
So the main purpose of this page is to depict how we could automate the procedure, how to be able to have the test system running on any virtual machine and finally stipple the full process. The final goal of this page is to be able to create an automated tool to create full installed and ready to run linux distributions under any virtualization environments (like VirtualBox, VMWare and Qemu mainly).
Test-Cloud is a project and is not currently used for Mandriva Linux development.
vmmaker is a project and is not currently used for Mandriva Linux development.Contents |
Principles
Run a script under any virtual machine that will (automatically) launch an installation of a Linux distribution on an empty disk:
- Launch a virtual machine
- From this running system
- Run a script that will:
- Mount the empty virtual disk
- Create partition table on this disk
- Format this disk
- Create/copy the wanted chroot on this disk (using Network and/or pre-defined ISO or archive)
- Chroot on this disk
- Make the disk bootable
- Copy needed pre-configured files (for networking mainly)
- Exit the chroot and unmount the virtual disk
- Ends
So, how it could run on any virtual machine ?
The trick is to run this script under the virtual machine we want, adding on it a new unparitioned virtual disk fully supported by this virtual machine.
Progress
What's actually done:
- A virtual machine to run the virtual machine creation
- A script that does:
- Ask for an hard disk device among a list of automatically guessed devices and excluding devices which have mounted partitions
- Ask for a filesystem with automatically guessing all available formats
- Create a partition table on the hard disk device with the appropriate size (guessed automatically)
- Create the wanted filesystem on this hard disk
- Ask for what kind of distribution and way to install
- Install a minimal mandriva distribution if the user choosed this way
- Use urpmi --auto so that nothing will be ask to the user
- Create network configuration
- Install a default urpmi media
- Install a minimal mandriva distribution if the user choosed this way
- Mount virtual filesystems /proc and /sys and special files directory /dev on the newly created partition
- Create /etc/fstab for the device
- Install grub on the MBR of the device
- Install the initrd (This is now done automatically threw urpmi)
- Make post-installation:
- Tries to install all rpm files present in the post/ subdirectory [current work]
Requirements:
This works only for SCSI devices but is now guessing for IDE devices too.
Virtual machines, virtual hard disks support:
- VirtualBox
- VirtualBox virtual disks (vdi)
- VMware virtual disks (vmdk)
- VMware
- VMware virtual disks (vmdk)
- Qemu
- raw format [not tested]
- qcow2 format
- VMware virtual disks (vmdk) [not tested]
Using VMware virtual disks with VirtualBox:
- Empty VMware virtual disks created by VMware
- Installation runs properly under VirtualBox
- Runs properly under VirtualBox
- Hard disk not found under VMWare [TODO: check what module is needed by VMWare to allow the disk to be recognized and put it in the initrd]
The VMware virtual disk format is support by these 3 virtual machines, so it could be a good start point.
The automated tool
Name proposal: vmmaker
Main purposes: Installs a distribution on an empty hard disk. Will allow to create new virtual machines for Test-Cloud in an easy way. Will also allow, in a theoretical way, to install any Linux distribution, only with the selected packages and in an easy way.
Using vmmaker threw a virtual machine
- You first need a virtual machine with an already installed distribution in it.
- Now you'll have to copy the vmmaker package into your working virtual disk.
- You can do so with using a shared directory.
- If you have Internet working from your virtual machine you can download it at this address: http://people.mandriva.com/~jdfrattini/vmmaker/
- Add a new empty virtual disk to your virtual machine
- Now boot on your virtual machine and install vmmaker. vmmaker will be installed in the /vmmaker directory.
- Enter the /vmmaker directory
- Launch vmmaker with: ./vmmaker
vmmaker will automatically guess your unused devices and available partition formats and will propose them to you.
Using vmmaker through a real physical machine
This will work only for new devices (empty partitions are not yet supported). Download the package, install it and follow the 3 last steps from the last section.
Advanced uses
vmmaker comes with a high range of configurations. It is theoretically possible to install any OS onto any hard disk into any virtual machine or even real hard disk into real machines.

