Skip to content

Instantly share code, notes, and snippets.

@neelabhg
Created March 6, 2017 08:28
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • 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"
@ketanarlulkar
Copy link

ketanarlulkar commented Apr 4, 2020

Hi @neelabhg do we need to add some option while starting qemu OS image for this to work?

On my Windows 10 host, I have installed QEMU and Arch Linux Guest on QEMU.
After that I created and shared a folder in Windows 10 Host, which I have shared with everyone.

Then started my VM by qemu-system-x86_64.exe -m 2G -drive file=arch.hd command.
Now I'm trying to mount that shared folder from Arch Linux using following command.
mount -t cifs -o user=windows_username,domain=windows_domain_name //10.0.2.2/Share_directory /home/user/local_mount

I'm getting error mount error(2): No such file or directory.
I tried by giving vers option as well, still no luck.

@0make
Copy link

0make commented Jun 12, 2020

@neelabhg
Copy link
Author

Hi @neelabhg do we need to add some option while starting qemu OS image for this to work?

On my Windows 10 host, I have installed QEMU and Arch Linux Guest on QEMU.
After that I created and shared a folder in Windows 10 Host, which I have shared with everyone.

Then started my VM by qemu-system-x86_64.exe -m 2G -drive file=arch.hd command.
Now I'm trying to mount that shared folder from Arch Linux using following command.
mount -t cifs -o user=windows_username,domain=windows_domain_name //10.0.2.2/Share_directory /home/user/local_mount

I'm getting error mount error(2): No such file or directory.
I tried by giving vers option as well, still no luck.

Hi @ketanarlulkar,

I had written this script quite some time ago. I believe I was using Windows 7. I don't remember if there were any special options passed to QEMU when starting it.

@neelabhg
Copy link
Author

I saved the steps on my blog, hope to save your time.

http://alanzheng.top/doku.php?id=tutorials:tools:qemu_windows_host_share_folder_with_linux_guest

Sure, that's fine!

@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