Operation Lotus completed

About Roy

I had been askedweird question “Can I configure virtual machine with Tape drive connected to it and use it as my backup server?” Crap why you want to do that? Obvious answer we don’t have fund to buy hardware dedicated for backup. So here comes my googling and seems like you can have Tape drive configured to your virtual machine which can act as your backup server. It sounds funny but this is IT and you can expect question like this. How do I do it?There is very old article which holds good for ESX1.X but even same theory can be used for ESX3.X host.
Add the hardware as usual to the chassis. Once the hardware is physically added, log in to the ESX Server system's management interface as root, and make the hardware available to the virtual machines by configuring the virtual devices. The following steps provide more detail.
Notes:1. Make sure the tape drive is connected to an Adaptec SCSI card, not a RAID controller. For a list of supported Adaptec cards, see https://www.vmware.com/pdf/vi3_io_guide.pdf.
2. As a bestpractice, dedicate a SCSI card to the tape device. (The tape deviceis the only device attached to the SCSI card.)
Note: If the tape device does not show up, perform a rescan of the Adaptec HBA using esxcfg-rescan. See Using esxcfg-rescan from the command line and the Virtual Infrastructure Client to perform a rescan of the storage (1003988).
4. Use either the management interface or VirtualCenter to map a SCSI target from the controller to your virtual machine.
5. Find what path the tape drive was given by the VMkernel:
# cat/proc/vmware/scsi/vmhba1/3:0
Vendor: IBM
Model: ULTRIUM-TD2 Rev: 36M3
Type:Sequential-Access ANSI SCSI revision: 04
Id: 31 31 31 30 30 31 32 34 31 30 55 4c 54 52 49 55
Size: 0 Mbytes
Queue Depth: 2
6. Add aSCSI generic device, using a unique SCSI target ID that is different from the local boot device. Use the management interface to assign vmhba1:3:0:0. In the .vmx file, the tape drive lines should look like this:To determine what the vmhba address should be in the .vmx file, use this guideline. As a general rule, vmhbaX:Y:Z:0 should correspond to /proc/vmware/scsi/vmhbaX/Y:Z.
7. Using the management interface, add the hardware to the ESX Server system.
1. To add the tape drive, which is the first device, choose Hardware > Add Device > Generic SCSI Device.
2. To add the media changer, choose Add device > Generic SCSI device. Under Device Connection, select Manually. Specify a device, then enter the information accordingly.
Make sure the SCSI controller attaching the tape drives and medium changer is dedicated
to the virtual machine only.
To confirm that the SCSI controller is dedicated:
1. Log on to the management interface as root or an administrative user.
2. Right-click VM.
3. ClickConfigure Hardware.
4. Look for the SCSI Controller section. Bus Sharing should be none.
To change the SCSI controller if it is shared:
1. Click the SCSI Controller link.
2. Choose none from the Bus Sharing pull-down menu.
We came across many instance when we have expanded the HDD which has snapshot and when we try to power on we get error “The parent virtual disk has been modified since the child was created” One
of my former college and guru’s has blogged about it . I found nice KB 1007849 which I thought of copying because
of fear that I may loose the track.
This error can occur under the following circumstances:
The base disk of thevirtual machine has been changed
Running out of space on the LUN that contains the snapshot
Virtual machine suffers a blue screen exception when a snapshot is taken
For more details about snapshots and missing header files, see Cannot power on a virtual machine because the virtual disk cannot be opened (1004232)
Before implementing the solution, ensure:
You know the file names of all virtual disks associated with the virtual machine. Use the following command and record the output:
#grep -i filename /vmfs/volumes/old_datastore/vmdir/*.vmx | grep -i
vmdk
That there is enough space on the target datastore to receive the cloned virtual disks. Use the following command to assess how much space is needed:
#ls -lah /vmfs/volumes/old_datastore/vmdir/*flat.vmdk
Note: This example assumes that all of the virtual disks are contained in the directory with the virtual machine configuration file (.vmx).
A complete snapshot chain with matching CIDs and Parent CIDs (obtained from step 2 in the procedure).
The virtual machine is in a powered off state.
There is enough time to commit the snapshots. This procedure can take an extended amount of
time depending on the size of the delta files.
Find out what disks the virtual machine is using. Log in to the ESX host and navigate to the directory that contains the virtual machine. Run the following command to identify which virtual disk files are being
used:
# grep -i filename *.vmx
The output appears similar to:
scsi0:0.fileName = "vm-000002.vmdk"
scsi0:1.fileName = "vm_1-000002.vmdk"
This virtual machine has two virtual disks.
Check the CID of the base disks and compare them to the snapshots to see if they match.Run the following command to obtain the information about the virtual disk:
#cat vm_1-000002.vmdk
Theoutput appears similar to:
CID=929c1b7d
parentCID=20d215cd
createType="vmfsSparse"
parentFileNameHint="vm_1-000001.vmdk"
This indicates that the file vm_1-000001.vmdk has the CID of 20d215cd.
Do this for each file in the snapshot chain until you get to the base disk.
Clone the virtual disk to a new base disk. To clone the virtual disk:
Run the vmkfstools -i command to copy out and consolidate the snapshots. This requires enough space for the basedisk. The command ls -l *-flat.vmdk gives the size of
each base disk in the current directory.
Create a directory on a the target datastore if you are not cloning to the current directory:
#mkdir /vmfs/volumes/new_datastore/recover
Run the vmkfstools -i command to clone out the last vmdk delta disk pointer VMDK:
#vmkfstools -i /vmfs/volumes/old_datastore/vmdir/vm_1-000002.vmdk
/vmfs/volumes/new_datastore/recover/vm_1.vmdk
The output appears similar to:
Destination disk format: VMFS thick
Cloning disk '/vmfs/volumes/old_datastore/vmdir/vm_1-000002.vmdk'...
Clone:100% done.
Note:If the above process does not work, choose the next snapshot up the tree as the one you are on (or one of the higher ones) is corrupt.
Detach the disk from the virtual machine using the VI Client.
Attach the new disk, /vmfs/volumes/new_datastore/recover/vm-disk2.vmdk
to the virtual machine.
Power up the virtual machine and ensure data integrity (Event Viewer, SQL, E-mail, etc).
Delete the base disk and only it's snapshot disks.
#grep -A2 parentFile vm_1-000002.vmdk | grep -v "#"
Theoutput appears similar to:
parentFileNameHint="vm_1-000001.vmdk"
RW 41943040 VMFSSPARSE "vm_1-000002-delta.vmdk"
This indicates that the pointer vm_1-000002.vmdk points to vm_1-000002-delta.vmdk and is using vm_1-000001.vmdk as it's parent disk.
You may run the same command on the parent pointer to determine what files it uses, until you locate them all.
#rm /vmfs/volumes/old_datastore/vmdir/vm_1-000002.vmdk
# rm/vmfs/volumes/old_datastore/vmdir/vm_1-000002-delta.vmdk
#rm /vmfs/volumes/old_datastore/vmdir/vm_1-000001.vmdk
# rm /vmfs/volumes/old_datastore/vmdir/vm_1-000001-delta.vmdk
#rm /vmfs/volumes/old_datastore/vmdir/vm_1.vmdk
# rm /vmfs/volumes/old_datastore/vmdir/vm_1-flat.vmdk
Note:If you are going to use rm with a wildcard, echo the command first.This allows you to see which files are being targeted for erase.
#echo rm *.vmdk
Move the VMDKs back to the original location and re-associate the virtual machine with the new disks.
To move the VMDKs back to the original location:
Run the following command to clone the disk back to the original data store.
#vmkfstools -i /vmfs/volumes/new_datastore/recover/vm_1.vmdk/vmfs/volumes/old_datastore/vmdir/vm_1.vmdk
Detach the recovered disk from the virtual machine using the VI Client
Attach the new disk in the original location, /vmfs/volumes/old_datastore/vmdir/vm-disk2.vmdkto the virtual machine.
Power up the virtual machine and ensure data integrity (Event Viewer, SQL, E-mail, etc).
Clean up the snapshot database.Rename the .vmsd file, remove the virtual machine from inventory, and re-add the virtual machine to clear the snapshot database.
#mv vm.vmsd vm.oldvmsd