Archive for July, 2010


This script will mount user share from a Samba . It run on system startup ..Take the username and run a specific VB Script from a PC and mount the required share . Put the first script on system startup
======================================================================================================
@echo off
for /f “tokens=3 delims=\” %%i in (“%USERPROFILE%”) do (set user=%%i) 2>&1
echo “logged in user:%user%”
set var=%user%

net use U: \\10.80.0.38\NetScripts wizard /user:opennms
copy U:\”%var%”.vbs c:\
cd C:\
“%var%”.vbs
del C:\”%var%”.vbs
net use U: /d
======================================================================================================

Then put this VBS script on the other network PC .According to this example I have put this vb script as mohammada.VBS ON 10.80.0.38 on share NetScripts.

======================================================================================================
‘ ########################################################################
‘ Written in VBScript.
‘ Establishes map drives.
‘ Assign to OU Group Policy under USER CONFIG, WINDOWS SETTINGS, SCRIPTS, LOGON SCRIPT.

‘ This script will:
‘ (1) check if the drive is already connected and, if so, disconnect it.
‘ (2) map the drive.

‘ Arguments are as follows:
‘ MAPIT DRIVE-LETTER as string, PATH as string, USER as string, PASSWORD as string
‘ (1) Do not specify colon in drive letter.
‘ (2) Do not end path with a forward slash.
‘ (3) If user and password are not required to establish map, then specify a zero-length string as follows: “”

‘ Reference Microsoft info at:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/wsmthmapnetworkdrive.asp
‘ ########################################################################

‘ Create the Shell or environment for the commands:
Set WshShell = WScript.CreateObject(“WScript.Shell”)
‘ Define objects:
Set WshNetwork = WScript.CreateObject(“WScript.Network”)
Set oDrives = WshNetwork.EnumNetworkDrives()

‘ ====================================
‘ DEFINE WHO TO CONTACT for pop-up messages:
‘ ====================================
strContactMessage = “If you require assistance, please contact IT Support.”

‘ ==================
‘ DEFINE DRIVES TO MAP:
‘ ==================
Mapit “F”, “\\10.80.0.2\Fshared”, “administrator”, “password”
Mapit “B”, “\\10.80.0.3\BBoat”, “administrator”, “password”
Mapit “X”, “\\10.80.0.1\Shared”, “mohammada”, “password”
Mapit “R”, “\\10.80.0.1\it_tech”, “mohammada”, “password”
Mapit “Z”, “\\10.80.0.1\Common”, “mohammada”, “password”
Mapit “H”, “\\10.80.0.1\MohammadA”, “mohammada”, “password”

‘ ========
‘ CLEAN UP:
‘ ========
Set WshShell = Nothing
Set WshNetwork = Nothing
Set oDrives = Nothing

‘ ##################################
‘ DO NOT MODIFY ANYTHING BELOW THIS POINT…
‘ unless you are familiar with the proper settings.
‘ ##################################
Sub Mapit(strLetter, strPath, strUser, strPass)

‘ Define the DriveLetter:
DriveLetter = strLetter & “:”

‘ Define the remote path:
RemotePath = strPath

‘ Pop-up Notices (set to False to disable notices, otherwise set to True):
bPopReminder = True

‘ Define known errors to trap:
Dim arrErrCode(1)
Dim arrErrDesc(1)
arrErrCode(0) = -2147023694
arrErrCode(1) = -2147024811
arrErrDesc(0) = “Unable to map drive ” & DriveLetter & ” to ” & RemotePath _
& ” due to a previously defined remembered map with the same letter.” _
& vbCrLf & vbCrLf & “Please MANUALLY disconnect map drive ” & DriveLetter _
& “, then Log Out and Log back in.”
arrErrDesc(1) = “Unable to map drive ” & DriveLetter & ” to ” & RemotePath _
& ” since ” & DriveLetter & “: was previously reserved by your computer.” _
& vbCrLf & vbCrLf & “(Refer to Management, Shared Folders, Shares)”

‘ Define whether the map information should be removed from the current user’s profile:
bForceRemoveFromProfile = True
bRemoveFromProfile = True

