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

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/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