| 1 | In summary (for the benefit of anyone else who comes across these issues), if you get the VERR_VM_DRIVER_VERSION_MISMATCH error yet your kernel driver and !VirtualBox userland version are the same, but you're running a 64-bit kernel with 32-bit userspace, create a 64-bit chroot environment: |
| 2 | {{{ |
| 3 | sudo debootstrap --arch amd64 sid /var/64 ftp://ftp.debian.org/debian |
| 4 | }}} |
| 5 | |
| 6 | Configure it: |
| 7 | {{{ |
| 8 | sudo ln /etc/hostname /var/64/etc/hostname |
| 9 | sudo ln /etc/environment /var/64/etc/environment |
| 10 | sudo ln /etc/passwd /var/64/etc/passwd |
| 11 | sudo ln /etc/group /var/64/etc/group |
| 12 | sudo ln /etc/shadow /var/64/etc/shadow |
| 13 | sudo ln /etc/sudoers /var/64/etc/sudoers |
| 14 | sudo ln /etc/localtime /var/64/etc/localtime |
| 15 | sudo ln /etc/timezone /var/64/etc/timezone |
| 16 | sudo ln /etc/resolv.conf /var/64/etc/resolv.conf |
| 17 | sudo ln /etc/apt/sources.list /var/64/etc/apt/sources.list |
| 18 | }}} |
| 19 | Ensure various stuff is bound to the chroot environment; for this, add lines to your /etc/fstab: |
| 20 | {{{ |
| 21 | /sys /var/64/sys none bind 0 0 |
| 22 | /proc /var/64/proc none bind 0 0 |
| 23 | /dev /var/64/dev none bind 0 0 |
| 24 | /home /var/64/home none bind 0 0 |
| 25 | /tmp /var/64/tmp none bind 0 0 |
| 26 | /var/tmp /var/64/var/tmp none bind 0 0 |
| 27 | /usr/src /var/64/usr/src none bind 0 0 |
| 28 | /lib/modules /var/64/lib/modules none bind 0 0 |
| 29 | }}} |
| 30 | |
| 31 | Then mount them: |
| 32 | {{{ |
| 33 | for i in /var/64/{sys,proc,dev,home,tmp,var/tmp,usr/src,lib/modules}; do sudo mount $i; done |
| 34 | }}} |
| 35 | |
| 36 | chroot into the environment: |
| 37 | {{{ |
| 38 | sudo chroot /var/64 su - ${LOGNAME} |
| 39 | }}} |
| 40 | |
| 41 | Set up the environment so you can launch X applications: |
| 42 | {{{ |
| 43 | export XAUTHORITY=${HOME}/.Xauthority DISPLAY=:0 |
| 44 | }}} |
| 45 | |
| 46 | Install VirtualBox (I'm presuming you've already built modules outside of the chroot environment using m-a auto-install virtualbox-ose, which will pull virtualbox-ose-source out of apt and build the modules for you): |
| 47 | {{{ |
| 48 | sudo touch /etc/init.d/udev |
| 49 | sudo apt-get install virtualbox-ose |
| 50 | }}} |
| 51 | |
| 52 | Add yourself to the vboxusers group and load the driver: |
| 53 | {{{ |
| 54 | sudo adduser ${LOGNAME} vboxusers |
| 55 | sudo modprobe vboxdrv |
| 56 | }}} |
| 57 | |
| 58 | Create a symbolic link from ${HOME}/.!VirtualBox to ~root/.!VirtualBox: |
| 59 | {{{ |
| 60 | sudo ln -s ${HOME}/.VirtualBox ~root/.VirtualBox |
| 61 | }}} |
| 62 | |
| 63 | For bridged networking, create two scripts that will be used to bring up and down the TAP interfaces and install brctl: |
| 64 | {{{ |
| 65 | sudo apt-get install uml-utilities bridge-utils |
| 66 | cat > vbox-ifup.sh <<EOF |
| 67 | #!/bin/bash |
| 68 | /usr/bin/sudo /sbin/ifconfig $2 up |
| 69 | /usr/bin/sudo /usr/sbin/brctl addif br0 $2 |
| 70 | EOF |
| 71 | cat > vbox-ifdown.sh <<EOF |
| 72 | #!/bin/bash |
| 73 | /usr/bin/sudo /usr/sbin/brctl delif br0 $2 |
| 74 | /usr/bin/sudo /sbin/ifconfig $2 down |
| 75 | EOF |
| 76 | chmod a+x vbox-ifup.sh vbox-ifdown.sh |
| 77 | }}} |
| 78 | |
| 79 | Then start up the !VirtualBox GUI using something like |
| 80 | {{{ |
| 81 | sudo virtualbox & |
| 82 | }}} |
| 83 | |
| 84 | and configure your VM to connect to a host interface named (e.g.) tap1. Point the startup and shutdown scripts at vbox-ifup.sh and vbox-ifdown.sh respectively. |
| 85 | |
| 86 | Outside of the chroot, it would help to edit /etc/network/interfaces and make a bridged interface your primary network interface, and add the ethernet adapter as its slave: |
| 87 | {{{ |
| 88 | auto br0 |
| 89 | iface br0 inet dhcp |
| 90 | bridge_ports eth0 |
| 91 | bridge_fd 9 |
| 92 | bridge_hello 2 |
| 93 | bridge_maxage 12 |
| 94 | bridge_stp off |
| 95 | }}} |
| 96 | |
| 97 | Bring down the ethernet interface and bring up the bridge: |
| 98 | {{{ |
| 99 | sudo ifdown eth0 |
| 100 | sudo ifconfig eth0 up |
| 101 | sudo ifup br0 |
| 102 | }}} |
| 103 | |
| 104 | At this juncture VirtualBox should work when launched from the 64-bit chroot environment and provide bridged access to the VM. |
| 105 | |
| 106 | Oh yeah, you'll also want to add root into the vboxusers group, since that's what VirtualBox will actually run as: |
| 107 | {{{ |
| 108 | sudo adduser root vboxusers |
| 109 | }}} |