Archive for the ‘VMWare’ Category

VM migration script

Saturday, April 3rd, 2021

#!/bin/sh

cd /vmfs/volumes/datastore1
scp -r root@192.168.100.27:/vmfs/volumes/datastore1/$1 .
cd $1
vmkfstools -i $1.vmdk -d thin $1-thin.vmdk
rm -f $1.vmdk $1-flat.vmdk
vmkfstools -E $1-thin.vmdk $1.vmdk
vmkfstools -K $1.vmdk
vim-cmd solo/registervm /vmfs/volumes/datastore1/$1/$1.vmx
cd

Estimate SSD lifetime on vmware

Wednesday, July 13th, 2016
  1. Obtain SSD Device id
    esxcli storage core device list
  2. Display Storage Statistics
    esxcli storage core device stats get -d=device_id

~ # esxcli storage core device stats get -d=t10.ATA_____KINGSTON_SUV400S37240G__________________50026B77650B37C4____
t10.ATA_____KINGSTON_SUV400S37240G__________________50026B77650B37C4____
Device: t10.ATA_____KINGSTON_SUV400S37240G__________________50026B77650B37C4____
Successful Commands: 21917
Blocks Read: 190610
Blocks Written: 84677
Read Operations: 7753
Write Operations: 12038
Reserve Operations: 694
Reservation Conflicts: 0
Failed Commands: 12041
Failed Blocks Read: 0
Failed Blocks Written: 0
Failed Read Operations: 0
Failed Write Operations: 0
Failed Reserve Operations: 0

mount NFS using CLI in VMWare ESXi

Sunday, January 31st, 2016

#dismount

/sbin/esxcfg-nas -d ghetto

#mount

/sbin/esxcfg-nas -a ghetto -o 192.168.100.31 -s /ghetto

Dismount a staled NFS volume in ESXi 5.x

Saturday, April 26th, 2014

esxcli storage nfs list

Screen Shot 2014-04-26 at 5.26.55 pm

esxcli storage nfs remove -v nfsvol1

REHL file system become read only in VMWare

Saturday, March 29th, 2014

This become a known issue for RHEL if you are on a busy I/O storage.

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

Work around is to remount the filesystem using the following command.

mount -o remount /

ghettoVCB.sh modification required for ESX 5.1

Thursday, November 29th, 2012

vm backup script will fail with “You’re not running ESX(i) 3.5, 4.x, 5.x!”

Fix: change ghettoVCB.sh

231c231
< if [[ “${ESX_VERSION}” == “5.0.0” ]]; then

> if [[ “${ESX_VERSION}” == “5.0.0” ]] || [[ “${ESX_VERSION}” == “5.1.0” ]]; then

Enable Net:SSH2 to connect to EXSi

Monday, November 12th, 2012

1. Enable SSH from vSphere Client
2. ssh to the vSphere server and edit /etc/ssh/sshd_config
change
PasswordAuthentication no
to
PasswordAuthentication yes

3. restart ssh /etc/init.d/SSH restart

ESXi 5.x Allow SMTP Firewall Setup

Monday, July 23rd, 2012

Create this file:
/etc/vmware/firewall/smtp.xml

<ConfigRoot>
<service id=”0033″>
<id>smtp</id>
<rule id=’0000′>
<direction>outbound</direction>
<protocol>tcp</protocol>
<porttype>dst</porttype>
<port>25</port>
</rule>
<enabled>true</enabled>
<required>false</required>
</service>
</ConfigRoot>

 

Restart Firewall Services
esxcli network firewall refresh

To enable persistency after reboot

copy smtp.xml to a place that have persistant storage, then

vi /etc/profile.local (5.1) or vi /etc/rc.local (5.0)

add

cp /vmfs/volumes/nas03.iscsi/firewall/smtp.xml /etc/vmware/firewall/smtp.xml
esxcli network firewall refresh

replace /vmfs/volumes/nas03.iscsi/firewall/smtp.xml with the storage location

Also upon restart, need to ssh logon to trigger the effect (no idea why it only execute only during ssh logon)

Upgrading ESXi 4.0 to ESXi 4.1 without vCenter Upgrade Center

Sunday, April 10th, 2011

You can use the vSphere CLI 4.0 vihostupdate.pl to upgrade your ESXi server.

Before you start the upgrade – you will need to meet the following pre-requisities.

First – Download VMware vSphere CLI 4.0 and Install it on Windows or Linux

Download vSphere CLI 4.0

Next Download VMWare 4.0 to 4.1 Zip Package

Once the above pre-requisties have been meet, we can now take it into action.

1. Shutdown all of your Virtual Machines

2. Enable VM Host in Maintenance Mode

3. Execute the following command and see what is available in the upgrade package

vihostupdate.pl –server vm4 –scan –bundle “e:\temp\upgrade-from-esxi4.0-to-4.1-update01-348481.zip”

4. Install ESXUpdate

vihostupdate.pl –server vm4 -i -b “e:\temp\upgrade-from-esxi4.0-to-4.1-update01-348481.zip” -B ESXi410-GA-esxupdate

5. Upgrade to ESXi 4.i

vihostupdate.pl –server vm4 -i -b “e:\temp\upgrade-from-esxi4.0-to-4.1-update01-348481.zip” -B ESXi40-TO-ESXi41UPDATE01

6. Check and ensure everything is installed properly

vihostupdate.pl –server vm4 –query

7. Reboot your server

8. Disable Maintenance Mode in VM Host

 

reference: https://www.vmware.com/pdf/vsphere4/r41/vsp_41_upgrade_guide.pdf

Converting Thick Disk to Thin Provisioned Disk

Tuesday, March 8th, 2011

vmkfstools -i thick.vmdk -d thin thin.vmdk