‘ Define whether the map information should be stored in the current user’s profile:
bStoreInProfile = False

‘ Check if already connected:
AlreadyConnected = False
For i = 0 To oDrives.Count – 1 Step 2
If LCase(oDrives.Item(i)) = LCase(DriveLetter) Then AlreadyConnected = True
Next

‘ Attempt to map the drive. If already mapped, first attempt disconnect:
If AlreadyConnected = True then
WshNetwork.RemoveNetworkDrive DriveLetter, bForceRemoveFromProfile, bRemoveFromProfile
If Not strUser = “” Then
WshNetwork.MapNetworkDrive DriveLetter, RemotePath, bStoreInProfile, strUser, strPass
Else
WshNetwork.MapNetworkDrive DriveLetter, RemotePath, bStoreInProfile
End If
‘ If bPopReminder Then WshShell.PopUp “Drive ” & DriveLetter & ” disconnected, then connected successfully to ” & RemotePath
Else
On Error Resume Next
If Not strUser = “” Then
WshNetwork.MapNetworkDrive DriveLetter, RemotePath, bStoreInProfile, strUser, strPass
Else
WshNetwork.MapNetworkDrive DriveLetter, RemotePath, bStoreInProfile
End If
If Err.Number 0 Then
bKnownError = False
For I = LBound(arrErrCode) To UBound(arrErrCode)
If Err.Number = arrErrCode(I) Then
bKnownError = True
strPopMessage = arrErrDesc(I)
‘ Display the Disconnect Network Drives window:
If Err.Number = arrErrCode(0) Then
Set objWSH = Wscript.CreateObject(“WScript.Shell”)
objWSH.Run “rundll32.exe shell32.dll,SHHelpShortcuts_RunDLL Disconnect”, 1, true
End If
Exit For
End If
Next
If Not bKnownError Then
strPopMessage = “Unable to map drive ” & DriveLetter & ” to ” & RemotePath _
& ” due to reason stated below.”
End If
‘ Display warning message:
strPopMessage = “WARNING!! WARNING!! WARNING!! WARNING!!” _
& vbCrLf & vbCrLf & strPopMessage _
& vbCrLf & vbCrLf & Err.Description & ” (error ” & Err.Number & “)” _
& vbCrLf & vbCrLf & strContactMessage
WshShell.PopUp strPopMessage
Else
‘ If bPopReminder Then WshShell.PopUp “Drive ” & DriveLetter & ” connected successfully to ” & RemotePath
End If
End If

wscript.sleep 200
End Sub
======================================================================================================


This script will monitor and count file number in a givven folder . If that count reach the thresold level of 15,
It will popup a message on screen and send an email to specifil email account .For sending email you need to install “bmail” program
for windows and put bmail.exe in c:\
=============================================================================================
@echo off
set _Count=0
for /F “tokens=1,2 delims= ” %%i in (‘dir F:\labvalapp\comms\solar2labval’) do if (%%j)==(File(s)) set _Count=%%i
if (%_Count%)==() goto EXIT
if %_Count% LEQ 15 goto EXIT
echo “Please Check……there is some problem in Auto Validation in MINOS”
cd c:\
bmail -s 10.80.0.50 -t root@gorgon.au.specsavers.com -f monitor@au.specsavers.com -b ” Please check Auto Validation” -a ” Problem in Minos Auto Validation”
pause
:EXIT
set _Count=
=============================================================================================


Adding a new disk to a Linux

Senario:

I am using a Vmware Virtual Box and just added a new HDD on that . I am not going through how I have done it . You can check this post for reference on that . Assuming the HDD is added and now go through the following.

[root@aurhel05 ~]# fdisk /dev/sdb

The number of cylinders for this disk is set to 3916.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/sdb: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Command action
e   extended
p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-3916, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-3916, default 3916):
Using default value 3916

Command (m for help): p

Disk /dev/sdb: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        3916    31455238+  83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@aurhel05 ~]# fdisk -l

