Vmware file sharing linux

VMware Workstation 3.2

Sharing Files Between Guest and Host Operating Systems

Sharing Files Between Guest and Host Operating Systems

To share files between a host computer and a virtual machine or between two virtual machines, you use the networking features of VMware Workstation. If you know how to share files between two physical computers on a network, you already know how to share files with a virtual machine.

This section describes four scenarios for sharing files between two systems, either a host computer and a virtual machine or two virtual machines, where

  • Both systems run Windows operating systems, using Windows file sharing
  • You are connecting from a Linux system to a Windows system, using smbmount
  • You are connecting from a Windows system to a Linux system, using Samba
  • Both systems run Linux operating systems, using NFS, FTP and Telnet

You can apply the same principles to share files between virtual machines. Configuration for FreeBSD guests is similar to that for Linux guests.

The following scenarios assume you have set up your virtual machine using NAT networking. Besides giving the virtual machine a direct connection to the host computer’s network, NAT networking sets up a virtual network adapter on the host computer. You can use this adapter, which connects to a virtual switch identified as vmnet8, to communicate between host and virtual machine. You can also connect two or more virtual machines using vmnet8. For details on NAT networking, see Network Address Translation (NAT).

In all cases, the user name you used to log in to the system from which you are connecting must be a user on the system to which you want to connect.

Sharing Files Between Two Windows Systems

Sharing Files Between Two Windows Systems

To share files between two Windows systems (where one machine is a host and the other is a virtual machine, or both are virtual machines), be sure the file and printer sharing service is installed for both operating systems and the folders you want to share are marked as shared. Then you can browse from one system to the shared folder or folders on the other system.

Sharing Files by Connecting to a Windows System from a Linux System

Sharing Files by Connecting to a Windows System from a Linux System

To share files on a Windows system with a Linux system (by connecting to a Windows host from a Linux guest or connecting to a Windows guest from a Linux host), you can mark a folder as shared on the Windows system, then use the smbmount utility in the Linux system to mount the shared folder. For example, if you want to share the folder C:\docs on a Windows 2000 system called win2k with a Linux system at /mnt/docs, follow the steps below. You may want to set up a shell script to run these commands.

    Set up the folder or folders to share on the Windows system.

Create a user account on the Windows system for the Linux system user name that you are using to connect to the Windows system.

Otherwise, if you know the user name and password for a user account that can access the Windows system, you can specify that account on the command line.

From your Linux system, log in as root.

Add the Windows system’s host name and IP address to the hosts file, if the system cannot be found by name.

Mount the Windows share on your Linux system. Enter the following command all on one line.

mount -t smbfs -o username= ,password=

(Substitute the appropriate host name, share and mount point for your systems.)

Note: If you do not want to expose this password on the command line or in a script, leave out that option and provide the password when prompted after you run the command.

Now you are connected to the shared folder on the Windows system from your Linux system and can begin to share files between the two.

Sharing Files by Connecting to a Linux System from a Windows System

Читайте также:  Джава 64 бит для windows

Sharing Files by Connecting to a Linux System from a Windows System

To share files on a Linux system with a Windows system (by connecting to a Linux host from a Windows guest or connecting to a Linux guest from a Windows host), you can run Samba on the Linux system and browse shared directories in the Linux file system from Network Neighborhood in the Windows system.

You need to modify Samba on the Linux host operating system so it recognizes the vmnet8 switch, otherwise you cannot access the Linux file system. You need to do this even if you installed host-only networking (as Samba is installed when you install host-only networking with VMware Workstation).

Connecting to a Linux Host from a Windows Guest

Connecting to a Linux Host from a Windows Guest

If you want to share the directory /home/user/shared, for example, on a Linux host operating system with a Windows guest operating system, follow these steps:

    On the Linux host operating system, copy the smb.conf file to a file called something like smb.conf.orig.
    cd /etc/vmware/vmnet1/smb
    cp smb.conf smb.conf.orig

Modify Samba on the Linux host system. Edit the following lines in
/etc/vmware/vmnet1/smb/smb.conf.

  1. Comment out the line starting with interfaces= .
  2. Below this line, add interfaces=vmnet1 vmnet8.
  3. Provide a network workgroup name. Set workgroup= .
  4. If you do not want to use the standard DNS name for the Linux system, set netbiosname= .
  5. You can leave security=user, unless you cannot connect, in which case use security=share.
  6. Set encrypt passwords=yes.
  7. In the [global] section, define a different shared memory access key. Add this line:
    sysv shm key=/dev/vmnet8
  8. For better performance, at this line:
    socket options = TCP_NODELAY
    edit the line to state:
    socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192

Note: This setting must be entered on one line.

  • To create the share, add the following:
    [SHARE_NAME]
    path = /home/user/shared
    public = no
    writable = yes
    printable = no
    (since you want to share files, not a printer)
  • Save this file and create a backup copy to protect these changes when you upgrade VMware Workstation.
  • Restart the Samba services to load the new settings.

    If VMware Workstation is running on the Linux host system, suspend or shut down all running virtual machines and close all VMware Workstation windows.

    On the Linux host operating system, at a command prompt, type

    On some Linux distributions, the command is

    Start VMware Workstation and run the Windows guest operating system from which you want to connect to the Linux host. The user ID you use to log in to the Windows guest must be in the Linux host's smbpasswd file. If you use the same user name and password to log in to the guest as you do on the Linux host, then you are not prompted to log in when you browse the Linux host.

    If you are connecting to the Linux system from a Windows Me, Windows 98 or Windows 95 guest operating system, NetBEUI must be installed in the guest operating system before you can browse the file system. If you need to install NetBEUI, you may need your Windows installation CD-ROM.

    When the system restarts, the Samba service does not appear in the list of services starting up, but it does start, unless an error appears.

    Connecting to a Linux Guest from a Windows Host

    Connecting to a Linux Guest from a Windows Host

    To share the directory /home/user/shared, for example, on a Linux guest operating system with a Windows host operating system, follow these steps:

      On the Linux guest operating system, copy the smb.conf file to a file called something like smb.conf.orig.
      cp /etc/smb.conf /etc/smb.conf.orig

    Modify Samba on the Linux system to share the directory. To create the share, add the following to /etc/smb.conf.

    [SHARE_NAME]
    path = /home/user/shared
    public = no
    writable = yes
    printable = no
    (since you want to share files, not a printer)

    Restart the Samba services to load the new settings. On the Linux guest operating system, at a command prompt, type:

    On some Linux distributions, the command is

    When the system restarts, the Samba service appears in the list of services starting up.

    Sharing Files Between Two Linux Systems

    Sharing Files Between Two Linux Systems

    To share files between two Linux systems (where one machine is a host and the other is a virtual machine, or both are virtual machines), you can use NFS on the system to connect to and the nfsmount utility in the system from which you are making the connection.

    As with any Linux network, you can use NFS, FTP or Telnet to connect from one Linux system (either virtual or physical) to another Linux system (either virtual or physical).

    Источник

    Vmware file sharing linux

    You are using an outdated browser. Please upgrade your browser to improve your experience.

    --> share-line

    --> --> --> --> plus

    After you enable a shared folder, you can mount one or more directories or subdirectories in the shared folder to any location in the file system in addition to the default location of /mnt/hgfs .

    Depending on the kernel version of the Linux guest operating system, VMware Tools uses different components to provide shared-folder functionality. In Linux kernels prior to version 4.0, the VMware Tools services script loads a driver that performs the mount. Linux kernels 4.0 and later use a FUSE file system component.

    You can use different mount commands to mount all shares, one share, or a subdirectory within a share to any location in the file system. The commands also vary depending on the Linux-kernel version of the guest.

    Table 1. Mount Command Syntax

    Linux Kernel Prior to 4.0 Linux Kernel 4.0 and Later Description
    mount -t vmhgfs .host:/ /home/user1/shares /usr/bin/vmhgfs-fuse .host:/ /home/user1/shares -o subtype=vmhgfs-fuse,allow_other Mounts all shares to /home/user1/shares
    mount -t vmhgfs .host:/foo /tmp/foo /usr/bin/vmhgfs-fuse .host:/foo /tmp/foo -o subtype=vmhgfs-fuse,allow_other Mounts the share named foo to /tmp/foo
    mount -t vmhgfs .host:/foo/bar /var/lib/bar /usr/bin/vmhgfs-fuse .host:/foo/bar /var/lib/bar -o subtype=vmhgfs-fuse,allow_other Mounts the subdirectory bar within the share foo to /var/lib/bar

    For Linux kernel prior to version 4.0, you can use VMware-specific options in addition to the standard mount syntax. Enter the command /sbin/mount.vmhgfs -h to list the options.

    For Linux kernel version 4.0 or later, enter the command /usr/bin/vmhgfs-fuse -h to list the available options.

    Источник

    VMware Workstation 5.0

    Using Samba for File Sharing on a Linux Host

    On a Linux host computer, VMware Workstation can 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 VMware Workstation runs over the VMware Workstation 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.

    Note: Starting with Workstation 5, Samba is no longer automatically configured when you run vmware-config.pl.

    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 VMware Workstation virtual Ethernet adapter, VMnet1.

    You can configure your existing Samba server to work with a host-only network. Note, however, 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 VMware Workstation. See Using Samba without Network Access.

    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:

    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 VMware Workstation. 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.

    # 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

    # 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.

    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

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

    [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

    Источник

    Читайте также:  Windows 10 top antiviruses
  • Оцените статью