FreeBSD 8.0 x86 and KDE4 full-screen in VirtualBox 3.1.4

I recently downloaded and installed FreeBSD 8.0 as a VirtualBox guest (running in an OpenSolaris host, natch), and quickly discovered two things; i) FreeBSD doesn’t use a desktop GUI by default, and ii) Oracle don’t provide VirtualBox Guest Additions for FreeBSD, such that one cannot handily run a FreeBSD guest full-screen.

The following is a quick how-to which will address both issues, for new guys like me wanting to install FreeBSD 8.0 quickly and use a desktop GUI at larger than 800×600 resolution. For kicks, I thought I’d use KDE for this example – only really having used GNOME on my OSS OS tinkerings to date.

I am using VirtualBox 3.1.4 on an OpenSolaris snv_134 x64 host, and I’m going to install a VM using 8.0-RELEASE-i386-dvd1.iso. This guide assumes familiarity with installing VirtualBox guests. Host and guest OSs must have internet access.

 

First hiccup; I had to attach the FreeBSD guest hard disk to a SATA (not IDE) controller in my VM, otherwise I encountered the error described by the original poster at http://forums.virtualbox.org/viewtopic.php?f=8&t=19447:

VirtualBox SATA settings

From the FreeBSD ports packages installation options, install:

kde4-4.3.1
xorg-server-1.6.1,1
xorg-drivers-7.4_2

FreeBSD ports installer screen 1

FreeBSD ports installer screen 2

FreeBSD ports installer screen 3

Once FreeBSD reaches the end of the installation process, reboot, login as root, then edit /etc/rc.conf to include the following:

local_startup="${local_startup} /usr/local/kde4/etc/rc.d"
kdm4_enable="YES"

(see http://www.freebsd.org/doc/handbook/x-config.html)

hald_enable="YES"
dbus_enable="YES"

(see http://www.freebsd.org/doc/handbook/x-config.html)

Alter the non-root account you (hopefully) made during installation such that it can su to root:

# pw user mod davenz -G wheel

See http://www.cyberciti.biz/tips/freebsd-becoming-super-user-su-or-enabling-su-access-to-user.html for more information.

Now, reboot the guest and you should now see a KDE welcome/login screen.

 

Next, we install open source VirtualBox Guest Additions. Be warned that this section may take quite some time to finish – and you also need guest internet access.

Open a terminal and enter the following:

# portsnap fetch update
# portsnap extract
# cd /usr/ports/emulators/virtualbox-ose-additions && make install clean

I used the following options when prompted:

VirtualBox Guest Additions build options

VirtualBox Guest Additions build options 2

Once complete, add the following to /etc/rc.conf:

vboxguest_enable="YES"

Reboot the guest, and when KDE runs you should now notice mouse integration between host and guest OS is now working.

 

Next, we enable a guest display resolution of 1280×1024 pixels.

Reboot FreeBSD into single user mode, login as root, and perform the following:

# mount -a
# Xorg -configure
# mv /root/xorg.conf.new /etc/X11/xorg.conf

Edit /etc/X11/xorg.conf and add the following after the “Device” section identifying the “VirtualBox Graphics Adapter” (in my case, I removed all the other “Display” subsection entries as well):

Section "Screen"
        DefaultDepth 24
	Identifier "Screen0"
	Device     "Card0"
	Monitor    "Monitor0"
	SubSection "Display"
		Viewport    0 0
		Depth       24
                Modes       "1280x1024"
	EndSubSection
EndSection

Reboot the machine, et voila:

FreeBSD 8.0 full-screen in VirtualBox

About these ads

21 thoughts on “FreeBSD 8.0 x86 and KDE4 full-screen in VirtualBox 3.1.4

  1. Lazy

    Heya,

    Good how to. But you could write also that input section needs this:

    Section “InputDevice”
    Identifier “Mouse0″
    Driver “vboxmouse”
    EndSection

    Reply
  2. Jasper

    Thanks for this great tutorial Dave! It helped me a lot getting PCBSD 8.1 to run on the latest VirtualBox on my Mac. I wrote all about it on the PCBSD forum. It was a long road. No resizing yet, but at least a better port view and resolutions as well as a mouse pointer that can now go from the VirtualBox to the main system. In the PCBSD forum thread where I discussed it all I mentioned your excellent blog post as well. Keep on the good work!

    Reply
  3. Dave

    My installation of BC-BSD 8.1 in Virtualbox 3.2.8 was at first very frustrating, as I was stuck at 600×400 resolution and nothing any info I found through Google would make any difference. When I edited /etc/X11/xorg.conf, it immediately got rewritten. Even though the xorg.conf file was set on 1024×768, it still gave only 600×400. On a 19″ monitor, that’s pretty discouraging. But I’ve followed your howto and have got both a larger window to work in and mouse-cursor integration. This is sooo much better.

    However, most installations of the guest additions allow the screen to be re-sized at will, and also allow integration of the clipboards for easy copy/paste between the host and guest. Is there any way to get FULL use of the guest additions?

    In faith, Dave
    Viva Texas

    Reply
    1. Dylan Bridgman

      To get auto-resize to work you first need to run “VBoxService” on boot.

      Then in your .xinitrc (or other mechanism that will run when X starts) run “VBoxClient –display” to enable the auto-resize. You can also run “VBoxClient –seamless” if you want to use seamless mode and “VBoxClient –clipboard” to enable clipboard sharing.

      Reply
      1. dpeirce

        Dylan, thanks for your response.

        I created ~/.xinitrc, and put all 4 commands in it, then rebooted. Same size VBox window and no integration. So I tried ‘VBoxService’ in a terminal:

        If I run VBoxService as user, it gives an error: “VbglR3Init failed with rc=VERR_ACCESS_DENIED”.

        If I run it as root, it gives an error: “”VBoxService error: Failed to connect to the guest property service! Error: VBRR_INVALID_PARAMETER. VBoxService error: Service ‘timesync’ failed pre-init: VERR_INVALID_PARAMETER”.

        I do “sorta” OK in Linux but this is the first time I’ve been able to get a ‘BSD running so I don’t know much. “For Dummies” instructions might help a great deal. Thanks!

        In faith, Dave
        Viva Texas

  4. Dylan Bridgman

    Hi Dave,

    You forgot to put the “vboxguest_enable” line in your “rc.conf”.

    It’s also worth nothing that if you set a specifc resolution in the “xorg.conf” file then auto-resize will be disabled, so you should *not* put in the 1280×1024 mode line.

    Here is a very brief list of what I did, although keep in mind I did not install KDE or any other desktop environment, just enough to test the auto-resize.

    a] Installed FreeBSD 8.1 and used “freebsd-update” to get it to the latest version
    b] Ran “pkg_add -r xorg virtualbox-ose-additions” to install the basic packages needed. You could use ports too.
    c] Added “dbus_enable”, “hald_enable” and “vbosguest_enable” to the rc.conf and rebooted.
    d] Ran “Xorg -configure” and copied the resulting “/root/xorg.conf.new” to “/etc/X11/xorg.conf”
    e] Edited “/etc/X11/xorg.conf” and changed “mouse” to “vboxmouse” on the input driver
    f] Ran “VBoxService”
    g] Ran “startx” resulting in a basic “twm” window manager.
    h] In one of the xterms ran “VBoxClient –display”, “VBoxClient –seamless” and VBoxClient –clipboard” (I haven’t tested the clipboard function though)

    After these steps I was able to use auto-resize and seamless mode. The “twm” window manager doesn’t like seamless mode though, so if you want seamless I’d recommend installing a different wm.

    Hope this helps.

    Regards,

    – Dylan

    Reply
  5. Dave

    The vboxguest_enable=”YES” entry already appears in my /etc/rc.conf file. I ‘#’ the modes entry in /etc/X11/xorg.conf, and rebooted; PC-BSD could not start ‘X’, so I logged in as root and removed the ‘#’ in xorg.conf with Nano. Now I reboot back to my 1280×1024 window size. Neither Seamless nor Clipboard are working.

    It seems that you are installing PC-BSD directly in your machine as host and installing Virtualbox in PC-BSD. I am installing Virtualbox in a PCLinuxOS host and trying to run PC-BSD as guest. The desktop is KDE. Don’t know if I made that plain above.

    I have installed the Guest Additions in PC-BSD. Looking through your ‘script’, there are already entries for dbus_enable and hald_enable in rc.conf. I changed ‘mouse’ to ‘vboxmouse’ in xorg.conf. On rebooting, I have my same 1280×1024 window, but the cursor is free now (seanless); however, nothing happens when I click on things: the flame icon gives me a tip but not a menu, and the konsole icon doesn’t give me a terminal. There’s a new tiny icon in the taskbar notifications area which says ‘driver “mouse”‘.

    So now I have seamless but can’t click on anything. ?????

    In faith, Dave
    Viva Texas

    Reply
    1. BrewBert

      I followed Dylans recipe and can confirm that everything (including seamless mode) works perfectly for a FreeBSD 8.1 GUEST on an Ubuntu 10.10 Maverick host system. I’m using unmodified gnome desktop. Grafics acceleration is enabled both in the host and in Virtualbox, 32MB video ram have been assigned.

      I’m however new to FreeBSD and VirtualBox so I would appreciate any recommendations on how to best integrate VBoxService and the VBoxClient commands into startup scripts. I’ve gdm_enable in my rc.conf.

      Regards
      -Hubert

      Reply
      1. Dylan Bridgman

        Hi Hubert,

        The important thing is that VBoxService is run by root on startup and then the various VBoxClient commands need to be run by root after X is started.

        To get VBoxService started I’d recommend creating or editing “/etc/rc.local” and adding a line to start “/usr/local/sbin/VBoxService”. You may need to “chmod a+x /etc/rc.local”

        For the VBoxClient open up “/usr/local/etc/gdm/PreSession/Default” and add the various VBoxClient lines to the end.

        Regards,

        – Dylan Bridgman

    2. Dylan Bridgman

      Hi Dave,

      I have installed PC-BSD on my side and here are the steps I followed to get it all working. Note that is has to be PC-BSD 8.1, the package installed in step c is not available for 8.0:

      a] Install PC-BSD 8.1. When asked on first startup, leave the driver as VESA.
      b] Open a terminal, run “su -” to get root
      c] Run “pkg_add -r virtualbox-ose-additions”
      d] Run “cp /usr/local/share/hal/fdi/policy/10osvendor/90-vboxguest.fdi /usr/local/etc/hal/fdi/policy/90-vboxguest.fdi”
      e] Create “/etc/rc.local” with the following contents:
      #!/bin/sh
      /usr/local/sbin/VBoxService
      f] Run “chmod a+x /etc/rc.local”
      g] Edit “/etc/rc.conf” and add vboxguest_enable=”YES” to the end
      h] Edit /etc/X11/xorg.conf, change “vesa” to “vboxvideo”, change “mouse” to “vboxmouse”, and delete the lines for Buttons, ZAxisMapping, Emulate3Buttons, Device and Protocol
      i] Edit /usr/local/kde4/share/config/kdm/Xstartup and the following to the end:
      /usr/local/sbin/VBoxClient –display
      /usr/local/sbin/VBoxClient –seamless
      /usr/local/sbin/VBoxClient –clipboard
      j] Reboot

      Reply
      1. Rui

        Apart from the VBoxClient commands needing to have two dashes, — , this works for me, but the clipboard sharing does not. Has anybody confirmed this works? (Win7x64 host)

  6. Dave

    Dylan: I’m not going to have time for a couple of weeks to follow your process posted above to see if it will solve my problems. I’m getting ready to go on a camping trip to Virginia and Iowa. However, when I get back I will give her a whirl.

    I’m not giving up on PC-BSD; just plowed under right now.

    In faith, Dave
    Viva Texas

    Reply
  7. Pingback: 2010 in review « Dave Koelmeyer

  8. Brian

    Thanks all for this tutorial and comments.
    PCBSD 8.2 users may want to check this.
    In my case VBoxClient resides in /usr/local/bin.

    So in the file /usr/local/kde4/share/config/kdm/Xstartup I have
    /usr/local/bin/VBoxClient –display
    /usr/local/bin/VBoxClient –seemless
    /usr/local/bin/VBoxClient –clipboard

    On the other hand VBoxService and VBoxControl are in /usr/local/sbin.

    Prior to the change above fullscreen did not work, despite allowing 1680X1050 resolution.

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s