Disk /dev/sda: 32.2 GB, 32259548160 bytes
255 heads, 63 sectors/track, 3922 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1         131     1052226   83  Linux
/dev/sda2             132         784     5245222+  83  Linux
/dev/sda3             785        1437     5245222+  83  Linux
/dev/sda4            1438        3918    19928632+   5  Extended
/dev/sda5            1438        1698     2096451   83  Linux
/dev/sda6            1699        1959     2096451   82  Linux swap / Solaris
/dev/sda7            1960        2220     2096451   82  Linux swap / Solaris
/dev/sda8            2221        2481     2096451   83  Linux
/dev/sda9            2482        2612     1052226   83  Linux
/dev/sda10           2613        3918    10490413+  83  Linux

Disk /dev/sdb: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        3916    31455238+  83  Linux

[root@aurhel05 ~]# mkfs.ext3 /dev/sdb1

mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
3932160 inodes, 7863809 blocks
393190 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
240 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 25 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

[root@aurhel05 ~]# mkdir /u02

[root@aurhel05 ~]# mount /dev/sdb1 /u02

[root@aurhel05 ~]# mkdir /u02

[root@aurhel05 ~]# mount /dev/sdb1 /u02

[root@aurhel05 ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on
/dev/sda9            1020M  632M  337M  66% /
/dev/sda10             10G  5.1G  4.4G  54% /u01
/dev/sda8             2.0G   36M  1.9G   2% /tmp
/dev/sda5             2.0G  161M  1.8G   9% /home
/dev/sda3             5.0G  5.0G     0 100% /var
/dev/sda2             5.0G  2.4G  2.4G  50% /usr
/dev/sda1            1020M   42M  927M   5% /boot
tmpfs                  12G     0   12G   0% /dev/shm
/dev/sdb1              30G  173M   28G   1% /u02

[root@aurhel05 ~]# vi /etc/fstab

LABEL=/                 /                       ext3    defaults        1 1
LABEL=/u01              /u01                    ext3    defaults        1 2
LABEL=/u02              /dev/sdb1                    ext3    defaults        1 2
LABEL=/tmp              /tmp                    ext3    defaults        1 2
LABEL=/home             /home                   ext3    defaults        1 2
LABEL=/var              /var                    ext3    defaults        1 2
LABEL=/usr              /usr                    ext3    defaults        1 2
LABEL=/boot             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
LABEL=SWAP-sda6         swap                    swap    defaults        0 0
LABEL=SWAP-sda7         swap                    swap    defaults        0 0

Save and exit . This will mount that pertition automatically after next reboot.


Problem :

I added one of no use syntax in /etc/fstab and  after reboot to single mode and then use vi to edit /etc/fstab that display this file
is read-only mode, so I cannot edit it ….. now I cannot go back to  normal boot up.

Solution :

In Single user mode type the following ,

mount -o remount,rw /

Then vi /etc/fstab and then you will be able to amend the file again .


Moving the swap file to an alternate datastore is a useful troubleshooting step if the virtual machine or guest operating system is experiencing failures, including STOP errors, read only filesystems, and severe performance degradation issues during periods of high I/O. However, identifying and resolving the underlying overcommit or storage performance issues is still recommended to ensure environment stability.
This can also be used to store the virtual machine swap files in an alternate non-replicated datastore when using LUN snapshot technologies to ensure that you are storing the swap files in a location that is not being replicated.

ESX 3.5 and ESX 4.0

To edit the virtual machine swap file location in ESX 3.5 and ESX 4.0:

  1. Connect directly to your ESX Server host or to your VirtualCenter server using the VI Client.
  2. Click the Configuration tab for the ESX Server host.
  3. Click Virtual Machine Swapfile Location and click Edit.
  4. Specify the datastore where you want the virtual machine swap files stored.
  5. After restarting your virtual machines, ensure the swap file is located on the specified host datastore.

ESX 3.0

Add the following line to your virtual machine’s configuration (VMX) file to store the swap on a VMFS3 volume:
sched.swap.dir= “/vmfs/volumes/<volume_name>/<dir_name>”
Where <volume_name> is a VMFS3 volume
To change the swap file location:
  1. Connect to VirtualCenter or directly to your ESX Server host using the Virtual Infrastructure Client (VI Client).
  2. Select either a virtual machine or a virtual machine template that you want to modify.
  3. Stop the virtual machine if it is running.
  4. Connect to the ESX console using SSH or service console connection.
  5. Change directory to the path of the .vmx file you want to edit.
    Note: Use the ‘vmware-cmd –l’ command to find the path to the configuration file. For more information on the vmware-cmd command, see the
    VMware Scripting API .
  6. Open the configuration file and add the line sched.swap.dir= “/vmfs/volumes/<volume_name>/<dir_name>”.
  7. Delete the line sched.swap.derivedName = xxx.
  8. Restart the virtual machine if it’s not a template.
  9. Repeat as necessary for each existing virtual machine
Advantage :
Faster VM Booting, Better VM Performace, Faster vMotioning and DRS, Faster VM evacuation when ESX host is entering maintenance mode
Ref : kb.vmware.com

Error :

Today was trying to do a V2V convertion with Vmware VConverter standalone edition . I have done that 100’s of time but today it stopped in the state of “Retrieving Source machine Information ” While checking on the converter server agent log , it was basically stopped in “uname -m” State . Whith some time spending with error log and vmware community site I have came up with the following  solution and it worked for me .Thought,  I need to share this with you.

Solution :

Log Location : /var/log/vmware-vcenter-converter-standalone

Symptoms

  • Converter Standalone stops responding for 10 minutes while displaying Retrieving source machine information.
  • Converter Standalone displays the following error message when you click Next on the Specify Source page: Unable to query the live Linux source machine.

Purpose

This article describes the process of troubleshooting an issue where you might be unable to perform a P2V conversion of a powered-on Linux source machine. You can follow the given steps to eliminate a specific cause for your problem by verifying that your login environment does not include an incompatible command.

Resolution

You must perform both troubleshooting steps listed below. Each step provides instructions or a link to a document, in order to eliminate possible causes and take corrective action as necessary. The steps are ordered in the most appropriate sequence to isolate the issue and identify the proper resolution.

If you perform a corrective action in any of the following steps, attempt converting the Linux source operating system again.

  1. Verify that the Linux source operating system is accepting ssh traffic and that the user name and password used in Converter are correct and result in a functional shell prompt.
    1. From the Linux source operating system, open a shell prompt, type ssh localhost, and press Enter. Log in using the same user name and password used in the Conversion wizard.
      If this does not result in a successful login, correct the problem.

      Note
      : For more information on opening a shell prompt, see Opening a command or shell prompt (1003892).
    2. From the computer running Converter, open a command prompt, run telnet xxxx nn, where xxxx is replaced by the host name or IP address of the Linux source operating system and nn is replaced by the port being used for SSH.
      If this does not result in information being displayed, a firewall might be preventing the computer running Converter Standalone from connecting to the Linux source operating system. Correct this problem.
  2. Confirm that the .bashrc file of the user name being used for authentication does not contain an echo command.

    If authenticating as root, use a text editor to edit /root/.bashrc. If authenticating as a different user, use a text editor to edit /home/user name/.bashrc, where user name is replaced by the user name being used for authentication.

    If a line in the file begins with echo, either delete it or change it to #echo.   <<<—– This was my Problem 🙂

3.   Ensure that the /tmp directory on the source machine is writable. If it is not, then the Converter agent will not be able to write to it and it will fail.

Ref :

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


“Why has a vSphere VM max mem 255GB? VMFS block size of 1MB = 256GB max – 0.4MB VM state = 255.6MB rounded down to 255GB – from Ole@VMware”


In other words, the maximum memory size for a vSphere VM is 255 GB. This is the maximum memory size because a swap file needs to be created as well. This swap file cannot exceed the maximum file size of a 1MB blocksized VMFS volume. Max file size = 256GB – VM state(roughly 400MB)=255.6GB. For safety this has been rounded down to 255GB. Which at first sounds like a weird amount but actually makes sense when you read the explanation.