How to add access to a NT file for ISO storage in ESX

In a small environment where storage is in scant supply, you may want to access a Windows share from your ESX server.  you may for example have an ISO store on a File server somewhere.

To do this from the ESX console you basically need to mount (similar to connecting a drive) the share to the ESX servers directory structure. What follows will walk you through the process, I have assumed a share UNC that is called WindowsServerShare:

  1. If needed create either a domain account or local server account and grant the account rights to the Windows share.
  2. From the command line on the ESX Server as root, enable smbclient on the firewall:
    esxcfg-firewall --enableService smbClient
  3. Create the mount point as root (a more meaningful name should be chosen):
  4. mkdir /mnt/smbshare
  5. To access the share issue the following command, remember to change the details to reflect your site:
mount –t smbfs –o username=MyDomainMyUserID,password=MyDomainPassword (lines wrap)
\WindowsServerShare /mnt/smbshare

To shorten the command, a file can be created that contains the username and password for the Windows share. Keep in mind that the password will be stored in clear text. The file will need to have permission applied to it.
At the command line as root, type in the following commands to create the file:

  1. echo username=DomainUser > ~root/.smbpasswd
  2. echo password=mySuperSecretPassword >> ~/.smbpasswd
  3. chmod 600 ~/.smbpasswd
  4. umount /mnt/smbshare

Make sure that you use a user name and password that has access to your share point. Now remount the share:

mount -t smbfs -o credentials=~root/.smbpasswd \WindowsServerShare /mnt/smbshare

The issue you have at the moment is that the mount point will go away after a reboot.  To have the SMB share mounted during each reboot, follow the steps below.

As root, start your favorite editor (like nano or vi) and save the following lines in /etc/init.d as smbshares:

#! /bin/sh
case “$1” in
echo “ Mounting SMB Shares…”
mount /mnt/smbshare &>2
echo “ Unmounting SMB Shares…”
umount /mnt/smbshare &>2

Change the permission to 755:

chmod 755 /etc/init.d/smbshares

Create link in rc3.d called S99smbshares to script in init.:

ln -s /etc/init.d/smbshares S99smbshares

As root, open /etc/fstab in your favorite editor and enter the following line at the bottom (make that you enter everything on one line):

 //rabk1/Software /mnt/smbshare smbfs credentials=/root/.smbpasswd,gid=users 0 0

That’s all there is to it. You now have a Windows file share available in the console after each reboot.