VMware leads the virtualization industry with Workstation for desktops and ESXi for the data center. Their hypervisor technology enables running multiple guest virtual machines (VMs) on physical host servers and workstations.

A major pain point for many virtual infrastructure admins and users is transferring files between guest VMs and hosts. VMware provides a seamless solution – the ability to share folders bi-directionally using shared folders.

In this comprehensive 3000+ word guide for Linux users, we will dig into everything you need to know about mounting VMware shared folders on Linux VMs from the command line.

Why VMware Shared Folders?

Before we get our hands dirty, it‘s important to understand why VMware shared folders are valuable:

  • Easy file transfers: Easily move files between guest OS and host without network or external storage.
  • Native integration: Shared folders have native integration with the VMware hypervisor and guest OS. No 3rd party tools needed!
  • Performance: The shared folders utilize the high-speed Virtual Machine Communication Interface (VMCI) for data transfer providing better performance over network file transfers.
  • Permission mapping: The mount options allow seamless mapping of permissions between host and guest for smooth integration.

Additionally, shared folders provide exclusively mounted file storage only accessible to the guest VM it is mounted in.

According to stats from the Uptime Institute, VMware holds over 50% of the virtualization market. With high adoption rates across enterprises, developer workstations, and personal usage, millions of shared folders facilitate simple file transfers globally each day!

Now let‘s get into the details on how Linux users can leverage this awesome technology…

Prerequisites

Before mounting VMware shared folders, confirm you have:

  • VMware Workstation/Fusion with guest VM created
  • Linux distribution as guest OS
  • Open VM Tools installed in guest VM – provides drivers for mounting

For example, I will demonstrate on an Ubuntu 20.04 VMware Workstation guest with Open VM Tools version 11.0.1 installed.

Share a Folder on the VMware Host

We first need to configure a folder share in the VMware host to make available to the guest:

  1. Power off the guest VM.

  2. Open VM Settings > Options > Shared Folders.

  3. Enable sharing and click Add to add new share.

  4. Browse and select the host folder then specify share details:

    Add VMware share

    • Share name: Simple label shown in VM UI.
    • Host path: Full absolute path of folder in host OS to share.
    • Enable share: Makes this share available.
    • Access: Read-only or Read/Write access from guest.
  5. Click Finish to add share.

Remember the share name defined here as it will be used later when mounting in the guest VM.

Mount VMware Share on Linux Guest

With share configuration done on the host, we are ready to mount it on our Linux guest VM:

  1. Power on Linux guest VM.

  2. Create the directory mountpoint where we will mount the share:

     mkdir ~/vmshare
  3. Use vmhgfs-fuse filesystem to mount VMware share:

     sudo mount -t vmhgfs-fuse .host:/<sharename> ~/vmshare

    Where <sharename> matches what was defined earlier during share configuration on the VMware host.

  4. By default, mounted share only allows root access. To enable access for non-privileged users, add allow_other option:

     sudo umount ~/vmshare 
     sudo mount -t vmhgfs-fuse -o allow_other .host:/<sharename> ~/vmshare

The VMware Tools component vmhgfs-fuse handles bridging the communication between guest VM and host OS to surface the shared folder to the guest Linux environment seamlessly.

Inside the guest, the VMware shared folder appears as a typical Linux-mounted filesystem but is redirecting all calls to the host filesystem for accessing the real folder transparently.

Automatically Mount on Boot

For persisting the mounted VMware share across guest VM reboots, we can add it to the Linux fstab file:

  1. Edit /etc/fstab as root:

     sudo nano /etc/fstab
  2. Add following line to auto-mount on boot:

     .host:/<sharename> /home/<user>/vmshare fuse.vmhgfs-fuse allow_other 0 0
  3. Save changes and reboot guest VM.

The share will now automatically mount on boot!

Transferring Files to Shared Folder

With share mounted, rapidly transfer files between guest and host using available file managers or command line:

Guest to Host

cp /path/on/guest/file ~/vmshare

Host to Guest

cp ~/vmshare/file /path/on/guest

This folder sharing makes moving files between environments extremely simple.

Shared Folder Permission Mapping

The guests kernel communicates with host ESXi hypervisor which directly interfaces with the host OS filesystem where the shared folder resides.

Consequently any files created in the mounted share actually reside on the hosts disk. By default, these appear to be owned by root inside guest.

