Base on my previous post, this would be another post in my VCAP-DCA Preparation series (DCAS).
It’s about storage and how to add new storage (iSCSI) to the hosts.
There is two ESXi 4.1 hosts with one NIC, one vSwitch (vSwitch0) and two VMKernel port (vmk0 & vmk1) and both have their local datastores for sure.
Adding one shared storage using iSCSI (which provided by Starwind iSCSI SAN Software) to both hosts by using commands (DCUI and/or SSH) not vSphere Client.
First thing first, for accessing iSCSI in ESXi there is two way, using Hardware iSCSI initiator or Software iSCSI initiator which comes by ESXi which is disabled by default.
In my home lab, I’m going to use Software iSCSI and for this purpose I must enable the software iSCSI initiator.
After enabling the initiator (adapter), I’m going to configure it so it would connect to my storage server.
Then it’s time for selecting the proper LUN and mounting it in “/vmfs/volumes/”, all these steps should be taken for both hosts. so here the exact steps I’ve taken to use the iSCSI storage with my hosts.
A. Enabling adapter and connecting to iSCSI server
For checking if the software iSCSI is enabled on the host, the “esxcfg-swiscsi -q” can be used to query for the status of adapter.
If it’s enabled, it’s your luck but if not, it can be enable by using “esxcfg-swiscsi -e”.
And it’s good if you check for the result of your action by using “esxcfg-swiscsi -q” which going to query for the status again.
For further actions the name of the iSCSI adapter would be needed, so it’s better to check it right, there’s a lot of way to check it but I used “vim-cmd hostsvc/summary/hba” command, also “esxcfg-swiscsi -s” command can be use as well which going to scan the Software iSCSI adapter and will print it’s name on the screen.
As the name of Software iSCSI adapter checked before, we can use it now like “vim-cmd hostsvc/storage/iscsi_add_send_target vmhba33 192.168.10.20” (192.168.10.20 is my storage server and can be replaced).
It seems the host can’t see anything on the server yet, well, when doing same thing (adding target to the iSCSI initiator) using the vSphere Client, after closing the configuration box, it will prompt and ask for the scan of the target but here, there wasn’t such a prompt (or question) so we should do it manually by using “vim-cmd hostsvc/storage/hba_rescan vmhba33”.
This command would make the host to rescan the specific HBA (vmhba33 here) for the changes.
As the above picture shows, the last line indicate that the host can see one LUN from vmhba33 which is “eui.78ea5cf3….”, for further actions the device name and UUID would be needed so it’s better to write them somewhere for further use.
As the result of these actions (up to now), we can see the storage on “/vmfs/devices/disks/” but it’s not ready for use yet. for make it ready for use, we should move to the next step (B. Mounting the proper LUN).
B. Mounting the proper LUN
After connecting the host to the storage server, it’s time for mounting and using it.
For checking the available datastore on the hosts “ls /vmfs/volumes/” can be used, this command will list all available datastore which mounted under “/vmfs/”.
As the above picture showed, there is no sign of shared storage (lun-003) in “/vmfs/”.
For mounting the target, first it must be formated as VMFS and prepared for further actions.
For formating the target, we must know the proper device and it can be find using “fdisk -l” command.
“fdisk -l” command will list all available disks which host is now using or can use.
As we noted the information about shared disk before, we can use it now for preparing the disk.
“fdisk /dev/disks/eui.78ea5cf3…” would be used to selecting the correct disk for working on it (eui.78ea5cf3… is the device name in my home lab and can be different on other places).
If any help is needed when using the “fdisk” command, “m” key can showing the list of available action and their shortcuts.
For checking the available partition on the target disk, “p” key can be used and as it’s new LUN and not used anywhere else, it should be empty.
As the help shows before (which shown up used by “m” key), “n” would help us to create new partition on the disk. after typing “n” and pressing the enter, four questions would be asked:
1. about type of partition, if it’s going to be “primary” or “extended” (can be select by “p” and “e” respectively)
2. Partition number, which I’m going to select the first one (default is 1)
3. First Cylinder, which I’m going to select the default again (default is 1)
4. Last Cylinder, which going to be set as default (default is 6527)
As the above picture showing, the “System” type is “Linux” and we need “VMFS”, so we have to change/convert it to VMFS partition before moving to the next step and this convertion can be done by pressing “t” and pressing enter after it, the typing “fb” for “HEX Code”, the result can be checked be pressing “p” key again.
For saving the changes we made to the disk, we need to type “w” for writing purpose and pressing the enter key.
Let check the conclusion of our action up to now by using “fdisk -l” for listing the partitions and disks available to the host.
For creating new datastore in ESXi we can use “vmkfstools” and this command need some informations to work correctly, one of these informations is the place of device/disk which we want to make it usable for the host.
First I’ve typed “vmkfstools -C vmfs3 -S lun-003 /vmfs/devices/disks/” and pressed “TAB” two time so the system listed available options (datastores here) for me.
Following picture showing available options to me and the second line “eui.78ea5cf3601f0df9:1” was the point which I needed for this step, first partition on the disk which is provided by my Storage and it’s accessible trough vmhba33.
C. Checking both hosts for the results 1
As the last task in adding new storage to the hosts, I had to check the availability of new datastore on the second host, so I used “putty” to connect to second host and start checking for the volume by using “ls /vmfs/volumes”.
It seems the new datastore (lun-003) is not shown up automatically in the second host. well, if you have time for it, you can wait a little and it will shown up but if you want to do things faster by yourself, “vim-cmd hostsvc/storage/vmfs_rescan” can help.
System will start showing some lines on screen which passing very fast and will stop after finishing the rescan task. I found two items on the screen (on the log of “rescan” task) which are relevant to the new datastore (lun-003 & eui.78ea5cf3…).
1 during my exercise, I have removed and added the storage multiple times, and the screen shots are taken from different series, so if the name are the same but the information is changed, it’s because of host selection (which one going to have the storage first).
- “esxcfg-swiscsi -q” can be use for checking the status of software iSCSI on the host.
- “esxcfg-swiscsi -e” can be use for enabling the software iSCSI feature on the host.
- For listing available datastore which can be used at the time, “ls /vmfs/volumes” can be use.
- “vim-cmd hostsvc/storage/hba_rescan vmhbaX” will rescan specific HBA and vmhbaX would be the name of HBA for rescan.
- “vim-cmd hostsvc/storage/vmfs_rescan” will rescan for any changes to VMFS file system (and mounted disks)
- “vim-cmd hostsvc/storage/iscsi_add_send_target iSCSIID address port” will add specific target to the list of target of specific HBA, where iSCSIID is the name of “vmhba” (in case of using software iscsi in ESXi vmhba33), “address” is the ip address of storage server (in my case 192.168.10.20) and port is optional if the storage is providing the service on any port different than 3260 (for iSCSI).
- “vim-cmd hostsvc/summary/hba” will list all available HBA on the host.
- “vim-cmd hostsvc/summart/scsilun” will list all available datastore (are currently used or can be used).
- “vmkfstools” can be used to create, delete or manage datastores and virtual disks