Contents

Previous Next

Using Samba for File Sharing on a Linux Host Using Samba for File Sharing on a Linux Host
On a Linux host computer, GSX Server can automatically install and configure a Samba server to act as a file server for Microsoft Windows guest operating systems.
You can then use Windows Explorer in the virtual machine to move and copy files between virtual machine and host — or between virtual machines on the same network — just as you would with files on physical computers that share a network connection.
The lightly modified Samba server installed by GSX Server runs over the GSX Server virtual Ethernet, and the Samba traffic between different operating systems is isolated from actual local area networks.
The source code differences for the changes (in diff format and based on Samba 2.0.6) are available from VMware. For more information, see www.vmware.com/download/open_sources.html.
If you already have Samba configured on your Linux host, the recommended approach is to modify that configuration so it includes the IP subnet used by the GSX Server virtual Ethernet adapter, VMnet1.
You can configure your existing Samba server to work with a host-only network. Note that all the shares you set up in Samba and in the guest operating system normally appear on the bridged network as well.
If you need to be sure the shares set up in the guest operating system are seen only on the host-only network, you may find it easiest to install and use the Samba server provided with GSX Server.
If you do not need any shares to appear on your bridged network, you can use your existing Samba server and set up the configuration file so it works only on the host-only network.
Samba configurations can be quite complex. This section provides several sample configuration files. If you need to go beyond the issues covered here, see the man page for the smb.conf file. To view this man page, type one of the following commands in a terminal window:
man smb.conf
or
man 5 smb.conf
Pay particular attention to the section on encrypted passwords. If you have enabled clear-text passwords in the guest operating system, be sure that smb.conf is set up to use clear-text passwords. Similarly, if you are using encrypted passwords, you must have the same setting in the guest operating system and in smb.conf.
Note: Using Samba printer sharing with virtual machines is not supported. Consult the man pages for guidance on configuring Samba for printing.
Sample smb.conf for Host-Only Networking
The following sample Samba configuration file is for use with host-only networking. This configuration is for the 2.0.6 version of Samba installed by GSX Server. The configuration files are placed in /etc/vmware/vmnet1/smb by default.
# This is the VMware(TM) Samba configuration file. You should read the
# smb.conf(5) manual page in order to understand the options listed
# here. Samba has a huge number of configurable options
# most of which are not shown in this example
#
# Any line that starts with a ; (semicolon) or a # (hash)
# is a comment and is ignored. In this example we will use a #
# for commentary and a ; for parts of the config file that you
# may wish to enable
#
#
# Configuration file for Samba 2.0.6 vmware-[sn]mbd operating on
# vmnet1.
#
# This file was generated by the VMware configuration
# program and modified for this document.
#
# If you modify it, it will be backed up the next time you run the
# configuration program.

# Global settings
[global]

# This should be polled at install time from the private subnet created by
# vmware-config.pl
socket address = 192.168.183.1
interfaces = vmnet1
bind interfaces only = yes

workgroup = WORKGROUP
netbios name = HOSTNAME
server string = VMware host-only

security = user
encrypt passwords = yes

# Note: Printers not loaded in this example. Resource definitions commented
# below.
; load printers = yes

socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192

# VMware extension to use a different shared memory access key on each
# Samba server running on this host
sysv shm key = /dev/vmnet1

; log file = /etc/vmware/vmnet1/smb/var/log.smb
; log level = 1
; max log size in KB
; max log size = 50

lock directory = /etc/vmware/vmnet1/smb/var/locks

smb passwd file = /etc/vmware/vmnet1/smb/private/smbpasswd

codepage dir = /usr/lib/vmware/smb/codepages

dns proxy = no

# Shared resources

# Home directories
[homes]
comment = Home directories
browseable = no
writable = yes

# Printers
;[printers]
; comment = All printers
; path = /var/lpd
; browseable = no
; guest ok = no
; writable = no
; printable = yes

;[HostFS]
; comment = VMware host filesystem
; path = /
; public = no
; writeable = yes
; printable = no
Sample smb.conf for Bridged Networking
The following sample Samba configuration file is for use with bridged networking. This configuration file is based on the 2.0.7 version of Samba and assumes that you are using your existing Samba server, as provided with your host computer's Linux distribution. The configuration file is placed in /etc by default.
# This is the main Samba configuration file. You should read the
# smb.conf(5) manual page in order to understand the options listed
# here. Samba has a huge number of configurable options
# most of which are not shown in this example
#
# Any line that starts with a ; (semicolon) or a # (hash)
# is a comment and is ignored. In this example we will use a #
# for commentary and a ; for parts of the config file that you
# may wish to enable
#
# NOTE: Whenever you modify this file you should run the command
# "testparm" to check that you have not many any basic syntactic
# errors.

# Global Settings

[global]

interfaces = eth0

workgroup = WORKGROUP
netbios name = HOSTNAME
server string = Samba Host Box

# Note: Printers not loaded in this example. Resource definitions commented
# below.
; printcap name = lpstat
; load printers = yes
; printing = cups

socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192

log file = /var/log/samba/log.%m
max log size = 50

security = user
encrypt passwords = yes
smb passwd file = /etc/smbpasswd

dns proxy = no

preserve case = yes
short preserve case = yes
default case = lower
; case sensitive = no

# Shared Resources

[homes]
comment = Home Directories
browseable = yes
writable = yes

;[printers]
; comment = All Printers
; path = /var/spool/samba
; browseable = yes
; guest ok = yes
; writable = no
; printable = yes
; create mode = 0700
; print command = lpr-cups -P %p -o raw %s -r # using client side
; printer drivers.
; print command = lpr-cups -P %p %s # using cups own drivers (use
; generic PostScript on clients).
; lpq command = lpstat -o %p
; lprm command = cancel %p-%j

;[system]
; comment = System share
; path = /
; valid users = username
; public = no
; browsable = yes
; writable = yes
; printable = no
Adding User Names and Passwords to the GSX Server Samba Password File
You must be sure the Samba password file includes entries for all users of the virtual machine who will access the host's file system. The user names and passwords in the Samba password file must be the same as those used for logging on to the guest operating system.
You may add user names and passwords to the GSX Server Samba password file at any time from a terminal window on your Linux host computer.
1. Log on to the root account.
su -
2. Run the GSX Server Samba password command.
vmware-smbpasswd vmnet1 -a <username>
<username>
is the user name you want to add. Follow the instructions on the screen.
Note: vmware-smbpasswd is based on the standard Samba password program. If you are familiar with the options used in smbpasswd, you may use any of them in vmware-smbpasswd.
3. Log out of the root account.
exit
You may receive an error message that says
Unknown virtual interface "vmnet1"
This indicates your machine is not using the GSX Server Samba server.
If your installation of GSX Server does not include the GSX Server Samba server and you want to set it up, log on to the root account on your host computer (su -), then run vmware-config.pl from a terminal on the host. The configuration program asks
Do you want this script to automatically configure your system to allow your virtual machines to access the host file system?
Answer yes.
Caution: In order to configure GSX Server correctly, the vmware-config.pl configuration program requires all virtual machines to be shut down. The program shuts down any running virtual machines automatically.
If You Are Already Running Samba
If you already have Samba running on your Linux host, you should not install the GSX Server Samba server when you are installing GSX Server on your host.
The configuration program prompts you
Do you want this script to automatically configure your system to allow your virtual machines to access the host file system?
Answer no.
Be sure to modify your Samba configuration so it includes the IP subnet used by the GSX Server virtual Ethernet adapter, VMnet1.
To determine what subnet is being used by VMnet1, run
/sbin/ifconfig vmnet1
You must be sure the Samba password file includes entries for all users of the virtual machine who will access the host's file system. The user names and passwords in the Samba password file must be the same as those used for logging on to the guest operating system.
You may add user names and passwords to the Samba password file at any time from a terminal window on your Linux host computer.
1. Log on to the root account.
su -
2. Run the Samba password command.
smbpasswd -a <username>
<username>
is the user name you want to add. Follow the instructions on the screen.
3. Log out of the root account.
exit
Using a Samba Server for Both Bridged and Host-Only Networks
You may use the Samba server of your choice — either the existing Samba server from your host operating system's distribution or the one provided with GSX Server — for both host-only and bridged networking. To do so, you must modify one parameter in the smb.conf file. You can define the interface parameter so your Samba server serves multiple interfaces. An example of this is:
interface = eth0 vmnet1
This example tells the Samba server that it is to listen to and use both the eth0 and vmnet1 interfaces — the interfaces used by bridged and host-only networking, respectively.
Using GSX Server's Samba with an Existing Installation
It may also be possible to run both your existing Samba server and the GSX Server Samba server at the same time. In order to do this, your current Samba server must be version 2.0.6 or higher and must be configured correctly. However, this approach is not recommended.
To determine the version of your Samba server, run
smbd -V
If you want to try running both Samba servers at the same time, use this sample smb.conf file as a basis for configuring the regular Samba server on your host computer.
Sample smb.conf for Running Two Samba Servers at the Same Time
; This file is the recommended smb.conf file for your
; normal Samba server if you want to run it concurrently
; (which we don't advise) with the VMware Samba server.
;
; Your normal samba server should be at least v 2.0.6
;
; Note that you will need to insert specific information
; for your system at several points indicated in the file
; by <text in angle brackets>.
;
; --------------
;
; Larmor samba server configuration
;
; Global settings
[global]
;
; Identity
;
; Allow several Samba servers on the same machine
interfaces = <your real subnet>/<your real netmask>
bind interfaces only = yes
; Workgroup the host belongs to
workgroup = VMware
; SMB name of the host (the hostname by default)
netbios name = <your Windows name>
; Description of the host
server string = Linux running Samba 2.0.6
;
; Access
;
; Allow connections from
; hosts allow = <your real subnet>/<your real netmask>
; Authentication scheme
security = user
encrypt passwords = yes
;
; Options
;
; Automatically load the printer list (from /etc/printcap
; by default)
load printers = yes
; Gives better performance
socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
;
; Files and directories
;
; Max log size in KB
max log size = 1024
; Locks
lock directory = /var/samba
; SMB passwords
smb passwd file = /etc/samba/smbpasswd
;
; Name browsing
;
; Allow the host to participate in master browser
; elections
local master = yes
; Force a local browser election upon startup
; We need that otherwise it takes a long time before the
; windows network is browsable
preferred master = yes
; Do not try to resolve SMB names via DNS
dns proxy = no

; Shared resources
;
; Home directories
[homes]
comment = Home directories
browseable = no
writable = yes
; Printers
;[printers]
; comment = All printers
; path = /var/lpd
; browseable = no
; guest ok = no
; writable = no
; printable = yes
[Slash]
comment = Whole filesystem
path = /
public = no
writeable = yes
printable = no


Previous Next