Sunday, November 17, 2013

Vboxwebsrv with systemd on openSUSE

This works if you need to restart vboxwebsrv using systemd in openSUSE. Some folks  will raise some eye browse with this configuration for sure :-). The USER-NAME in the entry below is the username of the user who will access vboxwebsrv.

Create a unit file in /etc.

  •  /etc/systemd/system/VBoxWeb.service 

why etc? because according to the man pages somewhere that if a local admin will make a unit file it should be in /etc because the order of which the unit file to be executed. Meaning if you have conflicting unit files in /usr and in /etc then the latter will be prioritize. Note that packages (*.rpm) unit files are in /usr.

Put the entry below inside that unit file.

 Description=VirtualBox Web Service

 ExecStartPre=/bin/bash -c 'if [[ -e $PIDFile ]]; then rm -f "$PIDFile"; fi'

 ExecStart=/usr/bin/vboxwebsrv --pidfile "$PIDFile" --background


 This is not a shell script! That is what systemd folks will say for sure ;-). The ExecStartPre in that unit file is removing (deleting) the pid file so when vboxwebsv should restart  you will not get any errors. The EnvironmentFile entry is like sourcing a shell script. In this case it is sourcing the unit file itself, hence the variable PIDFile. Note that with systemd 208 which is the default fro 13.1 the ExecPre line in that unit file is not required anymore, seems systemd is much smarter now a days! :-). 12.3 below you might still need it.

Create the temporary files and directories.

  •  echo "d /run/VBoxWeb 0755 USER-NAME vboxusers" > /etc/tmpfiles.d/VBoxWeb.conf 

  •  mkdir /run/VBoxWeb 

Change the permission.

  •  chown USER-NAME:vboxusers /run/VBoxWeb 

  •  chmod 755 /run/VBoxWeb 

Disable the vboxwebsrv service that came with VirtualBox package.

  •  chkconfig vboxweb-service off 


  •  systemctl disable vboxweb-service.service 

Start your newly created (unit file)  Daemon.

  •  systemctl start VBoxWeb.service 

Enable your newly created (unit file)  Daemon.

  •  systemctl enable VBoxWeb.service

