Home > Blogs > VMware Consulting Blog > Tag Archives: VMDK

Tag Archives: VMDK

Cloning AppStacks and Modifying Scripts

Jeremy WheelerBy Jeremy Wheeler

Recently while working onsite with a client I discovered they needed to have local Windows accounts created upon AppStack attachment as required by their application. The customer didn’t want to go through the process of recreating the AppStack to achieve this. I was able to solve this problem by injecting scripts into the VMDK of the AppStack. These scripts are called at the time a volume is dynamically attached, or at various points during system startup and logon. They are used in order only if present in the AppStack or Writable volume. If not present in the volume the batch file will be skipped.

All batch files are in the root of the AppStack or Writable Volume. They are only accessible on a system without an agent.

For example, if you assign a volume to a Windows system and there is a user logged in, you would see the following steps—taken automatically—in chronological order:

  • prestartup.bat runs under Windows SYSTEM. If the volume is attached from boot, this will run when SVSERVICE starts.
  • startup.bat runs under Windows SYSTEM. If the volume is attached from boot, this will run when SVSERVICE starts.
  • shellstart.bat runs under Windows USER. If the volume is attached before the user logs in, this is called just before the Windows shell launches.
  • startup_postsvc.bat runs under Windows SYSTEM. This will only occur if there are services or drivers on the AppStack or Writable Volume.
  • logon_postsvc.bat runs under Windows USER. This will only occur if there are services or drivers on the AppStack or Writable Volume.
  • allvolsattached.bat runs under Windows USER. If multiple volumes are attached at the same time (i.e., during user logon), then this is called only once.

These scripts may contain any scriptable actions and are used to customize Windows desktop and application actions at various points in time during the system startup and user login processes. This is to ensure AppStack and Writable Volume data will function appropriately and provide the user with the best possible experience.

These scripts are case sensitive and should be utilized and/or modified with caution.

Batch File Details:

Optional wait times for each batch file may be configured. These are just part of the agent machine. Wait times are defined in seconds and all settings are stored as REG_DWORD registry entries in the following Windows registry path.

HKLM\SYSTEM\CurrentControlSet\services\svservice\Parameters

Registry keys may also be created on the agent machine using the command line interface.

Example:

reg.exe add HKLM\SYSTEM\CurrentControlSet\services\svservice\Parameters /v KeyValue /t REG_DWORD /d 60

End User System Batch Files

The following is a list of each batch file used on the end-user system.

  • prestartup.bat – Launched under Windows SYSTEM when a volume is dynamically attached or during system startup prior to virtualization being activated.
    Optional wait time key: WaitPrestartup (default do not wait).
  • startup.bat – Launched under the Windows SYSTEM when a volume is dynamically attached or during system startup. (Right after the volume is virtualized)
    Optional wait time key: WaitStartup (default do not wait).
  • startup_postsvc.bat – Launched under the Windows SYSTEM after services have been started on the volume. This is only called when there are services on the volume, which are needed to be started (not called unless there are services on volume).
    Optional wait time key: WaitStartupPostSvc (default do not wait).
  • logon.bat – Launched under the Windows USER at logon and before Windows Explorer starts.
    Optional wait time key: WaitLogon (default wait until it finishes).
  • logon_postsvc.bat – Launched under the Windows USER after services have been started. This is only called when there are services on the volume, which are needed to be started (not called unless there are services on volume).
    Optional wait time key: WaitLogonPostsvc (default do not wait).
  • shellstart.bat – Launched under the Windows USER when a volume is dynamically attached or when Windows Explorer starts.
    Optional wait time key: WaitShellstart (default do not wait).
  • allvolattached.bat – Launched after all volumes have been processed (so if user has 3 AppStacks, this will be called after all 3 have loaded).
    Optional wait time key: WaitAllvolattached (default do not wait).
  • shellstop.bat – Launched under the Windows USER when Windows session logoff is initiated, but before Windows Explorer is terminated.
    Optional wait time key: WaitShellstop (default do not wait).
  • logoff.bat – Launched under the Windows USER during Windows session logoff when Windows Explorer has terminated, but before the volume has disconnected.
    Optional wait time key: WaitLogoff (default do not wait).
  • shutdown_presvc.bat – Launched under the Windows SYSTEM when the computer is being shut down before services have been stopped.
    Optional wait time key: WaitShutdownPresvc (default do not wait).
  • shutdown.bat – Launched under the Windows SYSTEM when the computer is being shut down after services have been stopped.
    Optional wait time key: WaitShutdown (default do not wait).

Provisioning System Batch Files

The following is a list of each batch file used on the provisioning system

post_prov.bat – Launched at the end of provisioning to conduct any one-time steps that should be performed at the end of provisioning. Invoked at the point of clicking the provisioning complete pop-up while the volume is still virtualized.
Optional wait time key: WaitPostProv (default wait forever).

The steps needed to perform such an operation are outlined here.

App Volumes Update Method

**** Initial preparation

JWheeler Cloning AppStacks 1

  1. Select the source AppStack and click ‘Update.’
  2. Give the new AppStack a name, select the appropriate storage, append the path with the new AppStack name, and enter a description if needed.
  3. Select ‘Create’ and ‘Wait for completion’ or ‘Perform in the background.’
  4. Select ‘Update.’
  5. Once ‘Update’ is selected you will need to wait until the AppStack is cloned. Once completed refresh your App Volumes Manager interface.
  6. The new AppStack you created should be present and show the status of ‘Un-provisioned.’

**** Provision Updated AppStack

JWheeler Cloning AppStacks 2

  1. From the App Volumes Manager interface, select ‘AppStacks’.
  2. Select your newly created AppStack (the one you just modified).
  3. Select ‘Provision.’
  4. Enter the name of the provisioning virtual machine. The provisioning machine is typically a clean virtual machine with patches and limited applications installed.
  5. Select the provisioning virtual machine.
  6. Select ‘Provision.’
  7. Select ‘Start Provisioning.’
  8. Once the AppStack is attached to your provisioning machine open the console to that virtual machine.
  9. You will be greeted with a dialog box that says you’re now in provisioning mode.
  10. Select Explorer and change the view to show hidden files/folders.
  11. Navigate to “C:\SnapVolumesTemp\MountPoints.”

Note: Under MountPoints you will discover links. If you go into each link you will find a set of files such as batch scripts (startup.bat, etc.) You can make your changes at this point.

  1. Once you complete your changes, re-hide hidden files/folders.
  2. Select ‘OK’ on the App Volumes dialog to finish the capture process.
  3. Select ‘Yes’ to the installation complete dialog.
  4. Select ‘OK’ to the next dialog box, which will reboot the virtual machine.
  5. Once the provisioning machine has rebooted, login to complete the process.
  6. Select ‘OK’ at the ‘Provisioning successful’ dialog box.

**** Editing an AppStack VMDK outside the Update option

