Skip to main content

VMWare automatically start at Boot on Linux

Before explaining how to start a virtual system on system start-up, I want to explain what services are, I'll continue with explaining the commands (for Linux), and then explain why you want a virtual system to start on the system start-up.

The term services, in geek speak, refers to two different, but related, things. A service could be the name of the actual application running on a computer or it could be used to refer in general to another computer or software package doing something for you (i.e, that application is functioning as a "service" for you to do something). This needs to be determined based upon context. The term server is similar. It could refer to an application that is doing something for a user (like the Apache WebServer service) or it could refer to a particular physical (or virtual) computer. (If you don't understand the concept of a virtual computer, I've provided other posts on the subject. However I'll sum it up as the computers today are so powerful and so under-utilitzed (in comparison to their capabilities) that you can “share” the hardware on a physical box with special software to mimic multiple computer systems). This is confusing to people who are not well versed in computers (i.e., users), and requires a lot of patience and open mindedness to follow through context.

When a computer starts up, it starts several services to do things on behalf of the user. For a Microsoft Windows computer, this could be something as simple as starting the network services so you can connect to another computer (like browse the Internet or get your email) and starting the anti-virus software or the firewall. However, if the service is a separate computer system, it may be to start the Email service so a group of users can read, download or send their email. Or it could be to start the Web service so uses can use their web browser to read information, browse pictures or watch a video (the content or information).

Like Apache (a Web Service) or Dovecot (software that services requests to view email by a client piece like Outlook), VMware is a service to simulate a computer or multiple other computers (see my other pages on VMware and Virtualization), and sometimes you want it to automatically start a virtual computer system when the VMware service starts on the host system. This can be accomplished by creating the following configuration:

VMWare Services

Many people think of VMWare as a way to reduce hardware costs by sharing resources on a computer system. And there are a variety of reasons to run VMWare. But VMWare is just another “service” on the computer... in this case the service mimics a whole computer system. So when the computer starts up, you may want the vmware service to automatically recover as well, and restart a select group of virtual machines when the physical hardware starts.

In reality, it's fairly simple to configure VMWare for this functionality. In this manner, if the system should fail for some reason (or patching of the system requires a restart), any virtual systems on the virtual host would automatically restart.

You can start a VMWare system during boot-up by the following crontab entry:

crontab -e

Then add the necessary entry:

@reboot /usr/bin/vmware-cmd "/path/to/my.vmx" start

Another way to solve this is to configure it inside the VMWare Server (aka VMWare GSX) application

On Microsoft Windows this is a little tougher, since the user account to configure it requires a password since the Virtual System may be running under a user account. (NOTE: Review if running it under Network Service or System Service if this is true!)

Why VMWare Service?

I explained earlier that an application could be a service. As an example, that the Apache Webserver is a service since a user or users connect to it in order to receive content (pictures, text, links, etc). But you may not want to run the Apache Web Service on your computer (for whatever reason). In this case you may want to build a virtual server that runs Apache. You could do this for testing a specific application configuration or you could do it because you are writing code and have not fully tested it or there may be security issues. In this case you could restrict access to the application / content or configuration (i.e., isolate it from other users). You may want this virtual machine to be ready for you soon after your computer (or another computer) starts. These are just a few examples, and you can certainly come up with more.

Conclusion

I've provided some background on services and hopefully cleared up some of the terms and usage. It's all dependent on context (or significant knowledge) as to what one person is talking about, but it is about an application or computer that does something on behalf of another user (or users). I explained how, under both Microsoft Windows and Linux, how to automatically have a virtual server start when the computer starts up. And I've wrapped up with a short description of how a VMWare server can support you.

Windows COMMAND.COM - Just Say NO

Most people I work with know that I spend a lot of time at the Command Line in both Windows and Linux. The Command Line Interface (CLI) gives me a lot of flexibility to quickly do things that I can't do through the Graphical User Interface (GUI).

However, a lot of users aren't aware that there are two different command line interpreters under Windows....and that using the wrong one can cause problems

People who started using Microsoft Windows 95 or Windows 98 only had one choice: COMMAND.COM. It was a 16-bit application (COMMAND.COM) that ran in a 16-bit environment. No big deal, and people now continue to use it out of habit. However, these same people now use Windows XP, which is a 32-bit Operating System, or in some cases a 64-bit Operating System.

Due to changes in the way the Operating System works in Windows XP (and Windows 2000 or Windows 2003), people couldn't run 16-bit applications. So Microsoft, as part of the Operating System, developed a 16-bit environment that those software programs could use. This environment, call ed the 16-bit NTVDM (NT Virtual DOS Environment), is shared by all 16-bit programs. What this means is that if any 16-bit program crashed or generated an error, it could affect any other 16-bit program also running and even cause it to crash as well. This is why using the wrong shell (COMMAND.COM) could cause problems.

The alternative is to use the program CMD.EXE anytime a use wants a command prompt. It has all the features of COMMAND.COM (and acts like it as well), plus it has additional features as well and does NOT run in the 16-bit environment.

In short, the next time you need a command prompt (shell), use CMD instead of COMMAND.

How to move your MySQL database directory

If you have a dedicated database server and the partition with the MySQL database fills up (or starts getting low), you can move your MySQL databases to a different location.

Let’s say you want to move the database to /home/mysql

  1. The first step is to stop MySQL so that all your data gets copied correctly.

$ /etc/rc.d/init.d/mysql stop

  1. Create the new database directory in the new location

$ mkdir /home2/mysql

(NOTE: At this point many people would use the move command (mv) instead of the copy command (cp). I ALWAYS copy the files… so that I can go back and undo my changes later!)

  1. Copy the database files from the first harddrive to the second harddrive

$ cp -R /var/lib/mysql/ /home/mysql

  1. Set the correct owner and group, permissions of the new database directory

$ chown -R mysql.mysql /home/mysql/

  1. Rename your old database directory

$ mv /var/lib/mysql/ /var/lib/mysql_old

  1. Create a symbolic link from the old database directory to the new one for any programs that rely on the default location

$ ln -s /home/mysql/ /var/lib/mysql

  1. Set the correct owner and group on the symbolic link

$ chown mysql.mysql /var/lib/mysql

  1. Edit the configuration file (/etc/my.cnf) to update the changes.

Comment out the old settings and add a line for the new one as you can see below

save your configuration files (my.cnf) and exit your text editor

  1. Restart MySQL

$ /etc/rc.d/init.d/mysql start

  1. Update the AppArmor configuration file (if necessary).
  2. If MySQL refuses to start look in /var/log/mysqld.log for the reason

Upgrading Drupal

I've built a check list for each time I upgrade Drupal, whether it's a simple (incremental) version upgrade (version 5.4 to 5.7) or a full version upgrade (from version 5 to version 6).

Upgrade

  • Copy the drupal and module files to the web server.
  • Unzip (using tar) the main drupal file.
  • Unzip the modules.
  • Configure the sites directory for each website.
  • Log into the website with the Administrative account (Account #1)
  • Disable all modules (/admin/build/modules)
  • Put database in maintenance mode
  • Backup database to flat file.
  • Update apache configuration to point to new version (commenting out the old lines - by commenting them out, you can easily uncomment them if you have to do a recovery and comment out the newer version).
  • Connect to the website url, adding update.php to the end (to start the update process).
  • Follow on-screen prompts.
  • Enable all modules
  • If you're using WyzWig module, Go back and enable module "Tiny mce" (enabling WyzWig disables it for some reason)
  • If you're using the node_permissions module, Run node_permissions module.
  • Re-run update.php
  • Configure the WyzWig Editor module (this seems to lose it's configuration with some upgrades, for some reason), and any other modules you need.
  • If you've added or upgrade any modules, fix the role permissions (/admin/user/permissions)
  • Take database out of maintenance mode.
  • Verify as an anonymous user (by logging out) that the site looks the way you want and that the functionality works correctly.

Recovery

  • Drop all tables in the database.
  • Reload the backup into the correct database.
  • Update apache to point to the correct directory (uncomment the old lines and comment the new lines).

MySQL Bind Address

There are times when you need MySQL to be able to bind to more than one address. In this particular occasion, I was running Nagios locally on the same system as Drupal, my content management system. For some reason Nagios was trying to connect using the loopback address (127.0.0.1) instead of the server IP Address (192.168.230.131). However, MySQL only allows you to set one bind address (bind-address) in the /etc/my.cnf configuration file. The solution is to allow it to bind to ALL IP Addresses (using bind-address=0.0.0.0) in the MySQL configuration file.

Shrink Transaction Logs

You do NOT need to run this (I already did), but you might be interested in this SQL to shrink transaction logs. You do need to do a backup of the databases after you truncate them (I'm not concerned since these old databases are lookup only - no new data should be written to them).

USE MASTER
GO

BACKUP LOG
    file
WITH TRUNCATE_ONLY
GO

USE db
GO

DBCC SHRINKFILE ( 'dbfile' )
GO
USE Master
GO

I used the following code to generate the list of files in the database.

SELECT 'SELECT name from ' + rtrim ( name ) + '..sysfiles'
FROM sysdatabases
WHERE name LIKE 'dbfile%'
ORDER BY name

Don't forget to back-up the database once you're finished as well. A FULL database backup should be done!

Finding info in Files

Sometimes you want to be able to quickly search the contents of some files for a command or some other piece of text. The following command (for Cygwin obviously) will work:

for i in `find /cygdrive/c/Devel/SQL/ | grep sql`; do echo $i; grep cursor $i; done;

For regular linux, the command would be:

for i in `find ~/devel/sql/ | grep sql `; do echo $i; grep 'cursor' $i; done;

Both of these commands search for the word cursor in the SQL files.

QEMU on Windows

Download the QEMU program (from http://www.h7.dion.ne.jp/~qemu-win/) and install it into a directory on Windows. I use C:\QEMU.

# Verify that C:\QEMU is in the path

# Create a "base" directory to handle all your Virutal Machines. In my case, I selected C:\Virtual. I also create a subdirectory for each virtual machine I'm going to build.

# Create a base directory for the ISO images (CD-ROM images). You'll need this path for the batch file.

# Create a batch file (.CMD extension) to launch your virtual machine. Below is my batch file (AKA, a script) to launch Damn Small Linux (DSL) version 1.5.

VMWare Information

Here are some links with additional information on VMware and virutalization.

Virtual Infrastructure articles and sites:
http://www.vmware.com http://www.vmware.com/vmtn/vmworld/ http://www.vmware.com/vmtn/blog/ http://www.vmware.com/vmtn/blog/sherrod/ http://vmware.itst.org/ http://www.vmguru.com/ http://www.run-virtual.com/ http://trivore.com/vmware/ http://tihlde.org/~larstr/vmktree/ http://chitchat.at.infoseek.co.jp/vmware/ http://www.vmts.net/ http://blogs.technet.com/megand/default.aspx http://sanbarrow.com/index.html http://www.roudybob.net/ http://www.redmondmag.com/columns/article.asp?EditorialsID=1220 http://www.vmwareprofessional.com/ http://www.platespin.com/spinblog/ http://www.jsequeira.com/cgi-bin/virtualization/BrowseFacets http://www.virtual-machines.nl/vm/index.php?option=com_content&task=cate...§ionid=5&id=2&Itemid=20&limit=25&limitstart=0 http://about-virtualization.com/mambo/index.php?option=com_content&task=... http://www.virtual-strategy.com/article/articleview/1328/1/2/ http://www.computerworld.com.au/index.php/id;1734537766;fp;2;fpid;2 http://www.microsoft.com/presspass/features/2005/oct05/10-10virtualizati... http://www.microsoft.com/presspass/press/2005/oct05/10-10VirtualizationS... http://www.cio.in/esntech/viewArticle/ARTICLEID=569

Here are some links with additional information on VMware and virutalization.

Virtual Infrastructure articles and sites:

http://www.vmware.com http://www.vmware.com/vmtn/vmworld/ http://www.vmware.com/vmtn/blog/ http://www.vmware.com/vmtn/blog/sherrod/ http://vmware.itst.org/ http://www.vmguru.com/ http://www.run-virtual.com/ http://trivore.com/vmware/ http://tihlde.org/~larstr/vmktree/ http://chitchat.at.infoseek.co.jp/vmware/ http://www.vmts.net/ http://blogs.technet.com/megand/default.aspx http://sanbarrow.com/index.html http://www.roudybob.net/ http://www.redmondmag.com/columns/article.asp?EditorialsID=1220 http://www.vmwareprofessional.com/ http://www.platespin.com/spinblog/ http://www.jsequeira.com/cgi-bin/virtualization/BrowseFacets http://www.virtual-machines.nl/vm/index.php?option=com_content&amp;task=category§ionid=5&amp;id=2&amp;Itemid=20&amp;limit=25&amp;limitstart=0 http://about-virtualization.com/mambo/index.php?option=com_content&amp;task=blogcategory&amp;id=0&amp;Itemid=11 http://www.virtual-strategy.com/article/articleview/1328/1/2/ http://www.computerworld.com.au/index.php/id;1734537766;fp;2;fpid;2 http://www.microsoft.com/presspass/features/2005/oct05/10-10virtualizationlicensing.mspx http://www.microsoft.com/presspass/press/2005/oct05/10-10VirtualizationStrategyPR.mspx http://www.cio.in/esntech/viewArticle/ARTICLEID=569</span></span></p>

Sharing an RDP Local Console Session

Connect to the system and modify the computer properties (right-click on My Computer and choose Properties).

Under the Remote tab, enable Allow Remote Assistance.

Apply the settings and disconnect.

Have the user needing to share the local console do the following:

Click on Start > Help and Support.

Look for the heading called Support on the right side of the window and click on the Remote Assistance link under the heading.

Choose to Invite a user to share your session.

At the bottom of the support window, click on "Save invite as a file" rather than using Windows Messenger or email.

Choose not to set a connection password (unless you feel it is necessary).

Save the file to a folder where the person needing to shadow the active session can find it.

The file may now be clicked on (opened) and will initiate a connection to an active local console session.

The user at the local console will need to accept the incoming connection. The new session will now open an RDP session that is controlled by the desktop user through an interface that is similar to the Netmeeting interface of old.

Remember that if you are the user connecting to the local console and you are doing so through Remote Desktop Client and connecting to servers, you will need to connect using the "/console" command option which is added to the end of the target string. For Remote Desktop Client running on Windows 2000 Professional, you will need to be careful to set the quotation marks around the path and executable, but place the command option outside the quotes.