Debian headless

Discussions related to using VirtualBox on Linux hosts.

Debian headless

Postby bmwiedemann » 22. Nov 2008, 19:10

I have been using VirtualBox on a Debian etch Headless server and did not want to pull in 126 packages for the X11 dependencies.
So I wrote a small bash script for Debian-based systems to build a new package that would work without X11. Of course, the VirtualBox GUI will not be available there. Just RDP.
Start VMs with
VBoxManage startvm $name -type vrdp


Code: Select all   Expand viewCollapse view
#!/bin/sh
in=virtualbox_1.6.6-35336_Debian_etch_i386.deb
out=virtualbox-server_1.6.6-35336_Debian_etch_i386.deb
wget -nc http://download.virtualbox.org/virtualbox/debian/pool/non-free/v/virtualbox/$in
dir=tmp
rm -rf $dir
mkdir $dir/DEBIAN -p
dpkg-deb --extract $in $dir
dpkg-deb --control $in $dir/DEBIAN

# clean
cd $dir
rm -rf usr/share/virtualbox/sdk usr/lib/virtualbox/VirtualBox usr/lib/virtualbox/VBoxSDL usr/bin/VirtualBox usr/bin/VBoxSDL

# drop X11&co from dependencies
perl -i -pe 's/Package: virtualbox/$&-server\nConflicts: virtualbox/;\
s/(Depends: ).*/$1libc6 (>= 2.3.6-6), libgcc1 (>= 1:4.1.1-12), libssl0.9.8 (>= 0.9.8c-1), libstdc++6 (>= 4.1.1-12), libxml2 (>= 2.6.27), debconf (>= 0.5) | debconf-2.0, psmisc, adduser/;\
s/(Recommends: ).*/$1linux-headers, gcc, make, binutils, bridge-utils, uml-utilities, libhal1 (>= 0.5)/' DEBIAN/control


cat >etc/vbox/settings <<EOF
# this file is sourced by /etc/init.d/vbox

# list numbers of VMs to start at boot on this host
START_VMS=""
EOF
echo /etc/vbox/settings >>DEBIAN/conffiles

cat >etc/init.d/vbox <<EOF
#!/bin/sh
### BEGIN INIT INFO
# Provides:       vbox
# Required-Start: \$network vboxnet vboxdrv
# Required-Stop:
# Default-Start:  2 3 4 5
# Default-Stop:   0 1 6
# Description:    VirtualBox server autostart
### END INIT INFO

. /etc/vbox/settings

case \$1 in
   start)
      echo "starting vms"
      for i in \$START_VMS ; do
         su -c /vm/vm\$i/start - vm\$i
      done
   ;;
   stop)
      echo "stopping vms"
      for i in \$(seq 1 9) ; do
         su -c /vm/vm\$i/stop - vm\$i &
      done
      n=20
      # wait up to \$n seconds for VMs to stop cleanly
      while test \$n -gt 0 && killall -0 VBoxSVC ; do
         sleep 1
         n=\$(expr $n - 1)
      done
   ;;
   status)
      ps axu|grep "/usr/lib/virtualbox/*V"
   ;;
   *)
   echo "Usage: \$0 {start|stop|status}"
   ;;
esac
EOF
chmod 755 etc/init.d/vbox

dpkg-deb --build . ../$out


Ciao Bernhard M.
I am who I am
bmwiedemann
 
Posts: 32
Joined: 23. Mar 2008, 06:41
Location: $HOME

Postby KeyzerSuze » 24. Nov 2008, 01:39

Thats great, would be nice if they broke up the deb package into say 3 files

a gui
a non gui
and the common stuff
KeyzerSuze
 
Posts: 88
Joined: 14. Aug 2008, 07:57
Primary OS: Debian other
VBox Version: PUEL
Guest OSses: debian i386, debian amd64, Windows XP, Windows 2003 Server

Postby Sasquatch » 24. Nov 2008, 16:30

KeyzerSuze wrote:Thats great, would be nice if they broke up the deb package into say 3 files

a gui
a non gui
and the common stuff
Would be better to have just two versions. One with GUI, one without.
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org

Retired from this Forum since OSSO introduction.
Sasquatch
Volunteer
 
Posts: 17800
Joined: 17. Mar 2008, 13:41
Location: /dev/random
Primary OS: Debian other
VBox Version: PUEL
Guest OSses: Windows XP, Windows 7, Linux

Postby bmwiedemann » 24. Nov 2008, 21:05

I agree with Sasquatch... there are several operations that can not be done with the VirtualBox GUI, so one has to install VBoxManage anyway.
However, would be nice having a split into say...
virtualbox
virtualbox-gui
virtualbox-devel (having the sdk/idl part)

as is the case with for example openvpn + openvpn+gui on MS-Windows.

however, with a script as the one above, everyone can split things as he sees fit.


Here is some bash script that I used to build a debian package of the guest additions, so that they can be easily installed in other VMs without gcc and kernel-headers. The X11 stuff is not included, as I dont need it.

Code: Select all   Expand viewCollapse view
#!/bin/sh
ver=1.6.6-35336
tmp=/tmp/vboxadd
pkg=virtualbox-guest-additions

mkdir -p $tmp/DEBIAN
cd $tmp
cat >DEBIAN/control <<EOF
Package: $pkg
Conflicts: virtualbox
Version: ${ver}_Debian_etch
Section: misc
Priority: optional
Architecture: i386
Pre-Depends: libc6 (>= 2.3.6-6)
Depends: libc6 (>= 2.3.6-6)
Recommends:
Installed-Size: 160000
Maintainer: Bernhard M. Wiedemann <vboxbmw lsmod.de>
Description: Sun xVB VirtualBox guest additions
 Guest additions provide access to the host's filesystem
 and synchronisation for the virtual machine's clock
EOF

cp --parent -a /etc/init.d/vbox{add*,vfs} /etc/rc2.d/S0*vbox* /lib/modules/`uname -r`/misc/vbox*.ko /usr/sbin/vboxadd-timesync .
#cp --parent -a /usr/bin/VBox{Client,RandR} .

dpkg-deb --build . /tmp/$pkg-$ver.deb
I am who I am
bmwiedemann
 
Posts: 32
Joined: 23. Mar 2008, 06:41
Location: $HOME

Postby vuser1 » 28. Jan 2009, 09:32

You may want to a look at this script - http://farfewertoes.com/code/vboxcontrol/
It also could bring up/down network bridge and has another features.

Author of the scrpipt mentioned DHCP for bridge br0 (in /etc/network/intefraces), but this also works perfect with static ip like:

interface br0 inet static
address ...
netmask ..
...
DON'T add "auto br0" - script does it itself.
vuser1
 
Posts: 26
Joined: 26. Jan 2009, 23:24

Re: Debian headless

Postby xbtsw » 26. Jun 2009, 22:19

I am trying to remove GUI/X11 component on VirtualBox 2.2.4. Since the script is for 1.6 so I don't know if it's compatible with 2.2.4. I trying to understand what the script is doing but I can't quite understand why the script modifying the "etc/vbox/settings" and "etc/init.d/vbox" file. Any explanation?
xbtsw
 
Posts: 4
Joined: 26. Jun 2009, 22:13
Primary OS: Debian Lenny
VBox Version: OSE Debian
Guest OSses: WinXP

Re: Debian headless

Postby bmwiedemann » 27. Jun 2009, 19:58

Both files are not part of the VirtualBox distribution, but were written by me for server requirements. They are hereby declared public domain. Of course, you can omit or replace them by other management tools.

As for the version, I did not try it with 2.x yet, but it should only need slight adaptions in any case. Changes can only affect the list of files to keep or omit. Maybe dependencies changed slightly as well.
Last edited by bmwiedemann on 27. Jun 2009, 21:30, edited 1 time in total.
I am who I am
bmwiedemann
 
Posts: 32
Joined: 23. Mar 2008, 06:41
Location: $HOME

Re: Debian headless

Postby bmwiedemann » 27. Jun 2009, 21:24

Found some time to update the script, but not to test the result more than producing the VBoxManage help page. Feedback welcome.

Code: Select all   Expand viewCollapse view
#!/bin/sh
inurl=http://download.virtualbox.org/virtualbox/debian/pool/non-free/v/virtualbox-2.2/virtualbox-2.2_2.2.4-47978_Debian_etch_i386.deb
in=`basename $inurl`
out=`echo $in | sed -e 's/virtualbox/&-server/'`
wget -nc $inurl
dir=tmp
rm -rf $dir
mkdir $dir/DEBIAN -p
dpkg-deb --extract $in $dir
dpkg-deb --control $in $dir/DEBIAN

# clean
cd $dir
rm -rf usr/share/virtualbox/sdk usr/lib/virtualbox/VirtualBox usr/lib/virtualbox/VBoxSDL usr/bin/VirtualBox usr/bin/VBoxSDL usr/lib/virtualbox/libQtGuiVBox.so.4 usr/lib/virtualbox/VBoxSDL.so usr/lib/virtualbox/VirtualBox.so

# drop X11&co from dependencies
perl -i -pe 's/Package: virtualbox/$&-server/;\
s/^(Depends: ).*/$1libc6 (>= 2.3.6-6), libgcc1 (>= 1:4.1.1-12), libssl0.9.8 (>= 0.9.8c-1), libstdc++6 (>= 4.1.1-12), libxml2 (>= 2.6.27), debconf (>= 0.5) | debconf-2.0, psmisc, adduser/;\
s/(Recommends: ).*/$1linux-headers, gcc, make, binutils, bridge-utils, uml-utilities, libhal1 (>= 0.5)/' DEBIAN/control


cat >etc/vbox/settings <<EOF
# this file is sourced by /etc/init.d/vbox

# list numbers of VMs to start at boot on this host
START_VMS=""
EOF
echo /etc/vbox/settings >>DEBIAN/conffiles

cat >etc/init.d/vbox <<EOF
#!/bin/sh
### BEGIN INIT INFO
# Provides:       vbox
# Required-Start: \$network vboxnet vboxdrv
# Required-Stop:
# Default-Start:  2 3 4 5
# Default-Stop:   0 1 6
# Description:    VirtualBox server autostart
### END INIT INFO

. /etc/vbox/settings

case \$1 in
   start)
      echo "starting vms"
      for i in \$START_VMS ; do
         su -c /vm/vm\$i/start - vm\$i
      done
   ;;
   stop)
      echo "stopping vms"
      for i in \$(seq 1 9) ; do
         su -c /vm/vm\$i/stop - vm\$i &
      done
      n=20
      # wait up to \$n seconds for VMs to stop cleanly
      while test \$n -gt 0 && killall -0 VBoxSVC ; do
         sleep 1
         n=\$(expr $n - 1)
      done
   ;;
   status)
      ps axu|grep "/usr/lib/virtualbox/*V"
   ;;
   *)
   echo "Usage: \$0 {start|stop|status}"
   ;;
esac
EOF
chmod 755 etc/init.d/vbox

dpkg-deb --build . ../$out
I am who I am
bmwiedemann
 
Posts: 32
Joined: 23. Mar 2008, 06:41
Location: $HOME

Re: Debian headless

Postby TechnoPractical » 11. Jul 2009, 21:57

I may be way off base here, so excuse my noobishness.

If I understand correctly you're just trying to run Vbox without GUI? Why not just start the VM headless; use the command VBoxHeadless.

My apologies if this is beyond obvious.
TechnoPractical
 
Posts: 6
Joined: 12. Jun 2009, 22:40
Primary OS: Ubuntu other
VBox Version: PUEL
Guest OSses: FreeBSD, Win Server 2003, Linux

Re: Debian headless

