Skip to content

Instantly share code, notes, and snippets.

@kallookoo
Last active October 15, 2024 18:10
Show Gist options
  • Save kallookoo/09df0bb28aa3c7927fb40c474923a411 to your computer and use it in GitHub Desktop.
Save kallookoo/09df0bb28aa3c7927fb40c474923a411 to your computer and use it in GitHub Desktop.
Script to enabling HGFS Shared Folders using the systemd
#!/usr/bin/env bash
if [[ "$(id -u)" -ne "0" ]]; then
echo "This script must be run as root, please run this script again with the root user or sudo."
exit 1
fi
if [[ ! -f /etc/modules-load.d/open-vm-tools.conf ]] || ! grep -qE '^fuse' /etc/modules-load.d/open-vm-tools.conf; then
echo "fuse" | tee -a /etc/modules-load.d/open-vm-tools.conf
fi
mkdir -p /mnt/hgfs
[ -f /etc/systemd/system/mnt-hgfs.mount ] && systemctl disable mnt-hgfs.mount --now
cat <<EOF >/etc/systemd/system/mnt-hgfs.mount
[Unit]
Description=VMware automount shared folders
DefaultDependencies=no
Before=umount.target
ConditionVirtualization=vmware
After=sys-fs-fuse-connections.mount
[Mount]
What=vmhgfs-fuse
Where=/mnt/hgfs
Type=fuse
Options=defaults,uid=1000,gid=1000
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable mnt-hgfs.mount --now
@kallookoo
Copy link
Author

kallookoo commented Oct 15, 2024

Note

How to:

curl https://gist.githubusercontent.com/kallookoo/09df0bb28aa3c7927fb40c474923a411/raw/systemd-hgfs.sh | sudo bash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment