HowTo: Create a Ubuntu virtual machine
Our VM cook book
Uncategorized July 8th, 2008
By Roger Howorth

We explain how to create a simple server virtual machine (VM) running Ubuntu Linux 8.0.4. We chose Ubuntu because it is well supported both by free on-line documentation and also by services companies that you could pay for help and advice.

We assume you are running VMware Workstation 6, but these instructions would work just as well for other VMware software with minimal or perhaps even no modification.

Create a blank VM
From the File menu, select “New virtual machine…”. Press “Next” to start the wizard, and “Next” again to select the “Typical” VM configuration.

Now select the “Linux” radio button, and “Ubuntu” from the drop down list of supported Linux distributions. (You could also select “Ubuntu 64bit” here too.)

Type a name for your VM. We’ll use “Ubuntu-test” for the name of our VM. You will now see the “Network Type” dialog box. Select “Use bridge networking”.

On the following dialogue box, set the “Disk size” to 2GB. This is suitable for a basic server configuration. Leave the other check boxes unticked, and press “Finish” to complete the wizard.

Obtain a Ubuntu CD Installer
We’ll install Ubuntu using a CD Installer, which you can download free of charge from http://www.ubuntu.com/getubuntu/download
On the Ubuntu web page, select the option for the LTS Server Edition, and press the green “Start download” button.

Configure your VM
Once the download has finished, look at the VMware Workstation window and click the right mouse button on the name of your VM — remember, we used “Ubuntu-test”.

Select the option “Settings”, and then click on CD-Rom in the “Virtual Machine Settings” dialogue box. The right hand side of the dialogue box will display some options for the VM CD-Rom drive.

Select “Use ISO image”, click on the “Browse” button, and navigate to and then select the CD-Rom Ubuntu LTS CD Installer file that you just downloaded. Click “open” to select the CD Installer, and then OK to close the VM Settings dialog box.

Power on
You can now power on your VM by clicking on the “Start this virtual machine” button in the main VMware Workstation window. If you see a dialogue box warning you that Workstation “Cannot connect virtual device floppy….” select “No” to continue.

Now select the language that you would like to use during the installation process. We chose “English”.

Click on the Ubuntu screen with your mouse and press “Enter” to confirm your language selection, and press “Enter” again on the following screen to select “Install Ubuntu Server” and begin the installation.

You need to select the language that will be used by your finished server. We took the default choice of “English” by pressing “Enter” on the following screen.

The next dialogue box asks you to confirm your location. We selected United Kingdom. Make your selection and press “Enter”.

The following dialogue box asks if you want the installer to detect your keyboard layout. In most cases it is safe to press the tab button to select “No” and then press “Enter” to continue.

Select your country again in the following two dialogue boxes. The installer will now begin configuring your Ubuntu Linux server.

Configure your network
Assuming your network is set up correctly with a DHCP server, the installer will proceed without error until it needs to know the hostname for your server. We were happy to use the suggested hostname of “ubuntu” so we pressed “Tab” to select “Continue” and “Enter” to continue at the “Configure the network” dialogue box. You could type any hostname you wish at this stage.

Partition disks
Press “Enter” to accept the default choice, which is called “Guided – use entire disk”. Press “Enter” again to select the default choice of disk to partition. Finally press “tab” twice to select “Yes” and “Enter” to confirm that you wish to write these changes to the disk. The installer will update your VM’s hard disk and begin copying files from your host PC to the VM hard disk.

Set up users and passwords
To improve security a default installation of Ubuntu prevents anyone from logging into the server using the all powerful “root” account. Therefore it’s a good idea to create a user account that you can use to log into the server with. At this point in the installation you will see a few dialogue boxes to help you create such a user.

Configure package manager
If you use a HTTP proxy to access the Internet, enter its detail here, otherwise press “Tab” and then “Enter” to continue. The installer will then try to go on-line to a software library to ensure your system is installed with the most recent, stable, versions of software.

Software selection
This screen allows you to select some software that can be added to your basic server configuration. We suggest you select “OpenSSH server”, then press “Tab” and “Enter” to continue. We will use this VM as a template for all our servers and add other software to cloned copies of this VM later.

Installation complete
A few minutes later a dialogue box will appear to tell you the installation is complete. Press CTL ALT to release the keyboard from the Ubuntu VM. Now go to the “VM” menu in VMware Workstation, select the “Removable devices” option, and “CD-ROM” from the list, and click “Disconnect” to prevent the VM from starting the CD Installer the next time your Ubuntu VM is booted.

Now click the mouse on the Ubuntu screen and press “Enter” to continue. You Ubuntu VM will reboot and you will soon be presented with a Linux console and login prompt.

Type the username and password you entered during the installation process.

Install VMware Tools
Once logged in to your VM you will probably want to install VMware Tools to your Ubuntu 8.x system to properly integrate your VM with the VMware software. First we’ll open a “normal” root shell. To do this, type the following command, and enter your normal password when asked.

sudo -u root su

Now we need to install some additional software to enable us to compile VMware’s tools. Type the following commands, and press “y” when asked to confirm that you wish to proceed. Note that the quote mark used in line 2 is normally found above the Tab key. It is the single quote that points down to the right.

apt-get install build-essential
LX=`uname -r`
apt-get install linux-headers-“$LX”

Now right click on your VM in the Workstation hierarchy, and select the option to “Install VMware tools…”

Type the following commands:

mount /dev/cdrom /mnt
cd /tmp
tar -zxvf /mnt/V

You can now press the “Tab” key to auto-complete most of the remaining filename. However, as there are two files in the mounted directory you’ll need to press “t” and “Tab” to finish the filename and press return to begin uz-tarring the files to the /tmp directory. When the un-tarring is done, type the following to disconnect the VMware ISO image.

umount /mnt
cd vm

and press tab to auto-complete the rest of the directory name. Press enter to change into the vmware-tools-distrib directory.

Type “./vm” and press tab, then press enter to run the “./vmware-install.pl” script.

You’ll need to press enter several times to accept the default choice for various parameters. However, the script should complete without errors, and VMware Tools will be installed.

Mail tools
You should install the mailx package so that logrotate and other daemons can email reports to you. Use the following command:

apt-get install mailx

Congratulations!
At this point you probably want to shutdown your VM and make a copy of it in case you want to create another Ubuntu Linux server without needing to go through the installation process again each time. You can shutdown the VM by pressing CTL-ALT to release the keyboard from your VM, clicking on the “VM” menu in the Workstation menu hierarchy, and using the “Power/Shut down guest” menu option.

Leave a Response

You must be logged in to post a response.