Last active
October 15, 2024 18:10
-
-
Save kallookoo/09df0bb28aa3c7927fb40c474923a411 to your computer and use it in GitHub Desktop.
Script to enabling HGFS Shared Folders using the systemd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note
How to: