Tuesday, March 6, 2012

VirtualBox on openSuSE

VirtualBox is a free and opensource virtualization client from Oracle. Before being acquired by Oracle VirtualBox was originally from innotek GMBh. First of all you need to update your system before installing vbox, you can use either   
 zypper   or    yast2 online_update  

To update using zypper.
  •   zypper ref && zypper up  
Reboot if you have a kernel update so the new kernel kicks in, this is specially from a new installation, you DO NOT want to jump into installing VirtualBox on a fresh installed SuSE because this might cause some unnecessary packages to be installed and later cause some issues which will cause you some headache and later blame the package or even openSUSE for screwing things up! There are two VirtualBox rpm packages that you can install, one from the suse repo and the other from VirtualBox website. Starting from version 4.0 the base package is released under the GPL v2. See editions on https://www.virtualbox.org/wiki/Editions to know the difference between the two.

There are 2 available packages one is coming from the distro and the other one coming from Oracle. read the whole guide and choose just ONE package that will suite your needs, DO NOT MIX packages!



Installing the distro package.

Normally VirtualBox is in the oss repository so you only need to install it using yast or zypper.
To install the virtualbox package in oss repository using zypper.

   zypper in virtualbox  

If you want you can always find the latest distro package in the virtualization repo and its
located here:  http://download.opensuse.org/repositories/Virtualization


to add that distribution repo.


      zypper ar http://download.opensuse.org/repositories/Virtualization/openSUSE_11.4/ Virtualization
  

You can change the disitribution according to your version, in this case its 11.4, the name
of that repo would be Virtualization.

Refresh that repo after its added. You need to accept and trust the public key.
  •   zypper ref Virtualization 
 To install that package from the distribution after adding the repo.
  •  zypper in VirtualBox 
    If you are not sure which version is available and which repo will it come.
    •  zypper se virtualbox 

    To check  some useful information about the package using zypper.
    •  zypper info virtualbox 

    This version or virtualbox package should pull the needed kernel module packages since it
    is packaged by the distro.  You can just load the driver as root run:

     /etc/init.d/vboxdrv start 

     systemctl start vboxdrv.service 

    If that does not load the driver try  to load the modules as root run:
    •  modprobe vboxdrv   \\  

    •  modprobe vboxnetflt 

    •  modprobe vboxnetadp 

    Enable it at boot time as root run:

     service vboxdrv on 

     systemctl enable vboxdrv.service 

    One thing to add about the distro package is that it does not include the Guest
    Additions which is in the form of an iso file. Since it contains some proprietary code
    which cannot be distributed the same way as the VBox package due to legal issues.
    You can always find the the iso file in their site.


    Go one more sub directory under your package version and you should see it there.


    NOTE:
        If you have installed the package from the distro you don't need to install
        the binary from Oracle, you need to choose which one that suites you best.


    Installing the binary from Oracle:

    Using  the binary from Oracle requires some packages to be installed first and to
    to prepare  your system before installing the binary. These are gcc make and
    some kernel development. packages. You can refer to this Chapter of the Manual.

    To install those packages using zypper .

    •  zypper in kernel-source kernel-syms make gcc  
    This should pull the other dependencies and some additional packages as well.


    The binary version from Oracle has its own repository, you can find them in


    http://download.virtualbox.org/virtualbox/rpm/opensuse

    To add that repo.


       zypper addrepo -r http://download.virtualbox.org/virtualbox/rpm/opensuse/"$version"/virtualbox.repo 


        Something to note about 12.1 is that there is no repo from oracle for 12.1 you can just use the 11.4 repo and package for 12.1 and it should work.

        You can change the distribution according to your version, replace the "$version" according to your suse version and the name of that repo would be virtualbox.

        Refresh that repo after its added. You need to accept and trust the public key.
        •   zypper ref virtualbox 

        One suggestion before you install that binary, you might consider keeping the
        package locally after the installation for future use. Enable the rpm files caching
        of VirtualBox repo using zypper.

        •  zypper mr -k virtualbox 

        What this mean is "mr" modify repo , "-k" keep packages=1. You can find that
        rpm inside the   /var/cache/zypp/packages/VirtualBox   directory after
        you have done installing.


        You will need to edit /etc/zypp/zypp.conf and uncomment out something so that delta rpm will not be used but the base rpm package.

        Always make a backup of all the files you're editing no matter which tool you are using.

         cp -v /etc/zypp/zypp.conf /etc/zypp/zypp.conf.orig 

        Here is an example of editing that /etc/zypp/zypp.conf on the run. You can always edit it by hand using your favorite text editor :-).

          printf '%s\n' 'g/^#[[:space:]]*download.use_deltarpm/s/^#[[:space:]]*/' w | ed -s /etc/zypp/zypp.conf  

        You should see this output.


          download.use_deltarpm = true
          download.use_deltarpm.always = false
         


         Replace true with false so you will only avoid using delta rpm.

           printf '%s\n' 'g/^\(download\.use_deltarpm[[:space:]]*=\)[[:space:]]*true$/s//\1 false/' w | ed -s /etc/zypp/zypp.conf

        In the end everything should look like this. It is on separate line this is just an example.


          download.use_deltarpm = false
          download.use_deltarpm.always = false



        Check out what is really there.

         grep -Ev '^($|;|\[|#)' /etc/zypp/zypp.conf 

        Again the previous step was just to keep a local copy of an rpm so that it can be used as a local source.

        You can now proceed with the installation whether or not you did the previous step.
        •  zypper in VirtualBox-4.0 
        The version of that binary is 4.0 you can always change it to the version you want to install.
        If you are unsure which version is available after you added the repo you can use  zypper.
        •  zypper se VirtualBox 
        The package you are looking for is named "Oracle VM VirtualBox"

        After installing VirtualBox whether its from the distro or from Oracle you need to add
        the user who will run and use it  to the group vboxusers which is created upon the
        installation of VirtualBox. As root run the gpasswd     or    groupmod  utility:
        •   gpasswd -a username vboxusers 

        or
        •  groupmod -A username vboxusers 
        Replace the username with the user you want to use VirtualBox. You will
        need to log-out that user in order for that to take effect. Upon re-login
        you can check which groups does  that user belongs, run  groups 

        Optionally you can install the Extension Pack  This package is not covered by the
        GPL v2 license  and falls under  the PUEL which remains to be the property of
        Oracle. Download  the   Extension Pack from virtualbox.org.

        Download the extension pack using the  wget  utility


             wget http://download.virtualbox.org/virtualbox/4.0.4/Oracle_VM_VirtualBox_Extension_Pack-4.0.4-70112.vbox-extpack


        Replace the version and name accordingly. You can always check which extension
        pack you want to install in this site  http://download.virtualbox.org/virtualbox/
        Since extpack goes to the installation of VBox itself it will ask you the roots
        password to continue the installation.

        To install that package using VBoxManage.
        •  VBoxManage extpack install  /path/to/<tarball
        Change the path to yours and the tarball should have an extension .vbox-expack
        Refer to the VBox Manual for more info about extension packs. Since 4.0 is  released under
        the GPL there is also a third party (GPL) extension pack which is from the community.


        Starting VirtualBox:

        After you have installed VirtualBox you can run it from console.To run
        virtualbox from console as a normal user which belongs to the vboxusers type
        •  VirtualBox 

          Note: DO NOT run VirtualBox as root user. A common mistake
                    is to invoke it using your favorite sudo utility. The  gui way
                    you can find it under the Emulator category.

          If you have  installed the binary   after  a kernel update you might 
          need to manually rebuild the kernel modules as root run ( just choose one ).
          •  /etc/init.d/vboxdrv setup 
          •   rcvboxdrv setup  
          Both command should work but the latter exist  only in SuSE.

          Now that your done installing You can create your new vm, look through the VirtualBox Manual on how you are going start.  FYI if you have installed VBox you can find the manual locally under the "Help" menu "Contents". Read the Documentation  or consult the  Community wiki for more in depth details.


          Enjoy and Good luck!

          4 comments:

          1. This (kernel default) method support 64 bit guests ?

            ReplyDelete
          2. If your asking about if 32 bit kernels support 64 bit guest then yes provided that the some conditions are met. See 3.1.2 of the manual which has 64-bit guests in the topic.

            http://download.virtualbox.org/virtualbox/UserManual.pdf

            ReplyDelete
          3. For this openSuSe newbie: regarding "Reboot if you have a kernel update" how would I tell if my kernel has been updated?

            ReplyDelete
          4. Sorry for not replying for a long time, any ways uname -r should tell you your current running kernel. you should run that before and after the update.

            ReplyDelete