VirtualBox

Changes between Initial Version and Version 1 of Setup_Jail


Ignore:
Timestamp:
Jan 8, 2008 10:16:34 AM (16 years ago)
Author:
Frank Mehnert
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Setup_Jail

    v1 v1  
     1In 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{{{
     3sudo debootstrap --arch amd64 sid /var/64 ftp://ftp.debian.org/debian
     4}}}
     5
     6Configure it:
     7{{{
     8sudo ln /etc/hostname /var/64/etc/hostname
     9sudo ln /etc/environment /var/64/etc/environment
     10sudo ln /etc/passwd /var/64/etc/passwd
     11sudo ln /etc/group /var/64/etc/group
     12sudo ln /etc/shadow /var/64/etc/shadow
     13sudo ln /etc/sudoers /var/64/etc/sudoers
     14sudo ln /etc/localtime /var/64/etc/localtime
     15sudo ln /etc/timezone /var/64/etc/timezone
     16sudo ln /etc/resolv.conf /var/64/etc/resolv.conf
     17sudo ln /etc/apt/sources.list /var/64/etc/apt/sources.list
     18}}}
     19Ensure 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
     31Then mount them:
     32{{{
     33for i in /var/64/{sys,proc,dev,home,tmp,var/tmp,usr/src,lib/modules}; do sudo mount $i; done
     34}}}
     35
     36chroot into the environment:
     37{{{
     38sudo chroot /var/64 su - ${LOGNAME}
     39}}}
     40
     41Set up the environment so you can launch X applications:
     42{{{
     43export XAUTHORITY=${HOME}/.Xauthority DISPLAY=:0
     44}}}
     45
     46Install 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{{{
     48sudo touch /etc/init.d/udev
     49sudo apt-get install virtualbox-ose
     50}}}
     51
     52Add yourself to the vboxusers group and load the driver:
     53{{{
     54sudo adduser ${LOGNAME} vboxusers
     55sudo modprobe vboxdrv
     56}}}
     57
     58Create a symbolic link from ${HOME}/.!VirtualBox to ~root/.!VirtualBox:
     59{{{
     60sudo ln -s ${HOME}/.VirtualBox ~root/.VirtualBox
     61}}}
     62
     63For bridged networking, create two scripts that will be used to bring up and down the TAP interfaces and install brctl:
     64{{{
     65sudo apt-get install uml-utilities bridge-utils
     66cat > 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
     70EOF
     71cat > 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
     75EOF
     76chmod a+x vbox-ifup.sh vbox-ifdown.sh
     77}}}
     78
     79Then start up the !VirtualBox GUI using something like
     80{{{
     81sudo virtualbox &
     82}}}
     83
     84and 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
     86Outside 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{{{
     88auto br0
     89iface 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
     97Bring down the ethernet interface and bring up the bridge:
     98{{{
     99sudo ifdown eth0
     100sudo ifconfig eth0 up
     101sudo ifup br0
     102}}}
     103
     104At this juncture VirtualBox should work when launched from the 64-bit chroot environment and provide bridged access to the VM.
     105
     106Oh yeah, you'll also want to add root into the vboxusers group, since that's what VirtualBox will actually run as:
     107{{{
     108sudo adduser root vboxusers
     109}}}

© 2023 Oracle
ContactPrivacy policyTerms of Use