How to create a vmfs file system from the command line
1. After adding a new disk, type esxcfg-scsidevs -c (compressed view) to gather
information about all the disks and the runtime name of the new device
In this example, the runtime name was mpx.vmhba1:C0:T1:L0
2. Use the fdisk command to partition the new disk and set the partition type to
0xfb (vmfs type). In this case, I used the command used was:
fdisk /dev/disks/mpx.vmhba1:C0T1L0.
You may need to use commands like "p" to view the existing partitions, "n" to
create a new one using 100% of the disk and "t" to specify the type. Once this
is done, use the "w" command to write/save the changes.
This is what the disk will look like by the time one is finished:
# fdisk /dev/sdh
The number of cylinders for this disk is set to 10240.
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/sdh: 10.7 GB, 10737418240 bytes
64 heads, 32 sectors/track, 10240 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Device Boot Start End Blocks Id System
/dev/sdh1 1 10240 10485744 fb VMware VMFS
3. Once the disk is partitioned properly, the vmkfstools command is needed. To
create a new file system and a new datastore, The command used was:
vmkfstools -C vmfs3 -b 1M -S MyDatastore mpx.vmhba1:C0:T1:L0:1
or
vmkfstools -C vmfs3 -b 1M -S Daniel /vmfs/devices/disk/naa.60060160e09028008e4d328c91a2df11:1
Final Note: The -S option was used to specify the datastore name
The -b option was used to specify the block size
The -C option was used to create a new file system
The :1 option used at the end of the command specifies the new slice
How to grow the file system by using a second extent:
Use the vml (symbolic link) of the second disk and add it to the original disk (the one with the
file system). Use the -Z option to add another extent. Don't use the -G option. The -G option
grows the file system size by using the rest of the first disk (whatever is unused).
Obtain the information about the two disks you are using:
cd /vmfs/devices/disks
ls -al | grep -i naa.60060160e09028008e4d328c91a2df11
ls -al | grep -i naa.60060160e0902800ef19e58491a2df11
Add the second extent to the first one:
vmkfstools -Z vml.020011000060060160e0902800ef19e58491a2df11524149442035:1 vml.020012000060060160e09028008e4d328c91a2df11524149442035:1
Friday, January 21, 2011
The power of the vim-cmd command
Despite not having a service console, esxi has a lot of commands available. Want something done from the command line NOT using the esxcfg command? No problem. What follows are examples of the capabilities of the vim-cmd command when a virtual machine is concerned.
# vim-cmd vmsvc
Commands available under vmsvc/:
acquiremksticket get.configoption power.off
connect get.datastores power.on
convert.toTemplate get.disabledmethods power.reboot
convert.toVm get.environment power.reset
createdummyvm get.filelayout power.shutdown
destroy get.guest power.suspend
device.connection get.guestheartbeatStatus reload
device.connusbdev get.managedentitystatus setscreenres
device.disconnusbdev get.networks snapshot.create
device.diskadd get.runtime snapshot.dumpoption
device.diskaddexisting get.snapshotinfo snapshot.get
device.diskremove get.summary snapshot.remove
device.getdevices get.tasklist snapshot.removeall
device.toolsSyncSet getallvms snapshot.revert
device.vmiadd gethostconstraints snapshot.setoption
device.vmiremove login tools.cancelinstall
devices.createnic logout tools.install
get.capability message tools.upgrade
get.config power.getstate unregister
get.config.cpuidmask power.hibernate upgrade
List all of the vms registered in that esxi host:
# vim-cmd vmsvc/getallvms
Vmid Name File Guest OS Version Annotation
32 WinXP-ibex01-a [SharedVMs] WinXP-ibex01-a/WinXP-ibex01-a.vmx winXPProGuest vmx-07 OneSizeXP-R40c.vmdk
64 WinXP-ibex01-c [SharedVMs] WinXP-ibex01-c/WinXP-ibex01-c.vmx winXPProGuest vmx-07 OneSizeXP-R40c.vmdk
How to halt a virtual machine:
# vim-cmd vmsvc/power.off 32
or
# vim-cmd vmsvc/power.shutdown 32
Powering on VM:
# vim-cmd vmsvc/power.on 32
Reboot a VM:
# vim-cmd vmsvc/power.reboot 32
(vim.fault.ToolsUnavailable) {
dynamicType = <unset>,
faultCause = (vmodl.MethodFault) null,
msg = "Cannot complete operation because VMware Tools is not running in this virtual machine.",
}
Get network related information:
# vim-cmd vmsvc/get.networks 32
Networks:
(vim.Network.Summary) {
dynamicType = <unset>,
network = 'vim.dvs.DistributedVirtualPortgroup:DVPG-a6 77 07 50 43 f3 38 cd-01 b9 dd 92 d3 d4 e7 b0-dvportgroup-146',
name = "Production",
accessible = true,
ipPoolName = "",
}
Get storage related information about a vm:
# vim-cmd vmsvc/get.datastores 32
name SharedVMs
url /vmfs/volumes/4d333ff0-28d4682c-49ea-00237da51830
capacity 145492017152
freeSpace 31078744064
accessible 1
type VMFS
multipleHostAccess <unset>
Get snapshot related information about a vm:
# vim-cmd vmsvc/snapshot.get 32
Get Snapshot:
|-ROOT
--Snapshot Name : 01%2f20%2f2011 15:04:40
--Snapshot Desciption :
--Snapshot Created On : 1/20/2011 14:59:11
--Snapshot State : powered on
Remove all snapshots for that vm:
# vim-cmd vmsvc/snapshot.removeall 32
# vim-cmd vmsvc/snapshot.get 32
Create a snapshot for that vm:
# vim-cmd vmsvc/snapshot.create 32 snappy
# vim-cmd vmsvc/snapshot.get 32
Get Snapshot:
|-ROOT
--Snapshot Name : snappy
--Snapshot Desciption :
--Snapshot Created On : 1/20/2011 20:0:9
--Snapshot State : powered off
Remove just one snapshot:
# vim-cmd vmsvc/snapshot.remove 32 snappy
# vim-cmd vmsvc
Commands available under vmsvc/:
acquiremksticket get.configoption power.off
connect get.datastores power.on
convert.toTemplate get.disabledmethods power.reboot
convert.toVm get.environment power.reset
createdummyvm get.filelayout power.shutdown
destroy get.guest power.suspend
device.connection get.guestheartbeatStatus reload
device.connusbdev get.managedentitystatus setscreenres
device.disconnusbdev get.networks snapshot.create
device.diskadd get.runtime snapshot.dumpoption
device.diskaddexisting get.snapshotinfo snapshot.get
device.diskremove get.summary snapshot.remove
device.getdevices get.tasklist snapshot.removeall
device.toolsSyncSet getallvms snapshot.revert
device.vmiadd gethostconstraints snapshot.setoption
device.vmiremove login tools.cancelinstall
devices.createnic logout tools.install
get.capability message tools.upgrade
get.config power.getstate unregister
get.config.cpuidmask power.hibernate upgrade
List all of the vms registered in that esxi host:
# vim-cmd vmsvc/getallvms
Vmid Name File Guest OS Version Annotation
32 WinXP-ibex01-a [SharedVMs] WinXP-ibex01-a/WinXP-ibex01-a.vmx winXPProGuest vmx-07 OneSizeXP-R40c.vmdk
64 WinXP-ibex01-c [SharedVMs] WinXP-ibex01-c/WinXP-ibex01-c.vmx winXPProGuest vmx-07 OneSizeXP-R40c.vmdk
How to halt a virtual machine:
# vim-cmd vmsvc/power.off 32
or
# vim-cmd vmsvc/power.shutdown 32
Powering on VM:
# vim-cmd vmsvc/power.on 32
Reboot a VM:
# vim-cmd vmsvc/power.reboot 32
(vim.fault.ToolsUnavailable) {
dynamicType = <unset>,
faultCause = (vmodl.MethodFault) null,
msg = "Cannot complete operation because VMware Tools is not running in this virtual machine.",
}
Get network related information:
# vim-cmd vmsvc/get.networks 32
Networks:
(vim.Network.Summary) {
dynamicType = <unset>,
network = 'vim.dvs.DistributedVirtualPortgroup:DVPG-a6 77 07 50 43 f3 38 cd-01 b9 dd 92 d3 d4 e7 b0-dvportgroup-146',
name = "Production",
accessible = true,
ipPoolName = "",
}
Get storage related information about a vm:
# vim-cmd vmsvc/get.datastores 32
name SharedVMs
url /vmfs/volumes/4d333ff0-28d4682c-49ea-00237da51830
capacity 145492017152
freeSpace 31078744064
accessible 1
type VMFS
multipleHostAccess <unset>
Get snapshot related information about a vm:
# vim-cmd vmsvc/snapshot.get 32
Get Snapshot:
|-ROOT
--Snapshot Name : 01%2f20%2f2011 15:04:40
--Snapshot Desciption :
--Snapshot Created On : 1/20/2011 14:59:11
--Snapshot State : powered on
Remove all snapshots for that vm:
# vim-cmd vmsvc/snapshot.removeall 32
# vim-cmd vmsvc/snapshot.get 32
Create a snapshot for that vm:
# vim-cmd vmsvc/snapshot.create 32 snappy
# vim-cmd vmsvc/snapshot.get 32
Get Snapshot:
|-ROOT
--Snapshot Name : snappy
--Snapshot Desciption :
--Snapshot Created On : 1/20/2011 20:0:9
--Snapshot State : powered off
Remove just one snapshot:
# vim-cmd vmsvc/snapshot.remove 32 snappy
Wednesday, January 19, 2011
How to recover from forgotten root password in esxi
What follows is a procedure to recover from a forgotten root password in ESXI
20 steps to recovery // Non-supported procedure
Note: This was done with a physical server (not nested esxi) & an Ubuntu cd
01. Power off your esxi server. This will obviously not be a clean shutdown.
02. Insert a linux live cd and boot from it (ubuntu linux was used in this case)
03. Once running from the live cd, open up a terminal
04. Type sudo mount /dev/sda5 /mnt (sda was the boot disk in this case)
05. Type ls /mnt and verify that this partition has the state.tgz file
06. Type sudo cp /mnt/state.tgz /tmp
07. Type cd /tmp to change directories to /tmp
08. Type sudo gzip -d state.tgz
09. Type sudo tar xvf state.tar
10. Type sudo gzip -d local.tgz
11. Type sudo tar xvf local.tar
12. Type cd etc to access the directory that contains the shadow file
13. Type sudo vi shadow to edit the file and use the "x" letter to remove the password
14. Type cd /tmp to go back to the /tmp directory
15. Type sudo tar czvf local.tgz etc to recreate the local.tgz file
16. Type sudo tar czvf state.tgz local.tgz to recreate the state.tgz file
17. Type sudo cp state.tgz /mnt to put the file back into its original location
18. Type sudo reboot to reboot the esxi host. Remove the live cd
19. Log into the esxi server
20. Change the root password by typing passwd. This will update the /etc/shadow file.
Note: The shadow file should be edited carefully. Make sure that you remove
only the password and nothing else. The password resides in the second
field of the first line. By the time you are done, the line should say root::
(nothing between the two ":", don't erase the ":"s. The rest of the line will
have a series of numbers. Leave them alone.
20 steps to recovery // Non-supported procedure
Note: This was done with a physical server (not nested esxi) & an Ubuntu cd
01. Power off your esxi server. This will obviously not be a clean shutdown.
02. Insert a linux live cd and boot from it (ubuntu linux was used in this case)
03. Once running from the live cd, open up a terminal
04. Type sudo mount /dev/sda5 /mnt (sda was the boot disk in this case)
05. Type ls /mnt and verify that this partition has the state.tgz file
06. Type sudo cp /mnt/state.tgz /tmp
07. Type cd /tmp to change directories to /tmp
08. Type sudo gzip -d state.tgz
09. Type sudo tar xvf state.tar
10. Type sudo gzip -d local.tgz
11. Type sudo tar xvf local.tar
12. Type cd etc to access the directory that contains the shadow file
13. Type sudo vi shadow to edit the file and use the "x" letter to remove the password
14. Type cd /tmp to go back to the /tmp directory
15. Type sudo tar czvf local.tgz etc to recreate the local.tgz file
16. Type sudo tar czvf state.tgz local.tgz to recreate the state.tgz file
17. Type sudo cp state.tgz /mnt to put the file back into its original location
18. Type sudo reboot to reboot the esxi host. Remove the live cd
19. Log into the esxi server
20. Change the root password by typing passwd. This will update the /etc/shadow file.
Note: The shadow file should be edited carefully. Make sure that you remove
only the password and nothing else. The password resides in the second
field of the first line. By the time you are done, the line should say root::
(nothing between the two ":", don't erase the ":"s. The rest of the line will
have a series of numbers. Leave them alone.
Wednesday, January 12, 2011
Getting info with the vsish command (esxi only)
The vsish command is used to gather information from an esxi host. It is an extremely powerful utility.
Once the command is typed, the ls command shows the contents of a working directory and the cat
command can be used to see the contents of a file. Finally, the cd command can be used to change
directories.
The first example shows how to get the maximum transfer unit for a particular vmnic.
/bin # vsish
/> cd net
/net/> cd pNics
/net/pNics/> ls
vmnic0/
vmnic1/
vmnic2/
vmnic3/
/net/pNics/> cd vmnic1
/net/pNics/vmnic1/> cat mtu
MTU {
mtu:1500
}
/net/pNics/vmnic1/> q
The second example shows how to gather cpu related information for a host.
/bin # vsish
/> cd hardware
/hardware/> cd cpu
/hardware/cpu/> ls
packageList/
cpuList/
cpuModelName
cacheInfo
cpuInfo
/hardware/cpu/> cat cpuInfo
CPU global information {
Hyperthreading state:Hyperthreading state: 3 -> enabled
HV state:HV state: 3 -> HV Enabled
Number of packages:2
Number of cores:8
Number of CPUs (threads):16
HV Replay capable:1
Reason replay is disabled on Host:Reason replay is disabled on Host: 0 -> HV Replay is supported
}
/hardware/cpu/> q
Once the command is typed, the ls command shows the contents of a working directory and the cat
command can be used to see the contents of a file. Finally, the cd command can be used to change
directories.
The first example shows how to get the maximum transfer unit for a particular vmnic.
/bin # vsish
/> cd net
/net/> cd pNics
/net/pNics/> ls
vmnic0/
vmnic1/
vmnic2/
vmnic3/
/net/pNics/> cd vmnic1
/net/pNics/vmnic1/> cat mtu
MTU {
mtu:1500
}
/net/pNics/vmnic1/> q
The second example shows how to gather cpu related information for a host.
/bin # vsish
/> cd hardware
/hardware/> cd cpu
/hardware/cpu/> ls
packageList/
cpuList/
cpuModelName
cacheInfo
cpuInfo
/hardware/cpu/> cat cpuInfo
CPU global information {
Hyperthreading state:Hyperthreading state: 3 -> enabled
HV state:HV state: 3 -> HV Enabled
Number of packages:2
Number of cores:8
Number of CPUs (threads):16
HV Replay capable:1
Reason replay is disabled on Host:Reason replay is disabled on Host: 0 -> HV Replay is supported
}
/hardware/cpu/> q
Subscribe to:
Posts (Atom)