START ALL VIRTUAL MACHINES ON BOOT CENTOS

                            START ALL VIRTUAL MACHINES ON BOOT CENTOS 

Image result for virtualbox
INTRODUCTION
As we know that automation is increasing its demand over the past few years. Keeping it in mind we are presenting a real-time scenario task to you. In this article, we are going to learn that how can we automate virtual box to start at the time of base machine boot along with all its virtual machine.


In the above picture, we have a virtual machine name test is currently running but I want to set this to happen automatically. For that perform the following steps

#vi /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
/usr/bin/virtualbox
VBoxManage startvm "test" --type headless

/etc/rc.local is the last file which runs after the boot process in Linux. So we put our commands here to automatic run virtual box. Kindly keep in mind to give absolute path of any command which you use here.

Another method is that you can put the same commands in another file i.e .bashrc of root but the problem is that everytime when you login through root then it will open and so many sessions will open. This method is not suggested. 

You can verify the VirtualBox is running or not by the top command. You will get PID of virtual-box


Thanks !! :)

Comments