Tuesday, October 11, 2016

VMWare - CLI: Convert Virtual Disks - Thick to Thin


Here I show you how to convert  Thick Virtual Disk (all space provisioned at creation) to a Thin Virtual Disk (dynamic space allocation up to the provisioned size).

This is a good way to save space because with a Thin Virtual Disk, only occupies the space of the files It holds at the time.

Warning with a Thin Virtual Disk you migth run out of space in the Datastore and the Disk can’t grow up to the provisioned size.

thin-provisioning

!-- Log in via SSH (must activate first) --
# ssh root@192.168.1.45
Password: *******


!-- List DataStore Disks (if needed)--
# ls -lh /vmfs/volumes/


!-- Access the VM Folder --
# cd /vmfs/volumes/DS-VM-DISK/UBUNTU-VM/
# ls -lh

total 16779272
-rw-------    1 root  root   16.0G Oct 10 00:41 UBUNTU-VM-flat.vmdk
-rw-------    1 root  root    8.5K Oct 10 00:41 UBUNTU-VM.nvram
-rw-------    1 root  root     473 Oct  9 22:28 UBUNTU-VM.vmdk
-rw-r--r--    1 root  root       0 Oct  9 22:25 UBUNTU-VM.vmsd
-rwxr-xr-x  1 root  root    2.6K Oct 10 00:41 UBUNTU-VM.vmx
-rw-r--r--    1 root  root  187.4K Oct 10 00:41 vmware.log


!-- Convert the Virtual Disk - Thick to Thin --
# vmkfstools -i UBUNTU-VM.vmdk -d thin UBUNTU-VM_thin.vmdk
Destination disk format: VMFS thin-provisioned
Cloning disk 'UBUNTU-VM.vmdk'...
Clone: 100% done.


!-- Replace the Thick with Thin (Virtual Disks) --
# rm UBUNTU-VM-flat.vmdk
# mv UBUNTU-VM_thin-flat.vmdk UBUNTU-VM-flat.vmdk
# rm UBUNTU-VM_thin.vmdk


!-- All Looks as When We Started --
# ls -lh
total 3246088
-rw-------    1 root  root  16.0G Oct 10 23:59 UBUNTU-VM-flat.vmdk
-rw-------    1 root  root   8.5K Oct 10 23:59 UBUNTU-VM.nvram
-rw-------    1 root  root    471 Oct 10 23:57 UBUNTU-VM.vmdk
-rw-------    1 root  root      0 Oct 10 16:46 UBUNTU-VM.vmsd
-rw-------    1 root  root   2.5K Oct 10 23:59 UBUNTU-VM.vmx

Now you can power the VM :)

To Reverse It Check Out:

Sunday, September 18, 2016

Cisco - Upgrade Switches From Tar (Bin+Html)

To upgrade a Cisco Switch from a .tar (IOS and Html - Management Web Page), just start TFTP64:

image

and use the command:

  • archive download-sw xxxxxxxxxx

on the switch command line, this will download and install the .tar, and set it to boot next time.

I normally use is the my “Main Command” this should work in most cases, but you have other options like the ones shown in “Command Options”, that you can use “as is”, or by combining them like the “Main Command”.

 

Main Command

Download & Install - Overwrite & Different Feauture Set
============================================
Download from TFTP server and unpack tar
and install it (IOS and Html - Management Web Page)
even if the current and the new image have diferent
feature sets (ex: ipbase vs ipservices)

archive download-sw /overwrite /allow-feature-upgrade tftp://192.168.1.230/c3560-ipservicesk9-tar.150-2.SE.tar

OPTIONS USED
/allow-feature-upgrade - update/downgrade to
                                    different feature set
                         
/overwrite                   - overwrite everything in
                                    the flash with the new
                                    IOS tar image

 

Command Options

Download & Install
============================================
Download from TFTP server and unpack tar and
install it (IOS and Html - Management Web Page)

archive download-sw tftp://192.168.1.230/c3560-ipservicesk9-tar.150-2.SE.tar


Download & Install - Overwrite
============================================
Download from TFTP server and unpack tar and
install it (IOS and Html - Management Web Page)
and overwrite everything in the flash with the
new downloaded IOS tar image

archive download-sw /overwrite tftp://192.168.1.230/c3560-ipservicesk9-tar.150-2.SE.tar

 OPTIONS USED
/overwrite - overwrite everything in the flash
                    with the new IOS tar image

 
Download & Install - Different Feauture Set
============================================
Download from TFTP server and unpack tar
and install it (IOS and Html - Management Web Page)
even if the current and the new image have diferent
feature sets (ex: ipbase vs ipservices)

archive download-sw /allow-feature-upgrade tftp://192.168.1.230/c3560-ipservicesk9-tar.150-2.SE.tar

