virtualbox
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
virtualbox [2010/02/18 08:55] – 172.26.0.166 | virtualbox [2010/07/04 20:05] – 172.26.14.218 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ===== VirtualBox ===== | + | ====== VirtualBox |
VirtualBox is a free/ | VirtualBox is a free/ | ||
* [[http:// | * [[http:// | ||
+ | * [[http:// | ||
===== Create a VM ===== | ===== Create a VM ===== | ||
Copy an ISO to your home directory: | Copy an ISO to your home directory: | ||
Line 51: | Line 52: | ||
---- | ---- | ||
- | Two Methods: | + | How do I get my VirtualBox Guest VM’s to start and stop when the host system reboots, shutdown, or starts. |
- | 1 VBoxTool http:// | + | Solution / Answer: |
- | 2 Script from http://www.kernelhardware.org/ | + | Create an init.d script so that VirtualBox Guest VM are controlled as a system service. |
+ | VBoxTool | ||
- | ===Ubuntu:Debian=== | + | http://www.kernelhardware.org/ |
- | VBoxTool currently consist only of a set of scripts. With this scripts, virtual | + | |
- | machines of VirtualBox in a Linux headless server can be controlled. Start, stop, | + | |
- | save, backup and show status of sessions in batch mode from the command line. | + | |
- | Usage and installation is tested only on Ubuntu. Please report if a specific | + | ---- |
- | function is not working in another environment, | + | Create Config File for vboxcontrol service |
- | + | ||
- | INSTALLATION | + | |
- | + | ||
- | Note. Precede commands with ' | + | |
- | + | ||
- | * Place the main script | + | |
- | * Make vboxtool executable: | + | < |
- | chmod +x /usr/local/bin/vboxtool | + | < |
+ | The file “machines_enabled” located in “/etc/virtualbox” is where we list the names of the Guest VM’s that we want vboxcontrol to control. | ||
- | * Place the init script script/ | + | To get a list of your current Guest VM names execute |
+ | < | ||
+ | $ VBoxManage list vms | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | Add Guest VM’s to “machines_enabled” include one VM name per line | ||
+ | < | ||
+ | # vi /etc/virtualbox/ | ||
+ | Centos_HDLES_x86_1 | ||
+ | Centos_HDLES_x86_3 | ||
+ | Centos_HDLES_LAMP</ | ||
+ | Add VirtualBox VM Service script | ||
- | * Make vboxtoolinit executable: | + | Create new init.d |
- | chmod +x /etc/init.d/ | + | |
- | + | ||
- | * Activate the init script | + | |
- | update-rc.d vboxtoolinit defaults 99 10 | + | |
- | + | ||
- | * Create a folder / | + | |
- | configuration section below, type ' | + | |
- | + | ||
- | Note. To remove vboxtoolinit from autostart: update-rc.d -f vboxtoolinit remove | + | |
- | CONFIGURATION | + | < |
+ | < | ||
+ | Copy the following code into file “/ | ||
- | Note. Configuration from vboxtool does *not* taking place on *running* sessions, | + | <code bash> |
- | so save or stop all sessions before issueing | + | #! /bin/sh |
+ | # vboxcontrol | ||
+ | # | ||
+ | # chkconfig: 345 98 02 | ||
+ | # description: | ||
+ | # processname: | ||
+ | # | ||
+ | # pidfile: / | ||
+ | # | ||
+ | ### BEGIN INIT INFO | ||
+ | # | ||
+ | ### END INIT INFO | ||
+ | # | ||
+ | # Version 20090301 by Kevin Swanson < | ||
+ | # Version 2008051100 by Jochem Kossen < | ||
+ | # http:// | ||
+ | # | ||
+ | # Released in the public domain | ||
+ | # | ||
+ | # This file came with a README file containing the instructions on how | ||
+ | # to use this script. | ||
+ | # | ||
- | * Create | + | # Source function library. |
- | < | + | if [ -f /etc/init.d/functions ] ; then |
+ | . / | ||
+ | elif [ -f / | ||
+ | . / | ||
+ | else | ||
+ | exit 1 | ||
+ | fi | ||
- | The VRDP-port enables RDP-clients like rdesktop to connect. It may be left blank. | + | ################################################################################ |
+ | # INITIAL CONFIGURATION | ||
+ | VBOXDIR="/ | ||
+ | VM_USER=" | ||
+ | USE_NAT=" | ||
- | * Create | + | export PATH=" |
- | vbox_user='< | + | |
- | * Issue the following command: | + | if [ -f $VBOXDIR/ |
- | | + | . $VBOXDIR/ |
+ | fi | ||
- | VBoxTool will configure sessions (VRDP-port). By now, session(s) should be up and | + | SU="su $VM_USER |
- | | + | VBOXMANAGE=" |
- | * Check if sessions or running, with the assumed vrdp-port: | + | ################################################################################ |
- | | + | # FUNCTIONS |
- | Show only the running sessions: | + | # Determine if USE_NAT is set to " |
- | | + | use_nat() { |
+ | if [ " | ||
+ | return `true` | ||
+ | else | ||
+ | return `false` | ||
+ | fi | ||
+ | } | ||
- | * Check if sessions configured in / | + | log_failure_msg() { |
- | | + | echo $1 |
+ | } | ||
- | UPGRADING FROM 0.2 | + | log_action_msg() { |
+ | echo $1 | ||
+ | } | ||
- | Sorry for breaking things here, but it' | + | # Check for running machines every few seconds; return when all machines are |
+ | # down | ||
+ | wait_for_closing_machines() { | ||
+ | RUNNING_MACHINES=`$SU " | ||
+ | if [ $RUNNING_MACHINES != 0 ]; then | ||
+ | sleep 5 | ||
+ | wait_for_closing_machines | ||
+ | fi | ||
+ | } | ||
- | - Config folder is moved from /etc/vbox to /etc/ | + | ################################################################################ |
- | - Main script ' | + | # RUN |
+ | case " | ||
+ | start) | ||
+ | if [ -f /etc/virtualbox/machines_enabled ]; then | ||
- | USAGE | + | cat / |
+ | log_action_msg " | ||
+ | $SU " | ||
+ | RETVAL=$? | ||
+ | done | ||
+ | touch / | ||
+ | fi | ||
+ | ;; | ||
+ | stop) | ||
+ | # NOTE: this stops all running VM's. Not just the ones listed in the | ||
+ | # config | ||
+ | $SU " | ||
+ | log_action_msg " | ||
+ | $SU " | ||
+ | done | ||
+ | rm -f / | ||
+ | wait_for_closing_machines | ||
- | After installation, | + | ;; |
+ | start-vm) | ||
+ | log_action_msg " | ||
+ | $SU " | ||
+ | ;; | ||
+ | stop-vm) | ||
+ | log_action_msg " | ||
+ | $SU " | ||
+ | ;; | ||
+ | poweroff-vm) | ||
+ | log_action_msg " | ||
+ | $SU " | ||
+ | ;; | ||
+ | status) | ||
+ | echo "The following virtual machines are currently running:" | ||
+ | $SU " | ||
+ | echo -n "$VM (" | ||
+ | echo -n `$SU " | ||
+ | echo ' | ||
+ | done | ||
+ | ;; | ||
+ | *) | ||
+ | echo " | ||
+ | name> | ||
+ | exit 3 | ||
+ | esac | ||
- | KNOWN ISSUES | + | exit 0 |
+ | </ | ||
+ | Add vboxcontrol service to chkconfig registry | ||
- | - Backup is not working as expected when using snapshots. When a snapshot is | + | < |
- | | + | Tell chkconfig |
- | previous backups. Problem is that once a snapshot is made, the main vdi | + | |
- | (according | + | |
- | vdi instead of the expected, chained main vdi in the vdi folder. | + | |
- | (Tracker #2132265) | + | |
- | MORE HELP | + | < |
- | - Type: ' | ||
- | - See http:// | ||
- | === Fedora :Redhat : CentOS === | ||
- | --- |