Thursday, October 10, 2013

VirtualBox Autosave Autostart of vms

This assumes that you are the only user on your system if not then you can try my Phpvirtualbox  guide. You do not need your favorite sudo utility nor running su just to set your vms to auto. Enable the systemd service one time and use VBoxManage to set your vms to auto.


 Download the script that will handle the vms.
  •  wget https://raw.github.com/Jetchisel/VBoxAutostart/master/systemd-vboxinit 
Copy it to your ~/bin directory.
  •   cp -v systemd-vboxinit ~/bin   
Make it executable.
  •  chmod ug+x ~/bin/systemd-vboxinit 

Change the group to vboxusers
  •  chgrp vboxusers ~/bin/systemd-vboxinit 


2. Download the unit file that will execute your script during boot/restart/shutdown of the host.
  •  wget https://raw.github.com/Jetchisel/VBoxAutostart/master/VBoxAutostart@.service 
Replace The ExecStart and ExecStop part with your "$HOME"/bin as the PATH
  •  cp -v VBoxAutostart@.service /usr/lib/systemd/system 
 Start that service.
  •  systemctl start VBoxAutostart@your-user-name.service 
Enable it .
  •  systemctl enable VBoxAutostart@your-user-name.service 
Check the status.
  •  systemctl status VBoxAutostart@your-user-name.service 
your-user-name is your user name not mine :-)

 3. Choose your vms that you want to autostart and autosave during boot/restart/shutdown of your host.

Get the names of the vms.
  •   VBoxManage list vms  
Set it to auto so the script will handle the autostart and autosave of the vm.
  •  VBoxManage setextradata YOUR-VM-NAME pvbx/startupMode auto 
Get the status.
  •   VBoxManage getextradata YOUR-VM-NAME pvbx/startupMode 

       Set it to manual if you dont want your vms to be handled by the script.
      •  VBoxManage setextradata YOUR-VM-NAME pvbx/startupMode manual 
      Set it to empty 'No value' the same thing it will be ignored by the script.
      •   VBoxManage setextradata YOUR-VM-NAME pvbx/startupMode 
        •   You can use the ExtraData script from the zip file below to manage your vms. 

          4. To access your vms.
          •  rdesktop localhost:1234 

          where 1234 is the port number which you can set via the gui or via VBoxManage.

          A gui app which you can use is krdc for Kde and   gnome-rdp for Gnome.

          The zip file from github. https://github.com/Jetchisel/VBoxAutostart/archive/master.zip

          I have package this stuff and it's in OBS now as an rpm. Look for systemd-vboxinit

           NOTE: if you have the Phpvirtualbox solution then you do not need this thus it can conflict with each other.

          2 comments:

          1. I think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article. car dvr

            ReplyDelete
            Replies
            1. Hi,

              Thanks for dropping by and sorry for not replying earlier :) also im glad that this is helpful to you.

              Delete