/
setup-vmx
executable file
·112 lines (98 loc) · 2.41 KB
/
setup-vmx
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
#! /usr/bin/env bash
GRUB_VERSION=0.97
REALVMX_VERSION=0.1.4
cat <<EOF
This script is distributed on an "as is" basis and does NOT provide
any warranty whatsoever. This includes, without limitation, all
warranties of merchantability or fitness for a particular purpose,
or another warranty, whether express or implied.
EOF
echo -n "Looking for needed programs... "
if [ "x`uname`" != xLinux ]; then
echo Failed!
echo This script has only been tested in Linux.
exit 1
fi
for prog in wget make qemu qemu-img fdisk; do
which $prog 1>/dev/null 2>&1
if [ $? -ne 0 ]; then
echo Failed!
echo $prog not found.
exit 1
fi
done
echo Done.
echo -n "Downloading sources and GRUB... "
wget ftp://alpha.gnu.org/gnu/grub/grub-$GRUB_VERSION-i386-pc.ext2fs \
http://downloads.sourceforge.net/project/vmx/Real%20VMX/$REALVMX_VERSION/vmx-$REALVMX_VERSION.tar.gz 1>/dev/null 2>&1
if [ $? -ne 0 ]; then
echo Failed!
exit 1
fi
echo Done.
echo -n "Unpacking and building sources... "
tar xzf vmx-0.1.4.tar.gz
pushd vmx/src/build/i386 1>/dev/null
make VMX_BASE=../../.. 1>/dev/null 2>&1
if [ $? -ne 0 ]; then
echo Failed!
exit 1
fi
popd 1>/dev/null
echo Done.
qemu-img create real-vmx.img 32M
mkdir root floppy
echo -n 'Must become root for a while. '
su -c"
LODEVICE=\`losetup -f\`
losetup \$LODEVICE real-vmx.img
echo -n 'Configuring disk image... '
fdisk -u -S63 -H16 \$LODEVICE 1>/dev/null 2>&1 <<EOF
n
p
1
a
1
p
w
EOF
losetup -d \$LODEVICE
losetup -o 32256 \$LODEVICE real-vmx.img
mkfs -t ext2 \$LODEVICE 1>/dev/null 2>&1
RET=\$?
losetup -d \$LODEVICE
if [ \$RET -ne 0 ]; then
echo Failed!
echo mkfs failed.
exit 1
fi
mount -t ext2 -o loop,offset=32256 real-vmx.img root
mount -t ext2 -o loop grub-0.97-i386-pc.ext2fs floppy
cp -r floppy/boot root
cat > root/boot/grub/menu.lst <<EOF
timeout 0
title Real VMX
rootnoverify (hd0,0)
kernel --type=netbsd /vmx
EOF
cp vmx/src/build/i386/vmx root/
umount root floppy
echo Done."
RET=$?
rm -r root floppy
if [ $RET -ne 0 ]; then
exit 1
fi
cat <<EOF
Install GRUB. In the QEMU window, enter the following commands:
root (hd0,0)
setup (hd0)
halt
EOF
qemu -hda real-vmx.img -fda grub-0.97-i386-pc.ext2fs -boot a
cat <<EOF
Now let's test that the Real VMX guest works. You should see a blue
screen with some options. This program can be found in
\`vmx/src/build/all/usrConfig.c'.
EOF
qemu -hda real-vmx.img -boot c