Saturday, July 30, 2011

Share Windows 7 host files to Linux VMWare guest OS using Samba

If you have a Linux guest running on a Windows host, you may want to share the Windows drive to Linux. This way you can work more efficiently by keeping a single copy of files to work on both windows and linux; no file redundancy, no wastage of HDD space and no more copy paste between the OS's.  (You can mount not only the Windows host but also any Windows shared folders in your network by this method; Just put the IP address of the network Windows machine instead of the host IP.)

My settings:
Dell XPS 15z laptop with Windows 7 Home premium installed
OpenSUSE 11.4 64bit installed as guest VMware virtual OS (NAT network)

I want:
To share D: drive of Windows host on OpenSUSE Linux guest with full read write access. I should be able to delete/move/rename any files in D: drive on Linux as a Linux user(You may not want to do that for your C: drive Windows system files)

Part A: Prerequisite
1) An administrative Windows host user account (eg. user name= "YourWindowsHostUserName")

2) Shared windows folder with read-write permission: If you want to have full access to the windows files on Linux.(delete/move/rename)

Right click on the Windows folder/drive (D:\) > Properties > Sharing > Advanced Sharing >
a) Check sharing, give a name (eg. WindowsD) for the shared folder (This name will be used in Linux command later)
b) On permissions add the user; search for your user name in the panel; add it and give Full permission.

c) Now when go to Computer > Network you should be able to see a shared directory "WindowsD"

3) IP address of your Windows host:
a) Open windows command shell; (Windows Start menu > Programs > Accessories > Command Prompt)
b) Type 'ipconfig' without quotes. You can see an IP address like '192.168.?.?' if you are on a LAN. You will use this IP address in Linux mount command later.

4) Samba package installed on the Linux guest: Go to Yast and search for samba modules. If not installed, install them.(I'm not sure which one specifically)

PART B: Enable sharing in Guest Linux
1) Log into your user account in Linux VMware guest
2) Create a directory where you want to mount your windows files to (eg. /home/YourUserName/winD)
3) Open terminal and check whether you can connect to the Windows by ping

  ping 192.168.?.?

You will see the reply if it is connected.
4) Now you are ready to mount: Type the mount command:

sudo mount -t cifs -o username=YourWindowsHostUserName,password=YourWinodwsHostUserPassword,uid=YourLinuxGuestUserName,gid=users //192.168.?.?/WindowsD /home/YourLinuxUserName/winD

(all in one line)
You can leave the password option out. Then the windows login password will be asked in the prompt.

5) Now yow should be able to see the Windows D drive files in winD directory in you home. You will be able to delete/rename/move files with full control. (Be careful, delete will go to Linux trash, not windows Recycle bin; well, you know that)

Part C: Make this permanent to the system

If the mounting is successful you can make this permanent so that the files will be mounted on booting Linux guest. i.e, You don't need to mount it every time you log in and need to use the shared Windows directory.

1) Check whether cifs service is running on linux
Yast > System > System Services (Runlevel) and make sure that the service 'cifs' is enabled. If not, enable it.

2) Add the following line to /etc/fstab as root

//192.168.?.?/WindowsD /home/YourLinuxGuestUserName/winD cifs username=YourWindowsHostUserName,password=YourWinodwsHostUserPassword,uid=YourLinuxGuestUserName,gid=users,_netdev 0 0

(all in one line)

3) Now when you boot the next time, you should see the windows files on winD on your home directory

4) If you don't want to display the password in fstab do the following

a) Create a login credential file as root; eg: /etc/.smblogincredentials
b) Add the following lines to the file


c) Change the permission so that other users won't be able to read it.

chmod go-rwx /etc/.smblogincredentials

May be there is another easy way, but this is not that hard and works well for me so far. Hope this helped you in some way. Visit the reference web pages given below for more detailed explanations and options.

Reference and useful web links:
1) Samba HowTo: Mount a CIFS Network Share [Mapped Drive] in openSUSE
PS: That is an excellent How-To tutorial.

2) Access Windows Shares in Linux

3) VMWare community discussions

4) Some old info
Share files/folders from Windows to Linux on VMWare

Sharing Files Between Guest and Host Operating Systems


  1. Many thanks, it worked so fine for me.
    Great post!

  2. You're welcome Jordi. Thanks for your comment.

  3. Dear TechNetizen,

    I hope that god bless you !
    All day long i'm looking for the simple answer to this and only after i come across your site i found it. so simple - but even in the vmware help i didn't find it...

    Anyway this was very helpful.

    Thank you


  4. Hi Erez, I'm glad it helped you. Ya, it was not clear anywhere on the web, the reason I posted my experience on here. Thanks for showing your appreciation! It's a motivation for me to share similar useful stuffs.

  5. i just want to say thank you, for you instruction works for me.

  6. I am getting mount error[13] :permission denied