Search code examples
linuxcloudvirtual-machinevirtualbox

Creation of a Linux Virtual Machine from command line


Is it possible to launch a script that would:

  • create one Virtual Machine
  • install Linux distribution(Lubuntu iso file) on it (with some required configuration: french keyboard, english languages, password etc)
  • and finally proceed some configuration inside the running VM (add guest Additions, install some programs, configure one specified static ip adress, etc...) ?

I am able to proceed all this steps graphically but it is really time consuming and i need to proceed all theses steps several times.

PS: i am aware of the clone option in VirtualBox but

  1. it suppose that i already have one VM with the specified options on my host. Since my goal is to launch a cloud on several machines, many of theses machine don't even one VM.
  2. When i make a clone i still have some configurations to proceed (change the static ip, chanhe the host name, etc ...

Solution

  • To create virtual machines from the CLI, I suggest you to use virsh, however you will need to install the following groups: Virtualization Client, Virtualization Hypervisor, Virtualization Platform, Virtualization Tools, also you need to start the libvirtd daemon.

    Regarding your question about changing some configurations to multiple VMs you can use ansible.