We can map permissions to integrate shares cleanly into guest userspace using uid/gid mount options:

sudo mount -t vmhgfs-fuse -o uid=1000,gid=1000 .host:/share ~/mount

This maps guest user ID 1000 and group 1000 as owning files. Ensure that user/group exists in guest OS.

For matching permissions across multi-user enterprise guests, create a common group and use group ID mapping. This handles access control consistently across transient development guests while enabling collaboration.

Optimizing Transfers with Shared Folders

What makes VMware shared folders uniquely advantageous compared to other network file transfer mechanisms:

Feature Shared Folders SFTP SMB
Speed Up to 100 Gbit/s 1 Gbit/s 1 Gbit/s
Direct I/O Yes No No
Encryption No Yes Yes
Guest Integration Seamless None Partial
Protocol VMCI TCP/IP TCP/IP
  • Shared folders leverage a direct high-speed Virtual Machine Communication Interface (VMCI) channel rather than TCP/IP networking for immense transfer speeds.
  • There is practically zero latency and minimal processor overhead since it bypasses network hardware and the guest OS network stack.
  • No guest tools or configuration needed beyond Open VM Tools as it integrates seamlessly into the guest filesystem.

In summary, VMware shared folders provide by far the best performance for transferring data to and from VMs with minimal complexity.

Shared Folder Communication Internals

It helps to understand at a high level what occurs behind the scenes when accessing files from a mounted VMware share on a guest VM:

VMware Shared Folders Architecture

  1. On the ESXi host, the hvpd daemon manages pending I/O requests from clients.
  2. VM Tools running in guest has the Virtual Disk Lib component listening for file requests.
  3. When guest accesses a file on the mounted share, fuse directs the request to Virtual Disk Client (VDC).
  4. VDC connects to VMCI channel to hvpd and handles transfer request.
  5. hvpd passes request to Host OS file system.
  6. Real file contents get communicated back to the requesting guest VM Tools through VMCI after traversing the various host and guest components facilitating the seamless transition across this virtualization barrier.

Securing Shared Folders

Since shared folders provide easy access across trust boundaries between guest and host, it introduces some security considerations around legitimate usage:

  • Ensure guest tools are kept updated with latest security fixes.
  • Configure firewall policies to block unauthorized VMCI traffic between guests and hosts, enabled by default on ESXi.
  • Set strict Linux filesystem permissions on sensitive data rather than solely relying on share read-only settings.
  • In enterprise environments, isolate VM development workloads connecting to shares hosting source code or resources on separate vLANs and apply strict resource controls.

Properly secured, users can reap all the productivity benefits of effortless cross-environment file access without introducing additional attack surface or risks.

Troubleshooting Mount Issues

If encountering issues mounting or unreliable share connectivity, some things to check:

  • Verify Open VM Tools is installed and current release supported on the guest OS version.

  • Inspect messages logged when attempting to mount shares:

      dmesg | grep vmhgfs
  • Explicitly passing UID/GID with correct guest user/group ID ownership often resolves permission issues:

      mount -t vmhgfs-fuse -o uid=1000,gid=1000 .host:/share /mount  
  • Temporarily disabling SELinux in RHEL/CentOS guests can help narrow down policy conflicts.

  • If mounting mismacthed shares, rebooting both guest and host fully clears stale connections.

  • For high-latency connectivity, consider isolated vLAN for storage traffic and not using low-quality VPN transport.

Guest tools provide the critical glue integrating host hypervisor so keeping up-to-date avoids incompatibilities. Logging and specific mount options generally mitigate common issues encountered when using VMware shared folders.

Key Takeaways and Benefits

We covered quite a lot around utilizing this great feature – here are some key highlights:

  • Seamless integration: VMware tools enable effortlessly surfacing host folders in guests.
  • Top performance: VMCI transfers easily saturate modern multi-Gbit/s networks.
  • User friendly: Transparent usage for both CLI and GUI handling.
  • Secure isolation: Dedicated per-VM storage preventing data leakage.
  • Access controls: Configurable share and user/group permissions.

With a solid understanding of the end-to-end flow, troubleshooting basic issues, and suggested best practices – you are armed with everything needed to harness the true power of VMware shared folders!

Let me know in the comments if any part of using shared folders with your Linux VMs remains unclear or you have a specific usage question.

Similar Posts