Create New VMware VM from Template
From MyWiki
Contents |
Copy the Files
- Login as root
- Create a directory in /var/lib/vmware/Virtual Machines using the name of the new server
cd /var/lib/vmware/Virtual Machines mkdir <new server name> cd <new server name>
- Copy an image into this directory. The currently list of guest O/S templates can be found here.
Configure the Virtual Machine
- Bring up the VMware Virtual Machine Console.
- Go to the file menu and select "Open Virtual Machine... Ctrl+O". From the dialog box select "Browse". Find the directory with the new servers name and open it. Then select the .vmx file listed. This should create a new server in the Inventory list of the console. You will have to change the name of the server. It should be the current one highlighted but check the path to make sure.
- Check the settings of the new virtual server. With the new server highlighted, either go to the VM menu item and select "Setting... Ctrl+D" or from the console window select "Edit virtual machine settings". Make sure the memory allocation is ok. Also check the CD-ROM, make sure the two check boxes, Connected and Connect at power on, are both UNchecked. Select the "Options" tab and look at the "Startup/Shutdown options". Make sure that the "On host shutdown" is set to "Power off virtual machine". The "On host startup" can be set to either "Don't power on virtual machine" or "Power on virtual machine". It all depends on how you want this server to work.
- Start the virtual server.
- When asked if you want a new identifier, select that option that will create a new identifier for the server. This will create a new MAC address for the server.
Configure the Guest Operating System
Linux
- Logon to the guest system as root.
- Edit /etc/hosts. Add the new server name to the end of the localhost line.
127.0.0.1 localhost.localdomain localhost <new server name>
- Edit /etc/sysconfig/network. Change the HOSTNAME to the full name of the new server.
Windows XP
- Add this new machine to the NCSA Domain via:
My Computer -> Computer Name -> Network ID
Register with the DNS System
- Register the new server with Network Engineering. The easiest way to do this is from the new server. Start X Windows, "startx". Bring up the internet browser. Go to https://ner.ncsa.uiuc.edu/dnsworks/.
- Select the "Network Activation" link.
- Select "A network in the new NCSA building (dhcp only)" click "next".
- Select the "add" new asset link.
- Fill out the form. The Blue Tag Number can be set to "C00000". The room is 3003.
- Under the "Operating System" you will need to select the OS (in this case "FreeUnix-Fedora-Core4". Leave "BootOrder" at 0. Then select "add".
- Once the OS info has been added, select the "add" at the bottom of the page.
- On step 4 of 7, select the correct network for the new server. Most likely, it will be: NCSA Building 3003 Machine Room Net. Select "next".
- On step 5 of 7, make sure the "Allocate a static ip address" box is checked. Copy the MAC address of the new server down. Select "next".
- You should have a new IP. Copy the IP address down.
- Exit the browser and X Windows.
Run Yum Update
- At this point you need to update all of the packages and the OS. To do this from the root prompt run: "yum update".
- Sit and wait for the update to finish.
- Reboot the server.
Install the VMware Tools Software
- From the console window go to the "VM" menu option and select "Install VMware Tools...".
- You might have problems with finding the right header information for the kernel. If this is the case, while running vmware-config-tools.pl, you will get to a step that says something like this:
What is the location of the directory of C header files that match your running kernel? [/usr/src/linux/include]
What you should see is something like this:
What is the location of the directory of C header files that match your running kernel? [/lib/modules/2.6.14-1.1656_FC4smp/build/include]
If you run into this problem, you need to find out what version of the kernel you are running and where the header files are. To find out what version you are running look in /var/logs/messages. Do a find for: .Linux version". You might want to start at the bottom of the file and work your way back up; this way you will find the latest listing which should indicate the current kernel. Once you have the kernel version look for it in /lib/modules. The directory path should look something like the one listed above. Give this path as the path to the needed files and continue on.
You might also need to install the kernel source stuff. You can use yum to do this. First find out what is installed:
yum list installed
Then find out what is available:
yum list available
Look for anything starting with kernel. Depending on what version you are running, you might need to install either of the following.
yum install kernel-devel.i686
or
yum install kernel-smp-devel.i686
Once you have done this, look for the needed directory and try it in vmware-config-tools.pl
Now, this might not work. Apparently there is a problem with the newer Fedora kernels and vmware-config-tools.pl and vmware-config.pl. For more information read the thread at: http://www.vmware.com/community/thread.jspa?messageID=345893񔜥
In a nutshell, a change needs to be made to the vmware code. Open the file /usr/bin/vmware-config-tools.pl and find the line:
$header_page_offset =~ s/^$pattern \(?0x([0-9a-fA-F]{8,}).*$/$1/;
Replace the line with this:
$header_page_offset =~ s/^.*([0-9a-fA-F]{8,}).*$/$1/;
Rerun vmware-config-tools.pl. Everything should work now.
- Logon as root and run vmware-config-tools.pl. This reconfigures the VMware tools for the new machine and new OS. This will need to be run any time the OS kernel is updated. Answer all of the questions with the default answer.
Additional Guest O/S Configuration
yum
- Check to make sure that yum is set up to run.
chkconfig --list | grep yum
Make sure that run level 2,3,4, and 5 are set to "on". If they are not, run:
chkconfig --level 2345 yum on
Check to make sure they are now set.
root email
- Change the mail alias for root so that you get the mail.
cd /etc vi aliases
Find the root alias, it most likely at the bottom of the file. You might need to uncomment it. Change the name to your user name in mail. Then update the aliases database
newaliases
Remote Desktop Connection (Windows XP)
- Enable Remote Desktop Connection (RDC) according to http://www.mobydisk.com/techres/securing_remote_desktop.html
Site-licensed software (Windows XP)
- Installed site-licensed software from <\\file-server\Software-PC> as needed.
Notes and Problems
- When you clone a VM (copy the pertinent files to a new directory and instantiate it using the Vmware Console), then typically you create a new UUID along with a new MAC (network hardware) address. If after rebooting your VM you can not login because eth0 has disappeared or has been converted to eth1, then you need to copy the new MAC address from the VM host's /var/lib/vmware/Virtual\ Machines/vm_name/*.vmx file to the VM's /etc/udev/rules.d/70-persistent-net.rules file and reboot. For more information go here.
- Note that in the 70-persistent-net.rules config file, the hex letters must be in lower case, i.e.,
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:c2:fa:db", ATTR{type}=="1", NAME="eth0"
and not
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0C:29:C2:FA:DB, ATTR{type}=="1", NAME="eth0"
