Skip to content

Instantly share code, notes, and snippets.

@neelabhg
Created March 6, 2017 08:28
Show Gist options
  • Save neelabhg/8c6bfcdb44c0aa3f86bed00fe1f6da49 to your computer and use it in GitHub Desktop.
Save neelabhg/8c6bfcdb44c0aa3f86bed00fe1f6da49 to your computer and use it in GitHub Desktop.
Mount a Windows host's folder on a QEMU Linux guest
#! /bin/bash
# The Windows folder needs to be shared appropriately
WINDOWS_DIR_PATH="//10.0.2.2/workdir"
MNTPOINT="/workdir_local"
if [ ! -d "$MNTPOINT" ]; then
mkdir $MNTPOINT
fi
if [ -z "$WIN_USERNAME" ]; then
echo "Please set WIN_USERNAME in .bashrc"
exit 1
fi
umount $MNTPOINT > /dev/null 2>&1
echo "Use your Windows password to mount $WINDOWS_DIR_PATH at $MNTPOINT"
mount -t cifs -o user="$WIN_USERNAME",uid=501,gid=501 "$WINDOWS_DIR_PATH" "$MNTPOINT"
@WanghongLin
Copy link

Here is my solution to mount a Windows host shared folder on Ubuntu guest

On Windows host, a shared folder need to be setup, right click a folder, Properties -> Sharing, e.g shared_windows_folder

On Ubuntu guest, do the following

sudo apt install cifs-utils
sudo mount.cifs -o user=$WINDOWS_USER,uid=1000,gid=1000 //10.0.2.2/shared_windows_folder /mnt

You will see shared_windows_folder content on /mnt.

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