OPTIONS USED
/allow-feature-upgrade - update/downgrade to different feature set
 


Download & Install - Image Only
============================================
Download from TFTP server and unpack tar
and install it only the IOS (.bin) and deletes
the Html files (Management Web Page)

archive download-sw /imageonly  tftp://192.168.1.230/c3560-ipservicesk9-tar.150-2.SE.tar

 OPTIONS USED
 /imageonly - Install only the IOS (.bin) image and
                      delete the Html files (Management Web Page)
 
 
Download & Install - Safe
============================================
Download from TFTP server and unpack tar
and install it (IOS and Html - Management Web Page).

Waits for new IOS to be downloaded successfully
before deleting the old IOS

archive download-sw /safe tftp://192.168.1.230/c3560-ipservicesk9-tar.150-2.SE.tar

OPTIONS USED
/safe - waits for the new IOS to be downloaded
           successfully before deleting the old IOS
        

Base On: https://cyruslab.net/2012/06/03/maintenance-ios-upgradedowngrade-with-archive-download-sw-command/

Tuesday, August 23, 2016

VMWare - Linked Clones Without vCenter (with vSphere Client)


As soon as you can create snapshots you have all the ingredients required to create linked clones.

This will walk you through the process of creating a bunch of linked clones from one master.
Only tools used are the vSphere client and a text editor on a Windows host.
First create the master VM.

It is recommended to use a thin disk ...

Give it a reasonable name - so that it stands out from the other VMs.
In the example I called the VM "dont_touch"

clip_image001
Install the new VM and when done reboot it and install VMware-tools.

Feel free to add more apps ... or sysprep the master VM ...

Once you are satisfied power down the VM.
Now create a snapshot with the vClient.

See the screenshot - the files that belong to the snapshot are hilighted.
From now on regard the directory "dont_touch" as readonly. Do not start the VM again.

clip_image002
Next use the datastore browser and download the two files hilighted in the next screen : the vmx and the snapshot-vmdk.

 clip_image003
On your Windows-host the two downloaded files should now look like this.

Don't worry - the datastorebrowser is a funny guy - he shows you two files but downloads three.
And ... he thinks this is helpful ;-)

clip_image004
First thing to do is edit the "dont_touch-000001.vmdk"
It now looks like :

# Disk DescriptorFile
version=1
encoding="UTF-8"
CID=fa3d08b7
parentCID=fa3d08b7
createType="vmfsSparse"
parentFileNameHint="dont_touch.vmdk"
# Extent description
RW 25165824 VMFSSPARSE "dont_touch-000001-delta.vmdk"
# The Disk Data Base
#DDB
ddb.longContentID = "9b8da3d63cda1e5dbea7c0f4fa3d08b7"

As we want an absolute path for the parentFileNameHint parameter we edit the vmdk descriptor so that it looks like:

Note the yellow line ! It shows the edited path.

# Disk DescriptorFile
version=1
encoding="UTF-8"
CID=fa3d08b7
parentCID=fa3d08b7
createType="vmfsSparse"
parentFileNameHint="/vmfs/volumes/4ba3aca0-eca4fd60-312d-f4ce46af50b6/dont_touch/dont_touch.vmdk"
# Extent description
RW 25165824 VMFSSPARSE "dont_touch-000001-delta.vmdk"
# The Disk Data Base
#DDB
ddb.longContentID = "9b8da3d63cda1e5dbea7c0f4fa3d08b7"

Tip: to find out the absolut path look it up in the vmx file - the parameter sched.swap.derivedName also uses the absolut path.

sched.swap.derivedName = "/vmfs/volumes/4ba3aca0-eca4fd60-312d-f4ce46af50b6/dont_touch/dont_touch-aafe8f9c.vswp"

The part marked in yellow shows the absolute path that is required to adjust the vmdk-description.

Now is also a good time to delete that parameter from the vmx file. Don't forget that !
Now we can create several copies of the vmx-file.

Give every file a new name and adjust the display name parameter.

displayName = "2k3-clone-1"

Screenshot below shows several new copies of the vmx-file - each one has the display-name adjusted and the sched.swap.derivedName line removed.

clip_image005
Now back on the ESXi create several new directories for the clones.

clip_image006
Into each new directory copy the appropriate vmx-file plus the two vmdks.

Again - don't worry - you need to upload three files but datastorebrowser only displays two.

clip_image007
Now all is left to do is add the vmx-file to the inventory and make sure you click "I copied it" on first launch.
clip_image008
During first boot of the cloned VM it is advisable to unconnect the network-card.

On a Windows VM you may want to run newsid.exe, change the hostname and configure the network on first boot.

Then reboot and enable the nics.

Taken From: http://sanbarrow.com/linkedcloneswithesxi.html