1 |
#!/bin/bash |
#!/bin/bash |
2 |
# $Header: /root/magellan-cvs/src/virtualbox/virtualbox-config.sh,v 1.9 2009-07-01 18:02:28 niro Exp $ |
# $Header: /root/magellan-cvs/src/virtualbox/virtualbox-config.sh,v 1.12 2010-02-21 20:06:45 niro Exp $ |
3 |
# Configures virtualbox for Magellan-Linux |
# Configures virtualbox for Magellan-Linux |
4 |
|
|
5 |
LIBDIR=/usr/lib |
LIBDIR=/usr/lib |
6 |
INSTDIR=${LIBDIR}/virtualbox |
INSTDIR=${LIBDIR}/virtualbox |
7 |
VBOXMODULE=vboxdrv.ko |
VBOXMODULE=vboxdrv.ko |
8 |
VBOXNETMODULE=vboxnetflt.ko |
VBOXNETMODULE=vboxnetflt.ko |
9 |
|
VBOXNETADPMODULE=vboxnetadp.ko |
10 |
|
|
11 |
COLRED="\033[1;6m\033[31m" |
COLRED="\033[1;6m\033[31m" |
12 |
COLGREEN="\033[1;6m\033[32m" |
COLGREEN="\033[1;6m\033[32m" |
46 |
die "No kernel sources for kernel ${KERNEL_VERSION} found! Aborting." |
die "No kernel sources for kernel ${KERNEL_VERSION} found! Aborting." |
47 |
fi |
fi |
48 |
|
|
49 |
for module in ${VBOXMODULE} ${VBOXNETMODULE} |
for module in ${VBOXMODULE} ${VBOXNETMODULE} ${VBOXNETADPMODULE} |
50 |
do |
do |
51 |
if [[ -f /lib/modules/${KERNEL_VERSION}/misc/${module} ]] |
if [[ -f /lib/modules/${KERNEL_VERSION}/misc/${module} ]] |
52 |
then |
then |
60 |
fi |
fi |
61 |
done |
done |
62 |
|
|
63 |
for module in ${VBOXMODULE} ${VBOXNETMODULE} |
for module in ${VBOXMODULE} ${VBOXNETMODULE} ${VBOXNETADPMODULE} |
64 |
do |
do |
65 |
# compile the module |
# compile the module |
66 |
cd ${INSTDIR}/src/${module/.ko/} |
cd ${INSTDIR}/src/${module/.ko/} |
68 |
make -C ${KERNEL_SOURCES} SUBDIRS=$(pwd) SRCROOT=$(pwd) clean || die "mod-compile ${module}" |
make -C ${KERNEL_SOURCES} SUBDIRS=$(pwd) SRCROOT=$(pwd) clean || die "mod-compile ${module}" |
69 |
|
|
70 |
# need some symver from vboxmodule (must be run after clean!) |
# need some symver from vboxmodule (must be run after clean!) |
71 |
if [[ ${module} = ${VBOXNETMODULE} ]] && [[ -f ../${VBOXMODULE/.ko/}/Module.symvers ]] |
if [[ ${module} = ${VBOXNETMODULE} ]] || [[ ${module} = ${VBOXNETADPMODULE} ]] |
72 |
then |
then |
73 |
cp ../${VBOXMODULE/.ko/}/Module.symvers . |
[[ -f ../${VBOXMODULE/.ko/}/Module.symvers ]] && cp ../${VBOXMODULE/.ko/}/Module.symvers . |
74 |
fi |
fi |
75 |
|
|
76 |
make -C ${KERNEL_SOURCES} SUBDIRS=$(pwd) SRCROOT=$(pwd) modules || die "mod-compile ${module}" |
make -C ${KERNEL_SOURCES} SUBDIRS=$(pwd) SRCROOT=$(pwd) modules || die "mod-compile ${module}" |
82 |
|
|
83 |
# calc module dependencies |
# calc module dependencies |
84 |
mecho "Calculating module dependencies ..." |
mecho "Calculating module dependencies ..." |
85 |
depmod -ae ${KERNEL_VERSION} |
depmod -a ${KERNEL_VERSION} |
86 |
|
|
87 |
# re-read udev rules to grant the right permissions |
# re-read udev rules to grant the right permissions |
88 |
if [[ -x $(which udevadm) ]] |
if [[ -x $(which udevadm) ]] |
94 |
# load the module |
# load the module |
95 |
if [[ x$(uname -r) = x${KERNEL_VERSION} ]] |
if [[ x$(uname -r) = x${KERNEL_VERSION} ]] |
96 |
then |
then |
97 |
for module in ${VBOXMODULE} ${VBOXNETMODULE} |
for module in ${VBOXMODULE} ${VBOXNETMODULE} ${VBOXNETADPMODULE} |
98 |
do |
do |
99 |
mecho "Loading kernel-module ${module} ..." |
mecho "Loading kernel-module ${module} ..." |
100 |
modprobe $(basename ${module} .ko) |
modprobe $(basename ${module} .ko) |
101 |
done |
done |
102 |
|
|
103 |
|
if [ $(echo ${KERNEL_VERSION%%-*} | sed 's:\.::g') -ge 2631 ] |
104 |
|
then |
105 |
|
# fixes NMI warnings with kernels >=2.6.31: |
106 |
|
# vboxdrv: Warning: 2.6.31+ kernel detected. Most likely the hardware performance |
107 |
|
# vboxdrv: counter framework which can generate NMIs is active. |
108 |
|
mecho "Disabled hardware performance counter NMIs ..." |
109 |
|
echo 2 > /proc/sys/kernel/perf_counter_paranoid |
110 |
|
fi |
111 |
else |
else |
112 |
echo -e ${COLRED} |
echo -e ${COLRED} |
113 |
echo "Your current running kernel does not match the the module target." |
echo "Your current running kernel does not match the the module target." |
114 |
echo "You must boot into your target kernel and load the modules manually," |
echo "You must boot into your target kernel and load the modules manually," |
115 |
echo "before you can use virtual box." |
echo "before you can use virtualbox." |
116 |
echo -en ${COLDEFAULT} |
echo -en ${COLDEFAULT} |
117 |
fi |
fi |
118 |
|
|