Postby xbtsw » 12. Jul 2009, 00:51

bmwiedemann wrote:Found some time to update the script, but not to test the result more than producing the VBoxManage help page. Feedback welcome.

Code: Select all   Expand viewCollapse view
#!/bin/sh
inurl=http://download.virtualbox.org/virtualbox/debian/pool/non-free/v/virtualbox-2.2/virtualbox-2.2_2.2.4-47978_Debian_etch_i386.deb
in=`basename $inurl`
ou
t=`echo $in | sed e ''s/virtalbox/&-seerver/'`
wget nc $$iurrl
dir=tt
rm
-rf-rf $dmk
mr $r r/DEBDEN -N -p
dpkg-de-extextract $in $dir
dpkeb ebcontontrol $in $dir/DEBI
#

# clean
cd $dir
rm urf/shr/sharrtvalbualbox/usr/lib/vibtuarboxlbox/ualBox usr lib/virtuarboxlbox/SDL usr/bir/VirtuarBoxlBox bin/VBoxSDo usL usr/virtuartualbox/libQtGuiVBox.so.4 usr/lib/virboxlbox/SDL.so usr lib/vir/virboxlbox/ualBox.so
.# drop X11

 X11&co from dependencies
perl -i -pe kageackagtu virtualbox/$er/;\
s/^(\
s/^(Depends: ).*/$1libc6 (>= 2.3.6-6), libgcc1 (>= 1-12), -12), libssl0.9.8 (>= 0.9.8c-1), libstdc++6 (>1-12), -12), libxml2 (>= 2, debc, debconf (>= 0debconfebconf-2.0, , addus adduss/(Rec
s/(Recmends: (Recommends: ).*/$1linux-headers, gc brmake, bils, uml-bridge-ut, libuml1 tilities, liEBIAN/(>= 0.5)/' DEBIAN/control


cat >etc/vbox/his ings <<EOF
# this file is sourced by /etc/init.d/vbox

# list numbers of VMs to start at boot on this host
START_VMS=""
EOF
echo /etc/vbox/settings >>DEBIAN/conffiles

ox <<EOF
init.d/vbox <<EOF
#!/bin/sh
### BEGIN INIT INFO
# Provides:       vbox
# Required-Start: \$network vboxnet vboxdrv
# Required-Stop:
# Default-Start:  2 3 4 5
# Default-Stop:   0 1 6
# Description:    VirtualBox server autostart
### END INIT INFO

. /etc/vbox/settings

case \$1 in
   start)
      echo "starting vms"
      for i in \$START_VMS ; do
         su -c /vm/vm\$i/start - vm\$i
      done
   ;;
   stop)
      echo "stopping vms"
      for i in \$(seq 1 9) ; do
         su -c /vm/vm\$i/stop - vm\$i &
      done
      n=20
      # wait up to \$n seconds for VMs to stop cleanly
      while test \$n -gt 0 && killall -0 VBoxSVC ; do
         sleep 1
         n=\$(expr $n - 1)
      done
   ;;
   status)
      ps axu|grep "/usr/lib/virtualbox/*V"
   ;;
   *)
   echo "Usage: \$0 {start|stop|status}"
   ;;
esac
EOF
chmod 755 etc/init.d/vbox

dpkg-deb --build . ../$out


Thanks for your update and explaination.

The script eems not working for me. After I installed the virtualbox-server-2.2 package and trying to use VBoxManage it come up with a error saying following:
Code: Select all   Expand viewCollapse view
/usr/lib/virtualbox/VBoxSVC: error while loading shared libraries: libxslt.so.1: cannot open shared object file:uch file or directory
ERROR: failed to create the VirtualBox object!
ERROR: code NS_BASE_STREAM_WOULD_BLOCK (0x80470007) - Stream operation would block (extended info not available)
Most likely, the VirtualBox COM server is not running or failed to start.
Last edited by xbtsw on 12. Jul 2009, 01:07, edited 1 time in total.
xbtsw
 
