When you use a lot of VMware servers and/or desktops, you will need a lot of harddisk space. Also you need to copy software and data from one virtual machine to the other. This can be made very easy when you build a shared disk.
A shared disk is a disk that is used as a D: or E: drive in many images. But building a shared disk that is used by many machines instead of copying it for every machine is not that easy. I had to search over the internet and take the information from many forums to finally get a working solution.
In this tutorial I'm going to explain how to build a shared disk, and how to use it in your environment. For the tutorial I will build one shared disk that contains all my software and all my data so every machine thinks it is local on the D drive.
Remember to always have a good backup of the data on the shared disk. This will eventually prevent you from loosing a lot of data.
Also remember that if you just build a virtual disk, it is actually a shared disk that can be used by one machine at a time. The tutorial below will help you make a real shared disk that can be used by many machines at the same time.
1. Building Your VMWare Shared Disk
First you need Virtual Windows 2003 server.
Edit your Windows Server 2003 Virtual Machine Settings and add 2 virtual disks. Your machine must be stopped to do this. Proceed as following:
- create a empty folder on your harddisk where you will place your virtual disks.
- Edit your Windows Server 2003 Virtual Machine Settings.
- Click on add hardware.
- Create a new virtual disk.
- Disk size 20Gb or less or more. (do not allocate disk now)
- Define your destination path as created previously + name your disk DATA-SHARED>
- Select the advanced options: select the virtual device node to "SCSI 1:0" and the mode to "Independent" and "Persistent"
2. VMWare Device Configuration
Now you have to attach it to the other machines.
- Edit the VM settings. Again the machine should be stopped before you can perform this task.
- Click on add hardware and select harddisk
- Select existing virtual harddisk and give the correct path to the disk.
3. Adding Line in VMWare Configuration File
This entire configuration is stored in the vmx file of your Virtual Machine. Edit it and take a look at it. You may want to do some cleaning but make sure you first create a backup of the configuration file before you edit it.
You'll need to add some lines to make VMWare use a shared disk as it would do in real cluster hardware.
Go to the bottom of the vmx file. There you will see the following lines:
scsi1.present = "TRUE" scsi1.sharedBus = "none" scsi1.virtualDev = "lsilogic" scsi1:0.present = "TRUE" scsi1:0.fileName = "D:\Virtual Machines\Shared Disk\SHARED-DISK.vmdk"
Change them in the lines below:
disk.locking = "FALSE" diskLib.dataCacheMaxSize = "0" #scsi1 data storage scsi1.present = "TRUE" scsi1.virtualDev = "lsilogic" scsi1.sharedbus = "none" scsi1:0.present = "TRUE" scsi1:0.fileName = " D:\Virtual Machines\Shared Disk\SHARED-DISK.vmdk " scsi1:0.mode = "independent-persistent" scsi1:0.shared = "TRUE" scsi1:0.redo = ""
The lines will ensure you that VMWare will not take a local copy of the disk in each client or server, and it will prevent the started Vmware to lock the file. When the file is locked you receive an error and the second and third machine will not startup.
Without adding the lines to a Vmware server or ESX server, the file will just be copied by every next machine, and you will have a shared disk that is not shared.
In that case you will notice that your harddisk will be getting full with copies of the shared disk.
4. Initialize and Convert Shared Disks
Start your Virtual machine by clicking and open the "Computer Management" dialog (Start > All Programs > Administrative Tools > Computer Management). Click on the Disk Management tree node and you'll immediately be prompted with the "Initialize and Convert Disk Wizard".
- Do NOT convert any of the disks to dynamic since we need them to be basic so make sure that the disk is unchecked.
- Create the disk to be an extended partition of all the available size
- When this is done, create the partition as a logical drive of the available size, assign a drive letter and format it with NTFS with the quick format checkbox enabled.
The disk will now be formatted and completely prepared for the use.
5. Prepare Your Second Node
To build the second server or client to use the shared disk, just power off your actual server (we'll call it Server 1) and duplicate the VMWare files (separate them into different folders).
You'll then need to power on the copy of the Server 2, change the machine name in Server 2 and give a new IP Address.
When you do this with a client, just copy the client and start the copy as client2.
6. Start Using Your Shared Harddisk
Now all your clients and servers that are cloned from the original will use the shared disk. This will save you a lot of harddisk space in your virtual environment.
The shared disk created in this article can be used for many tasks.
It can be used as a disk for a SQL cluster, a Disk for a file cluster, or just as a datashare. Your servers will see it as a local disk.