runsisi

  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  45 随笔 :: 15 文章 :: 26 评论 :: 0 Trackbacks
昨天编译的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 -"$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

 
runsisi@HUST
posted on 2010-01-12 21:15 runsisi 阅读(822) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理