Friday, December 10, 2010

How to deal with the virtual machines from the cli:

View number of virtual machines on host and location:

# vmware-cmd -l

Start a virtual machine:

# vmware-cmd ubuntu start

Stop a virtual machine:

# vmware-cmd ubuntu stop

View if a virtual machine is running:

# vmware-cmd ubuntu getstate

View how long a virtual machine has been running in seconds:

# vmware-cmd ubuntu getuptime

Reboot the virtual machine:

# vmware-cmd ubuntu reset trysoft

Create a snapshot and quiesce in the process:

# vmware-cmd ubuntu createsnapshot snap1 "first snapshot" 1 1 

Revert to a previous snapshot:

# vmware-cmd ubuntu revertsnapshot

Remove snapshots:

# vmware-cmd ubuntu removesnapshots

How to administer the service console's ip address

How to repair the ip address of the service console:

1. View the current state of the vswif interface by typing:
# esxcfg-vswif -l ; ifconfig vswif0

2.  Modify the ip address by typing:
# esxcfg-vswif -i -n vswif0

3. Add the vswif interface if needed by typing:
# esxcfg-vswif -a vswif0 -p "Service Console" -i -n

4. Verify vswif information by typing:
# cat /etc/sysconfig/network

Note: Esxi uses a vmkernel port so the commands are different.
On esxi, type esxcfg-vmknic and notice the examples at the end
of the output.

vcli examples

vcli examples:

Note: All these examples assume that the server has an ip address of

To backup and restore esxi settings:

# --server -s C:\esxibackup
 # --server -l C:\esxibackup

To modify and view hostname and dns information:

# --server --hostname wesker
# --server --domain
# --server --dhcp yes
# --server --dhcp no
# --server --dns,
# --server --vnic vmnic0
# --server

To modify and view ntp information:

# --server -l
# --server -a
# --server -d
# --server --start
# --server --stop

To modify nfs/nas information:

#  --server --list
# --server --add nfs1 --nasserver  --share /music
# --server --delete nfs1

Thursday, December 9, 2010

How to add users in esx//esxi

Adding users in esxi:

1. Log in as root
2. Create the /home directory with mkdir /home
3. Create the user with adduser user_name_here
4. When asked, enter the username's password
5. Take a look at the account with the command cat /etc/shadow; cat /etc/passwd

Adding users in esx:

1. Log in as root
2. Create the user with useradd -md /home/user_name
3. Give the user a password with the command passwd user_name
4. Verify the account by loggin in as the user or the su - username command
5. Type the exit command to be root again (if su was used) or log out.

How to enable webaccess in esx

What is webAccess:

WebAccess is a feature found in esx only (no esxi) that allows a user to access the virtual machines consoles via a browser. This feature is disabled by default.

To enable this feature, log in as root on the service console and perform the
following steps:

1. service vmware-webAccess start
2. service vmware-webAccess status
3.  chkconfig --level 345 vmware-webAccess on

How to recover from forgotten root password in esx

Recovery in 5 easy steps:

1. Power on your server
2. When faced with the grub menu, type "a" to stop the automatic boot sequence
3. Add the word "single" to the boot sequence shown and press enter
4. When faced with the recovery prompt, type "passwd" to change your password
5. Type "reboot" after changing your password

If your server has a grub password, an alternative is to boot from a live
linux cd, mount the /boot partition into /mnt and edit the grub.conf file in the
grub directory.