Posts: 4
Joined: 26. Jun 2009, 22:13
Primary OS: Debian Lenny
VBox Version: OSE Debian
Guest OSses: WinXP

Re: Debian headless

Postby xbtsw » 12. Jul 2009, 00:56

TechnoPractical wrote:I may be way off base here, so excuse my noobishness.

If I understand correctly you're just trying to run Vbox without GUI? Why not just start the VM headless; use the command VBoxHeadless.

My apologies if this is beyond obvious.

Yes we are trying to run headless virtualbox, on debian virtualbox package from the debian source the package come with dependencies of ~250 packages on a minial debian system. Most of them are X related libraries, which is useless when running headless server.
The script bmwiedemann wrote help to remove those dependencies and remake the deb file.
xbtsw
 
Posts: 4
Joined: 26. Jun 2009, 22:13
Primary OS: Debian Lenny
VBox Version: OSE Debian
Guest OSses: WinXP

Re: Debian headless

Postby bmwiedemann » 12. Jul 2009, 14:44

xbtsw wrote:The script eems not working for me. After I installed the virtualbox-server-2.2 package and trying to use VBoxManage it come up with a error saying following:
Code: Select all   Expand viewCollapse view
/usr/lib/virtualbox/VBoxSVC: error while loading shared libraries: libxslt.so.1: cannot open shared object file:uch file or directory
ERROR: failed to create the VirtualBox object!
ERROR: code NS_BASE_STREAM_WOULD_BLOCK (0x80470007) - Stream operation would block (extended info not available)
Most likely, the VirtualBox COM server is not running or failed to start.


the missing file is part of the libxslt1.1 . Probably some dependencies missing on my list. There might be some more (see below for VirtualBox 3.0)

VBoxHeadless -startvm NAME
should work anyway

Code: Select all   Expand viewCollapse view
# ldd /usr/lib/virtualbox/VBoxManage
        linux-vdso.so.1 =>  (0x00007fff9d3ff000)
        VBoxDDU.so => /usr/lib/virtualbox/VBoxDDU.so (0x00007f8494e75000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f8494c59000)
        VBoxRT.so => /usr/lib/virtualbox/VBoxRT.so (0x00007f84949b0000)
        VBoxXPCOM.so => /usr/lib/virtualbox/VBoxXPCOM.so (0x00007f8494695000)
        libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007f8494389000)
        libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f8494171000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f8493e18000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f849509f000)
        libz.so.1 => /lib64/libz.so.1 (0x00007f8493c02000)
        librt.so.1 => /lib64/librt.so.1 (0x00007f84939f9000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007f84937f5000)
        libcrypto.so.0.9.8 => /usr/lib64/libcrypto.so.0.9.8 (0x00007f8493478000)
        libxml2.so.2 => /usr/lib64/libxml2.so.2 (0x00007f849311a000)
        libcurl.so.4 => /usr/lib64/libcurl.so.4 (0x00007f8492ed7000)
        libm.so.6 => /lib64/libm.so.6 (0x00007f8492c81000)
        libidn.so.11 => /usr/lib64/libidn.so.11 (0x00007f8492a4e000)
        libssl.so.0.9.8 => /usr/lib64/libssl.so.0.9.8 (0x00007f8492800000)
        libldap-2.4.so.2 => /usr/lib64/libldap-2.4.so.2 (0x00007f84925bc000)
        libgssapi_krb5.so.2 => /usr/lib64/libgssapi_krb5.so.2 (0x00007f8492390000)
        libkrb5.so.3 => /usr/lib64/libkrb5.so.3 (0x00007f84920ee000)
        libk5crypto.so.3 => /usr/lib64/libk5crypto.so.3 (0x00007f8491ec8000)
        libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007f8491cc4000)
        libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007f8491ac1000)
        libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f84918aa000)
        liblber-2.4.so.2 => /usr/lib64/liblber-2.4.so.2 (0x00007f849169a000)
        libsasl2.so.2 => /usr/lib64/libsasl2.so.2 (0x00007f849147f000)
        libkrb5support.so.0 => /usr/lib64/libkrb5support.so.0 (0x00007f8491276000)