This is very useful when you are using phpvirtualbox and you are restarting the vms every once in a while.


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 
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 
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.

          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.

          Monday, September 23, 2013


          Download the latest release in 

          Unpack that tar ball. I choose to install in /data/apache2.
          •  tar -zxvf phpsysinfo-"$version"-tar.gz -c /data/apache2
          Set up sysinfo.
          •  cd /data/apache2/phpsysinfo-"$version" 
          •  cp -v phpsysinfo.ini 
          Set permission.
          •  chown -Rv wwwrun:www /data/apache2/phpsysinfo-"$version" 

          Add an entry to apache2 config
          •  vi /etc/apache2/conf.d/phpSysInfo.conf 

          Add the entry below

            Alias /sysinfo /data/apache2/phpsysinfo-"$version"

            <Directory /data/apache2/phpsysinfo-"$version">
               Options Indexes MultiViews FollowSymLinks
               Order allow,deny
               Allow from all


          Again the only thing to adjust to your set up is /data/apache2.

          Restart apache2
          •  systemctl restart apache2.service 

          Type the url on your browser
          •  localhost/sysinfo 

          Thursday, September 19, 2013

          phpVirtualBox on openSUSE reloaded

          phpVirtualBox home page has been moved from google to sourceforge it is in  You will need to install VirtualBox since it is just a front end.  before you can use this app. Refer to my guide on how you can install vbox.  After you have installed vbox you will install a web server. We will use apache2 as an example. You can either use yast2 software management to install the lamp_server pattern and some php packages or use our friend zypper.

            In this setup i choose to install to a different directory than /srv/www/htdocs. So just in case something unrecoverable happens :P in my system i will not delete the directory where phpvirtuablox resides. Here i choose /data/apache2. You can put it any where you like just replace the config entry in apache2.

            To install the packages using zypper
              •     zypper in patterns-openSUSE-lamp_server php5-soap      

                 Create an entry for apache2
                  •     vi /etc/apache2/conf.d/phpvirtualbox.conf   

                  The only thing you need to replace to meet your setup is    /data/apache2  the rest is as-is.

                    Alias /phpvirtualbox  /data/apache2/phpvirtualbox

                    <Directory   /data/apache2/phpvirtualbox>
                       Options Indexes MultiViews FollowSymLinks
                       AllowOverride All
                       Order allow,deny
                       Allow from all

                     Unpack that zip file using unzip into /data/apache2.
                      •   unzip phpvirtualbox-"$version".zip -d /data/apache2/ && cd /data/apache2 
                        Rename that file to just phpvirtualbox
                          •   mv -v phpvirtualbox-"$version" phpvirtualbox && cd phpvirtualbox 

                            Now rename the php file
                              •  mv config.php-example config.php 

                                Edit that config.php file and put the name of the user which uses virtualbox and the corresponding line and do it like this.
                                    var $username = 'jetchisel';                                  
                                    var $password = 'mypassword';

                                  •   var $ location = '';  

                                  •  var $consoleHost = 'IP ADDRESS OF YOUR COMPUTER'; 

                                  Create an file called virtualbox in /etc/default and put something like this.


                                  Set permissions as root run the following commands.

                                    •   chgrp -Rv vboxusers /data/apache2/phpvirtualbox  
                                    •   chmod -Rv 775 /data/apache2/phpvirtualbox   

                                       Edit that config.php file, un comment out the following.

                                          var $startStopConfig = true;
                                          var $enableAdvancedConfig = true;

                                        For the deprecated system V.
                                           Download the vboxinit for SuSE.
                                            •  wget -O vboxinit 
                                              copy the script to /etc/init.d
                                                •  cp -v vboxinit /etc/init.d/vboxinit 
                                                  set permission.
                                                    •  chmod u+rx /etc/init.d/vboxinit  
                                                      Enable init script.
                                                        •  chkconfig vboxinit on  
                                                             Check the script if it is working
                                                                  •  /etc/init.d/vboxinit {start|stop|restart|status} 

                                                                  Enable the init scripts at boot time.

                                                                      •   chkconfig vboxweb-service on 

                                                                      Restart the init scripts as root run the following.
                                                                      •  service vboxautostart-service restart 
                                                                      •  service vboxweb-service restart 

                                                                      For SYSTEMD

                                                                       Download the systemd version  for SuSE.
                                                                      •  wget 
                                                                      You can save it to any place you want even in /home/user/bin. In this example i choose to put in  to /usr/lib/systemd/
                                                                      •  cp -v systemd-vboxinit /usr/lib/systemd 
                                                                      Set permissions
                                                                      •  chmod ug+x /usr/lib/systemd/systemd-vboxinit 
                                                                      •  chgrp vboxusers /usr/lib/systemd/systemd-vboxinit

                                                                      Create a systemd unit  "vboxvmservice.service" (or any name that suits you)
                                                                      inside /usr/lib/systemd/system and add the entry below: Replace " username " with the user that belongs to the vboxusers group.


                                                                             Description=VBox Virtual Machine  Service


                                                                             ExecStart=/usr/lib/systemd/systemd-vboxinit start
                                                                             ExecStop=/usr/lib/systemd/systemd-vboxinit stop



                                                                      If you choose to save the systemd-vboxinit script in another path and not /usr/lib/systemd then you need to adjust the following entry.

                                                                      •  ExecStart=/path/to/file/systemd-vboxinit start
                                                                      •  ExecStop=/paht/to/file/systemd-vboxinit stop 

                                                                      Start that newly created unit.
                                                                      •   systemctl start vboxvmservice.service 
                                                                      Enable the service at boot time.
                                                                      •  systemctl enable vboxvmservice.service 

                                                                      Enable the init scripts;

                                                                        •  systemctl enable vboxweb-service.service 

                                                                        Start and enable apache2.
                                                                        •   systemctl start apache2.service 
                                                                        •  systemctl enable apache2.service 

                                                                        In your browser type the url below:
                                                                        •   localhost/phpvirtualbox  

                                                                        First log in:
                                                                        •  username: admin 
                                                                        •  password: admin  

                                                                        After a log in you can add a user that can handle your vms.

                                                                        Configure vms in phpvirtualbox's graphical menu.
                                                                        •  Settings --> General --> Basic --> "StartupMode --> Automatic" 

                                                                         An example of running vms at boot.

                                                                        Checking the status of your unit after booting.

                                                                        Zip file from github:

                                                                        You can search phpvirtualbox for an rpm package of this in OBS.

                                                                        Kudos to Mr. Ian Moore the author of phpvirtuabox.


                                                                        Sunday, August 25, 2013

                                                                        OpenSuSE on usb grub2

                                                                        Since 12.2 release opensuse has grub2 as an option to use. Come 12.3 it is the default grub in the installation but you can always choose to use the old legacy grub. As of this time of my blog entry Aug 2013, grub2 is still in development but usable (so they say :P ).

                                                                        Then if your using the old legacy grub  suse has some options to edit the necessary entry in order to boot your system when it has some boot issues.
                                                                        Sadly if you use grub2 then it is only limited to the following:

                                                                        As you can see theres a lot of missing files to be edited unlike old legacy grub.
                                                                        Well some files were either renamed or removed completely. Grub2 has the following (but not limited to)  files:

                                                                        1. /boot/grub2/
                                                                        2. /etc/default/grub
                                                                        3. /boot/grub2/grub.cfg
                                                                        4. /etc/grub.d/

                                                                         If your going to do a usb install  then you should not follow the suggested partitioning from the installer since i may offer to use the existing internal partitions or worst suggest to delete it completely. Untick the "proposed separate home partition". Choose create partition setup and check your other partitions if they are mounted automagically by the installer if it is indeed mounted then umount it. The partitioning i suggest is to make the first part the root and if you really need a separate /home then put it in the second partition. A swap partition will be the last. Other wise you will be thrown at the grub prompt during the first reboot ;-(.

                                                                        You will probablly will encounter some errors similar to  this.

                                                                        This is to be expected, dont worry you can just copy the error somewhere.

                                                                        Let it reboot after the installation and boot again from the dvd and choose installation in the menu. 

                                                                        Once booted to your system you can  do the following commands.

                                                                        echo '(hd0)  /dev/disk/by-id/ata.....' > /boot/grub2/

                                                                        Make sure you got the correct id of you disk.

                                                                          grub2-install --force /dev/sda1  

                                                                        /dev/sda1 is my root partition so point it to yours.

                                                                        Yo will get a WARNING but the important message is the last.


                                                                            grub2-mkconfig -o /boot/grub2/grub.cfg     


                                                                        Now if you will not see any errors from the last command then it is safe to reboot.

                                                                        This hack is also true if you cloned your disk. This does not apply to efi system since i do not have any close encounter with EFI (at least not yet :P )

                                                                        Enjoy folks!