VMWare category
Creating a new VM from an existing VM
OK. Once you have a good working base VM system, it is quite easy to implement new VMs for different tasks.
The first step is to create your base Linux/CentOS system or Windows system that will be used for future VMs. This system will essentially be a fresh install with all the service packs and updates applied to it. When necessary you will run it and apply new updates.
Now comes the duplicating task. That is, creating a new VM from this base system so you can experiment or create a new server. Here are the steps.
1) Create a new Virtual Machine from the VM Server access panel
2) Choose the appropriate operating system when asked. For CentOS 5.2 use Linux Redhat 5.x.
3) When asked for what hard drive to install choose none. You will later attach a copy of the base systems disk to this new VM system.
4) Choose the other setting as normal and appropriate for your situation. Remember, you are essentially creating a virtual computer without a harddrive. In my case, I needed to select a my “BridgeCard” network card for the networking setting instead of the default NAT.
5) Once created, you can now go to the summary page of the VM to add the new copied harddisk.
6) First,copy and paste the vdmk file for the base system to the new VM folder. Then rename the vmdk file to the name of that makes more sense for the VM that you just created. Usually the same name as the VM machine.
7) Now, you add the copied harddisk to the VM machine by choosing the Add New Hardware on the left hand side of the VM summary page. When adding the hardisk, choose the “Use existing Harddisk” option and select the copied and renamed vmdk file from the datastore.
That’s it. You now have a new working copy of the base VM. Your next steps would be to start configuring it to your liking such as adding the desired programs and services for it desired task, changing its IP, internal computer name, and MAC Address (if needed, for servers etc.), setting firewall setting to allow traffic to it and setting up connections to it such as external database servers.
Enjoy. The fun has just begun.
Renaming the virtual machine disk file
From http://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC&docType=kc&externalId=6821743&sliceId=1&docTypeID=DT_KB_1_1&dialogID=71326048&stateId=1%200%2071322858
Creating a new virtual disk for an existing Linux virtual machine
From http://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC&docType=kc&externalId=1003940&sliceId=1&docTypeID=DT_KB_1_1&dialogID=71320981&stateId=1%200%2071322764
Creating a VMServer NAS using FreeNAS
So I wanted to create a NAS on a Virtual machine to store webfiles. This would allow a good separation of program files and content files. With the help of my friends Ron and Phil, we were able to get it up and running from scratch in about 90 minutes. Aren’t friends and VMs nice.
The idea is to create a NAS on a virtual server as a virtual machine, mount the NAS on the webserver and then setup apache to be able to access it.
Setting up FreeNAS VM
For the NAS virtual machine, we were able to download the FreeNAS VM Image from http://www.freenas.org/index.php?option=com_versions&Itemid=51
- Download the VM Image from http://www.freenas.org/index.php?option=com_versions&Itemid=51
- unzip in your virtual machines directory on your Virtual Server host.
- Then add a new virtual machine from inventory to have the vm show up in your inventory.
- At this point, you can increase the size of the hard drive.
- You may also wish change some settings to the network card depending on how you wish to manage your NAS IP. In my case, I manually set the virtual network card MAC address and set my hardware firewall to assign a static IP address to that MAC address.
- You may also wish to set the auto-start/auto stop settings of the VM Server to include the new NAS so it will auto power up and down.
- After starting up the NAS, you can connect to it and reset the webGUI password, assign interfaces and set LAN IP if necessary.
- Connect to the webGUI using a web browser. You will be prompted for the username and password.
- Once connected you will want to create a folder to store your data and enable the services to allow sharing of files.
- create a new folder by going to the advanced menu and selecting file manager.
- create a new folder like /usr/local/nas/
- Go to the Service menu and select NFS and enable it and save it.
- Then go to the Share tab and add a folder to share, browse and select the new folder you created
- For authorized network, you can either set it to be your entire network by adding something like 192.168.0.0 and a mask of 24 or you can specify the specific web service IP and set the mask to 32.
Mounting your NAS on your web server
Next we would like to mount the NAS on the web server so that it has access to it.
- log into you webserver.
- go to the /mnt directory by using the cd /mnt command
- add a new directory by using the mkdir command, mkdir nasfiles
- next mount the new directory to the nas directory using, the command, sudo mount -t 192.168.0.35:/usr/local/nas /mnt/nasfiles
- edit the fstab file in the /etc folder to have the nas mounted on power up with the following line 192.168.0.35:/usr/local/nas /mnt/nasfiles ext3 defaults 0 0
Give Apache access to the newly mounted NAS
- edit the httpd.conf file and add in an alias to the mnt directory and add a directory declaration
- Alias /nasfiles “/mnt/nasfiles”
- <Directory “/mnt/nasfiles”>Options None AllowOverride None Order allow,deny Allow from all </Directory>
- then restart the httpd service
Test it.
Add a file to the mounted nas directory, see if you can access the file from your website.
Installing VMWare Tools on a Linux Guest Machine
VMWare Tools greatly enhance the user experience by improve the graphics and other device driver such and keyboard and mouse inputs. the most noticable effect is faster screen updates and the ability to dynamically size your VMWare console. VMWare tools also allow you to copy and paste up to 64K of plain text between the guest and the host operating system.
To install VMWare tools,
- select the guest virtual machine from the base console and click on the Install VMWare Tools link on the far right. This will insert a virtual DVD into the guest system.
- Run the RPM to install the VMWare tools.
- After installation is complete, run the vmware-config-tools.pl configuration file from the command line.
- Enter the vmware-user command to start the VMWare User process.
- Enter vmware-toolbox & to start the VMware tools control panel.
Expanding VMWare Virtual Hard Disk Size using SCSI Hard Disk
VMWare is a beautiful piece of software that allows you to run multiple virtual machines on one physical machine. As explained in a previous post, one thing that you can do is create a based virtual machine with one of your favorite operating systems, get all the updates for the operating system, install all your favorite free software, and then just copy and paste or clone the virtual machine to create new virtual machines already setup with all your favorites.
So you are thinking to yourself, that sounds great!! I will create a virtual machine with the base operating system and a small virtual hard drive so I dont take alot of room up on my serve and after I copy it, I will increase the size of the harddrive… Right. Sounds like a good plan and that what I thought. However, not all virtual hard disks are the same. It turns out, the default IDE virtual hard disk does not allow increasing its size on the fly. Therefore, if you are looking to start out with a small virtual hard disk footprint and expand when you need it, it is best to go with the SCSI virtual hard disk. this allows you to increase it storage space on the fly.
Hopefully, you are reading this before you already created your base system with a small IDE hard disk. Unfortunately, I did not and I did not find a way to easily convert the IDE to a SCSI. So I had to start from scratch with a VM machine that was built on a VM SCSI hard drive. Now I am good to go…
Copying and Pasting a VMWare VMDK file
The beauty of using VMWare is that it is very easy to magically “create” a new computer by simply copying the base vmware files of any already existing vmware instance. Are the wheels in your head starting to turn like they did in mine? Probably so. You are thinking to yourself, “Self, if I create a base windows and a base linux machine, get all the updates and then just clone them, I will save myself a TON of time”. You are absolutely correct. Not only that, but if you ever have a motherboard failure, getting a system up and running from your vmware backups is a simply as installing the vmware server base on a system and then reinstalling your backed up VMDK files of all your virtual machines. Pretty cool huh.
The main file that need is the vmdk file. On a CentOS base server setup, these files are stored in folders in the /var/lib/vmware/Virtual Machines directory. To create a new virtual machine from a base virtual machine, do the following…
- Create a new directory for the new machine in the Virtual Machines folder
- Copy vmdk and the vmx files from the base machine folder to the new folder.
- Add Virtual machine to inventory
- Rename the server and edit the notes.
- Depending on how you had your base system setup, you may need to edit static MAC addresses, Host Names, etc.
VMWare running on Linux CentOS 5.2
I decided to take the plunge and move all my servers to VMWare box. My buddy, Dr. Phil Heil got me hooked the VMWare stuff. If you haven’t heard of VMWare, it is the best thing since sliced bread. VMWare allows you to run multiple virture machines (hence, the term VM) on a single box. Essentially, you run a base vmware configuration which runs the vmware software, then you can create as many new virtual machines as you would like.
Running virtual machine is great for computer programs since you can quickly set up a particular computer configuration and test your code on it. Since VMWare supports snapshots and copying of vmdk files, you can quickly get back to your based configuration or create another instance very easily. In my case, I wanted an easy way to experiment with different server setups and a way of isolating web servers, email servers and data SQL servers. Separating servers is a best practice when hosting e-commerce sites.
Phil, our IT guru has been running the companies servers on them for many years now on a windows based system. I wanted to run mine on a linux box since linux is fast and the VMWare server software is free for linux. After doing some research, I found the following tutorials which proved to be exceptional.
VMWare Server in Production by Brian Downey and
How to Install VMWare Server on a CentOS 5.0 Desktop by Falko Timme
Follow these two guys tuitorials and you are as good as gold. After that you can set up as many servers on your box as you would like. Windows on Linux, Linux on Windows, you name it, you can do it.