I am who I am
bmwiedemann
 
Posts: 32
Joined: 23. Mar 2008, 06:41
Location: $HOME

Re: Debian headless

Postby xbtsw » 13. Jul 2009, 00:08

bmwiedemann wrote:
xbtsw wrote:The script eems not working for me. After I installed the virtualbox-server-2.2 package and trying to use VBoxManage it come up with a error saying following:
Code: Select all   Expand viewCollapse view
/usr/lib/virtualbox/VBoxSVC: error while loading shared libraries: libxslt.so.1: cannot open shared object file:uch file or directory
ERROR: failed to create the VirtualBox object!
ERROR: code NS_BASE_STREAM_WOULD_BLOCK (0x80470007) - Stream operation would block (extended info not available)
Most likely, the VirtualBox COM server is not running or failed to start.


the missing file is part of the libxslt1.1 . Probably some dependencies missing on my list. There might be some more (see below for VirtualBox 3.0)

VBoxHeadless -startvm NAME
should work anyway

Code: Select all   Expand viewCollapse view
# ldd /usr/lib/virtualbox/VBoxManage
        linux-vdso.so.1 =>  (0x00007fff9d3ff000)
        VBoxDDU.so => /usr/lib/virtualbox/VBoxDDU.so (0x00007f8494e75000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f8494c59000)
        VBoxRT.so => /usr/lib/virtualbox/VBoxRT.so (0x00007f84949b0000)
        VBoxXPCOM.so => /usr/lib/virtualbox/VBoxXPCOM.so (0x00007f8494695000)
        libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007f8494389000)
        libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f8494171000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f8493e18000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f849509f000)
        libz.so.1 => /lib64/libz.so.1 (0x00007f8493c02000)
        librt.so.1 => /lib64/librt.so.1 (0x00007f84939f9000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007f84937f5000)
        libcrypto.so.0.9.8 => /usr/lib64/libcrypto.so.0.9.8 (0x00007f8493478000)
        libxml2.so.2 => /usr/lib64/libxml2.so.2 (0x00007f849311a000)
        libcurl.so.4 => /usr/lib64/libcurl.so.4 (0x00007f8492ed7000)
        libm.so.6 => /lib64/libm.so.6 (0x00007f8492c81000)
        libidn.so.11 => /usr/lib64/libidn.so.11 (0x00007f8492a4e000)
        libssl.so.0.9.8 => /usr/lib64/libssl.so.0.9.8 (0x00007f8492800000)
        libldap-2.4.so.2 => /usr/lib64/libldap-2.4.so.2 (0x00007f84925bc000)
        libgssapi_krb5.so.2 => /usr/lib64/libgssapi_krb5.so.2 (0x00007f8492390000)
        libkrb5.so.3 => /usr/lib64/libkrb5.so.3 (0x00007f84920ee000)
        libk5crypto.so.3 => /usr/lib64/libk5crypto.so.3 (0x00007f8491ec8000)
        libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007f8491cc4000)
        libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007f8491ac1000)
        libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f84918aa000)
        liblber-2.4.so.2 => /usr/lib64/liblber-2.4.so.2 (0x00007f849169a000)
        libsasl2.so.2 => /usr/lib64/libsasl2.so.2 (0x00007f849147f000)
        libkrb5support.so.0 => /usr/lib64/libkrb5support.so.0 (0x00007f8491276000)

Thanks for your quick reply.
After adding the "libxslt1.1 (>= 1.1.18)" in the dependencies the VBoxManage seems up and running.
xbtsw
 
Posts: 4
Joined: 26. Jun 2009, 22:13
Primary OS: Debian Lenny
VBox Version: OSE Debian
Guest OSses: WinXP


Return to VirtualBox on Linux Hosts

Who is online

Users browsing this forum: No registered users and 19 guests