Configuring Persistent Shared Folders in Ubuntu Virtual Machines on VMware

Establishing Host-Guest File Sharing

Ensure VMware Tools is installed on the guest operating system. Create a designated directory on the host machine for data exchange and verify the path.

Verifying and Creating the Mount Point

First, confirm that the virtual machine detects the shared folder configuration.

vmware-hgfsclient

Check if the standard mount directory exists within the file system.

test -d /mnt/hgfs && echo "Exists" || echo "Not found"

If the directory is absent, manually create the mount point.

sudo mkdir -p /mnt/hgfs

Manual Mounting and Permission Handling

Attempt to mount the shared folder. By default, the mount inherits root permissions. To allow the current user to read and write, determine the user ID (UID) and group ID (GID).

MY_UID=$(id -u)
MY_GID=$(id -g)

Execute the mount command using the specific permissions to avoid access denied errors.

sudo vmhgfs-fuse .host:/ /mnt/hgfs -o allow_other -o uid=$MY_UID -o gid=$MY_GID

If the mount fails due to the directory not being empty, include the nonempty flag.

sudo vmhgfs-fuse .host:/ /mnt/hgfs -o nonempty -o allow_other -o uid=$MY_UID -o gid=$MY_GID

Configuring Automatic Mounting

To persist the configuration across reboots, edit the filesystem table.

sudo nano /etc/fstab

Insert the following configuration line at the bottom of the file. Substitute the UID and GID with the values retrieved previously.

.host:/ /mnt/hgfs fuse.vmhgfs-fuse allow_other,uid=1000,gid=1000,umask=022 0 0

Tags: Linux Ubuntu VMware System Administration devops

Posted on Thu, 07 May 2026 08:18:07 +0000 by bh