Skip to content

Instantly share code, notes, and snippets.

@kkirsche
Last active May 17, 2022 14:09
Show Gist options
  • Save kkirsche/381e17fab1457ccf3b8b750edbc40b79 to your computer and use it in GitHub Desktop.
Save kkirsche/381e17fab1457ccf3b8b750edbc40b79 to your computer and use it in GitHub Desktop.
Mount or restart open VM toolchain
#!/bin/sh
# to install:
# git clone https://gist.github.com/381e17fab1457ccf3b8b750edbc40b79.git msd
# mv ./msd/mount-shared-folders /usr/local/bin
# rm -rf ./msd
# chmod +x /usr/local/bin/mount-shared-folders
# Source: https://gitlab.com/kalilinux/packages/kali-tweaks/-/blob/kali/master/data/mount-shared-folders
# vmware-hgfsclient is provided by the open-vm-tools package
# in some cases, this package is named open-vm-tools-desktop instead.
test $(id -u) -eq 0 || { echo "Please call this script with sudo" >&2; exit 1; }
vmware-hgfsclient | while read folder; do
vmwpath="/mnt/hgfs/${folder}"
echo "[i] Mounting ${folder} (${vmwpath})"
mkdir -p "${vmwpath}"
umount -f "${vmwpath}" 2>/dev/null
vmhgfs-fuse -o allow_other -o auto_unmount ".host:/${folder}" "${vmwpath}"
done
sleep 2s
#!/bin/sh
# Source: https://gitlab.com/kalilinux/packages/kali-tweaks/-/blob/kali/master/data/restart-vm-tools
test $(id -u) -eq 0 || { echo "Please call this script with sudo" >&2; exit 1; }
systemctl stop run-vmblock\\x2dfuse.mount
killall -q -w vmtoolsd
systemctl start run-vmblock\\x2dfuse.mount
systemctl enable run-vmblock\\x2dfuse.mount
vmware-user-suid-wrapper vmtoolsd -n vmusr 2>/dev/null
vmtoolsd -b /var/run/vmroot 2>/dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment