fedora 12 virtualbox 3.1.2_OSE 驱动模块加载

昨天编译的 Virtualbox 有一个问题,虚拟机设置的共享文件夹不能使用,根本就找不到网络地址,这可是个 big problem!

没有找到有效的解决方法,不知道是我的 rpwt 还是配置问题。不过我在主机配置了一个 ftp 服务器,好歹也能把虚拟机里下的东西传到主机上了。另外发现一个问题,虚拟机无法使用桥接方式上网,配置成桥接网络的话,启动时会报错,是另外两个模块没有加载的原因,把昨天的脚本修改了一下,如下,将它复制粘贴保存为 vbox,并 chmod 成可执行,覆盖 /etc/init.d 下的同名文件即可。

#!/bin/bash

#by runsisi@163.com 2010-01-11

### BEGIN INIT INFO
# Provides: vbox
# Required-Start: $syslog $local_fs
# Required-Stop: $syslog $local_fs
# Default-Start: 2  3  4  5
# Default-Stop: 0  1  6
# Short-Description: The Virtual Box kernel module
# Description: The Virtual Box kernel module
### END INIT INFO

running()
{
  lsmod | grep -q "$1[^_-]"
}

start()
{
  echo $"Starting Virtual Box."
  if ! running vboxdrv; then
    if ! modprobe vboxdrv; then
      echo $"Failed."
      return 1
    else
      chown root.vboxusers /dev/vboxdrv
    fi
  fi
  if ! running vboxnetadp; then
    if ! modprobe vboxnetadp; then
      echo $"Failed."
      return 1
    else
      chown root.vboxusers /dev/vboxnetctl
    fi
  fi
  if ! running vboxnetflt; then
    if ! modprobe vboxnetflt; then
      echo $"Failed."
      return 1
    fi
  fi

  return 0
}

stop()
{
  if running vboxnetadp; then
    if ! rmmod vboxnetadp; then
    echo $"Cannot unload module vboxnetadp"
    return 1
    fi
  fi

  if running vboxdrv; then
    if running vboxnetflt; then
      if ! rmmod vboxnetflt; then
        echo $"Cannot unload module vboxnetflt"
        return 1
      fi
    fi
    
    if ! rmmod vboxdrv; then
      echo $"Cannot unload module vboxdrv"
      return 1
    fi
  fi

  return 0
}

status()
{
  if running vboxdrv; then
    if running vboxnetflt; then
      if running vboxnetadp; then
        echo $"VirtualBox kernel modules (vboxdrv, vboxnetflt and vboxnetadp) are loaded."
      else
        echo $"VirtualBox kernel modules (vboxdrv and vboxnetflt) are loaded."
      fi
    else
      echo $"VirtualBox kernel module is loaded."
    fi
    return 0
  else
    echo $"VirtualBox kernel module is not loaded."
    return 3
  fi
}

restart()
{
  stop
  start
}

case $1 in
  start)
    start
    ;;
  stop)
    stop
    ;;
  restart)
    restart
    ;;
  status)
    status
    ;;
  *)
    echo "Usage: vbox {start|stop|restart|status}"
    exit 3
esac

exit 0

最后修改于 2010-01-12