JWheeler Cloning AppStacks 3

  1. Select a virtual machine that does NOT have App Volumes Agent installed.
  2. Edit the settings of the virtual machine and add a drive. (Edit Settings > Add… > Hard Disk > Use an existing virtual disk)
  3. Navigate through the storage tree to your newly created AppStack and select the VMDK (i.e., \cloudvolumes\apps\<your new app>\<your new app.vmdk>
  4. Select ‘OK’ on the virtual machine settings interface to commit changes.
  5. You should now see a new drive letter representing the new AppStack VMDK. Proceed to make any customizations you need.
  6. Once finished, edit the settings again of the virtual machine (you can do this step with the virtual machine powered-on or off).
  7. Select the newly added hard disk (the new AppStack VMDK you added).
  8. Select the button ‘Remove.’
  9. Select the button ‘Remove from virtual machine.’
  10. Select ‘OK’ to commit changes to the virtual machine.

Note: If you receive an error message that the VMDK is in shared-mode you can do one of two options to resolve this.

  • Select ‘Rescan’ in the App Volumes Manager portal > Volumes > AppStacks tab.
  • Delete .metadata file where the VMDK resides on the datastore. This option is typically needed if you clone the AppStack from the datastore side and don’t use the Update method as outlined above.

Your AppStack is now ready to test.


Jeremy Wheeler is an experienced senior consultant and architect for VMware’s Professional Services Organization, End-user Computing specializing in VMware Horizon Suite product-line and vRealize products such as vROps, and Log Insight Manager. Jeremy has over 18 years of experience in the IT industry. In addition to his past experience, Jeremy has a passion for technology and thrives on educating customers. Jeremy has 7 years of hands-¬‐on virtualization experience deploying full-life cycle solutions using VMware, CITRIX, and Hyper-V. Jeremy also has 16 years of experience in computer programming in various languages ranging from basic scripting to C, C++, PERL, .NET, SQL, and PowerShell.

Jeremy Wheeler has received acclaim from several clients for his in-¬‐depth and varied technical experience and exceptional hands-on customer satisfaction skills. In February 2013, Jeremy also received VMware’s Spotlight award for his outstanding persistence and dedication to customers and was nominated again in October of 2013

Copying App Volumes AppStacks Between Environments That Use vSAN Storage

JeffSmallBy Jeffrey Davidson

There is an issue copying App Volumes AppStacks (VMDK files) if using Secure Copy (SCP) from one environment to another when using VSAN storage. This is not an App Volumes problem; it is related to the way VSAN stores VMDK data.

Clients will often want to create AppStacks in a test environment, then copy those AppStacks to a production environment, and finally import them into App Volumes. In situations where any of those environments use VSAN storage, you will not be able to copy (SCP) AppStacks (specifically VMDK files) between environments.

In this blog entry I will discuss a workaround to this issue, using an example in which the client has two VSAN environments (DEV and PROD), and needs to copy VMDK files between them.

The VMDK files created by App Volumes are nothing special and are traditionally comprised of two files.

What we normally identify as <filename>.vmdk is a type of header/metadata file. Meaning it only holds information regarding the geometry of the virtual disk and, as such, references a file that contains the actual data.

The file referenced is often called a “flat” file; this file contains the actual data of the VMDK. We can identify this file as it has the naming pattern of <filename>-flat.vmdk

On traditional block level storage these two files are normally stored together in the same folder, as shown in the example screenshot below.

JDavidson1

But VSAN storage is different; if you look at the contents of the “header” file you see something similar to the screenshot below. In this screenshot, the section in red is normally a reference to a “flat” file (example: Adobe_Acrobat_Reader -flat.vmdk). In the case where VSAN is the storage platform, we see something different. The screenshot below shows a reference to a VSAN device.

JDavidson2

VSAN storage employs object-level storage, which is different from traditional block-level storage. The VSAN objects are managed through a storage policy which, for example, can allow for greater redundancy for some virtual machines over others. Because the reference in the VMDK file points to a VSAN DOM object, it cannot be copied through traditional means (SCP).

To work around this issue you will need traditional block-level storage which acts as a “middle man” to allow the SCP copy of VMDK files between environments. You will also need SSH access enabled on one host in each environment.

The first step is to clone the VMDK you wish to copy from the VSAN volume to the traditional storage volume. Once on traditional storage you will be able to copy (SCP) the two VMDK files directly to a host in a different VSAN environment. After you have copied (SCP) the VMDK files to a destination VSAN environment, you will need to perform a clone action to re-integrate the VMDK with VSAN as a storage object, so it can be protected properly with VSAN.

The diagram below is an overview of the process to copy AppStack (VMDK) files between VSAN environments.

JDavidson3

The example below shows the commands required to copy an App Volumes AppStack (VMDK) between environments that use VSAN storage. Before executing these commands you should create a staging area in each environment where AppStacks will be copied temporarily before being copied between hosts for getting re-integrated in the destinations’ VSAN storage.

For example:

In the source environment, create the folder <path to block level storage>/AppVolumes_Staging

In the destination environment, create the folder <path to cloud volumes root folder>/cloudvolumes/staging

Step 1:

SSH into the host where the AppStack currently resides.

Execute the following command to clone the AppStack to block-level storage. Note that after you execute this command there are two files on the block-level storage. One is the header file, and the other is the “flat” file, which was previously integrated with VSAN as a storage object.

vmkfstools -d thin -i <VSAN path to App Stack>/cloudvolumes/apps/<filename>.vmdk <path to block level storage>/AppVolumes_Staging/<filename>.vmdk

Example:

vmkfstools -d thin -i /vmfs/volumes/vsan:4a65d9cbe47d44af-80f530e9e2b98ac5/76f05055-98b3-07ab-ef94-002590fd9036/apps/<filename>.vmdk /vmfs/volumes/54e5e55d-97561a60-50de-002590fd9036/AppVolumes_Staging/<filename>.vmdk


Step 2:

Execute the following commands to copy (SCP) an AppStack from one environment to another.

scp <path to vmdk clone on block level storage>/<filename>.vmdk root@<esxi mgt IP>:<path to staging folder>/<filename>.vmdk

scp <path to vmdk “flat” file clone on block level storage>/<filename>-flat.vmdk root@<esxi mgt IP>:<path to staging folder>/<filename>-flat.vmdk

Example:

scp /vmfs/volumes/54e5e55d-97561a60-50de-002590fd9036/AppVolumes_Staging/<filename>.vmdk root@10.10.10.10:/vmfs/volumes/vsan:265d91daeb2841db-82d3d8026326af8e/6efbac55-f2f7-f86a-033f-0cc47a59dc1c/Staging/<filename>.vmdk

scp /vmfs/volumes/54e5e55d-97561a60-50de-002590fd9036/AppVolumes_Staging/<filename>-flat.vmdk root@10.10.10.10:/vmfs/volumes/vsan:265d91daeb2841db-82d3d8026326af8e/6efbac55-f2f7-f86a-033f-0cc47a59dc1c/Staging/<filename>-flat.vmdk


Step 3:

Run the commands below to delete the AppStack from the staging folder on the source environment.

rm <path to staging folder>/<filename>.vmdk

rm <path to staging folder>/<filename>-flat.vmdk

Example:

rm /vmfs/volumes/54e5e55d-97561a60-50de-002590fd9036/AppVolumes_Staging/<filename>.vmdk

rm /vmfs/volumes/54e5e55d-97561a60-50de-002590fd9036/AppVolumes_Staging/<filename>-flat.vmdk


Step 4:

SSH into the host where the AppStack has been copied to. In this example the host IP address is 10.10.10.10.

Run the command below to clone the copied AppStack from the staging folder to the App Volumes “apps” folder, and re-integrate the VMDK into VSAN as a storage object.

vmkfstools -d thin -i <path to staging folder>/<filename>.vmdk <path to cloud volumes root folder>/cloudvolumes/apps/<filename>.vmdk

Example:

vmkfstools -d thin -i /vmfs/volumes/vsan:265d91daeb2841db-82d3d8026326af8e/6efbac55-f2f7-f86a-033f-0cc47a59dc1c/Staging/<filename>.vmdk /vmfs/volumes/vsan:265d91daeb2841db-82d3d8026326af8e/6efbac55-f2f7-f86a-033f-0cc47a59dc1c/apps/<filename>.vmdk


Step 5:

Run the commands below to delete the AppStack from the staging folder on the destination environment.

rm <path to staging folder>/<filename>.vmdk

rm <path to staging folder>/<filename>-flat.vmdk

Example:

rm /vmfs/volumes/vsan:265d91daeb2841db-82d3d8026326af8e/6efbac55-f2f7-f86a-033f-0cc47a59dc1c/Staging/<filename>.vmdk

rm /vmfs/volumes/vsan:265d91daeb2841db-82d3d8026326af8e/6efbac55-f2f7-f86a-033f-0cc47a59dc1c/Staging/<filename>-flat.vmdk
After completing these steps, you will have successfully copied a VMDK from one VSAN storage platform to another.

App Volumes also creates a “metadata” file during the creation of an AppStack, as shown in the screenshot below.

JDavidson4

The “metadata” file is a “text” file and should be copied to the destination environment so the AppStack (VMDK) can be imported into the destination App Volumes instance. Because this is a “text” file, it can be copied (SCP) without the cloning process and need for block-level storage as described in steps 1–5 above.


Jeffrey Davidson, Senior Consultant, VMware EUC. Jeffrey has over 15 years of IT experience and joined VMware in 2014. He is also a VCP5-DCV and VCP5-DT. He is a strong advocate of virtualization technologies, focusing on operational readiness with customers.

App Volumes: Storage Migration for AppStacks

Jeremy WheelerBy Jeremy Wheeler

Inside of App Volumes you can accomplish a storage migration between different SANs using the feature called ‘Storage Groups,’ provided you have shared storage between App Volume Managers. If you don’t, I recommend creating a temporary LUN/Volume to accomplish this migration. If you are performing a migration on a large scale, such as 2X or more App Volume Manager instances, you will need to perform steps one through eight on each App Volume Manager instance.

Conceptual architecture:

JWheeler AppVolumes Manager Conceptual Architecture

 

To achieve a successful migration we will need to utilize a shared LUN/Volume between datastores. This can be an NFS or iSCSI datastore and will only be used temporarily to complete this process.

JWheeler AppVolumes Migration Setup

Stage 1: Migration Startup

  1. Select ‘Infrastructure’
  2. Select ‘Storage Groups’
  3. Give your storage group a name (my example: migration_temp)
  4. Check ‘Automatically Replicate AppStacks’ and leave ‘Automatically Import AppStacks’ unchecked. If you check the ‘Import AppStacks’ checkbox, you will need to do a lot of cleanup if you were using a temporary LUN to do this migration.
  5. Select ‘spread’ for your distribution strategy.
  6. Select your preferred template storage.
  7. Select ‘direct’ for storage selection.
  8. Select the checkbox of your local shared storage. This field will represent where you currently have the AppStacks you want migrated.
  9. Select the checkbox of your Temporary LUN. The temporary LUN is assumed empty or the AppStacks you want migrated over are not on the temporary LUN.
  10. Select ‘Create’ 

Once your storage group is created replication will begin immediately; it might take awhile depending on how many AppStacks you need to distribute within the storage group.

Stage 2: Cleanup

  1. After all AppStacks have been evenly distributed in the storage group, you can simply delete the storage group. This will not delete any AppStacks – it simply disassociates the logical bucket of resources. Both the source LUN and temporary LUN will still have the AppStacks.

Load the VMware vSphere® client and move any AppStacks from the temporary LUN to the permanent shared storage LUN, and then to the View Block.

JWheeler AppVolumes View Block

I want to dig further into explaining this process about moving AppStacks from the temporary LUN. App Volumes create pointers to all AppStacks residing on storage. This means in our example (shown above) when we replicate an AppStack between two points the inventory object in App Volumes Manager will consider all these locations as the AppStack living space. This also means that if you decide to delete an AppStack from inventory, ALL pointer locations will also be deleted. So, if you need to clean up the App Volumes Manager inventory in your Source Environment, you will need to copy, move, or detach the temporary LUN you created prior to deletion. The process for doing that is explained here.

JWheeler AppVolumes

a)      Move AppStacks from cloudvolumes/apps/* to a temporary folder /cloudvolumes/apps/tmp/* using the vSphere C# client, GUI, or vSphere command-line.
b)      Delete AppStacks from Source inventory.
c)      Move AppStacks from cloudvolumes/apps/tmp/* to a permanent shared storage in the target environment folder /cloudvolumes/apps/* using the vSphere C# client, GUI, or vSphere command-line.
d)      Select ‘Import AppStacks’ in App Volume Manager under Volumes > AppStacks.
e)      Select the LUN you moved all the AppStacks into (step c).
f)       Set the root path of where the AppStacks will live and select ‘Import.’

You can also use ‘vmkfstools’ if you have shell access to a host that can see the shared storage. This process is a lot more manual compared to using App Volumes Storage Groups, but you can still accomplish the migration using this method.

Execute the following syntax:

vmkfstools -i </source/location> </dest/location> 

This will copy the VMDK file in its current format from source to target.
(AppStacks VMDKs are Thin Provisioned by default).

Once you have copied the AppStacks you will need to ‘Import AppStacks’ from the App Volume Manager
(Volumes –> AppStacks –> Import AppStacks).

Reference this Knowledge Base for additional information when using the vmkfstools command:

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1028042

For more information, be sure to check out the following Education Course:


Jeremy Wheeler is an experienced senior consultant and architect for VMware’s Professional Services Organization, End-user Computing specializing in VMware Horizon Suite product-line and vRealize products such as vROps, and Log Insight Manager. Jeremy has over 18 years of experience in the IT industry. In addition to his past experience, Jeremy has a passion for technology and thrives on educating customers. Jeremy has 7 years of hands-¬‐on virtualization experience deploying full-life cycle solutions using VMware, CITRIX, and Hyper-V. Jeremy also has 16 years of experience in computer programming in various languages ranging from basic scripting to C, C++, PERL, .NET, SQL, and PowerShell.

Jeremy Wheeler has received acclaim from several clients for his in-¬‐depth and varied technical experience and exceptional hands-on customer satisfaction skills. In February 2013, Jeremy also received VMware’s Spotlight award for his outstanding persistence and dedication to customers and was nominated again in October of 2013