In association with Zazzle.com

Linux Goodies

In Pursuit Of The Perfect O/S

Home Page Go To Small Telescope Astronomy Writing and Sci Fi humorous science shirt,comical science shirt,funny science shirt,zany science shirt,humorous math shirt,comical math shirt,Pi shirt,Pi day shirt,zany math shirt,funny linux shirt,comical linux shirt,linux nerd shirt,humorous linux shirt,computer geek shirt

VM File Sharing Between Linux Host And Windows Guests

Home

Linux General Info
Migrating from Windows
Programming Languages
Making Documents
Linux on an Old Laptop
Linux User Survey

Linux Astronomy
Kstars Planetarium
Stellarium Planetarium
Xephem Planetarium

Window Manager Reviews
Dwm
Fluxbox
FVWM
Idesk
Icewm
Ratpoison
Window Maker

Linux Hints and Tips
Linux App Hints
Linux Distro Hints
Forth Programming Hints

Linux Lite Apps
MtPaint

Linux Language Reviews
Gforth Review
Linux Matrix Languages
Euler Math Toolbox Review
Octave Language Review
PDL Language Review
R Language Review
Scilab Language Review
Tela Language Review
Yorick Language Review

Linux Virtual Machines
Virtual Machine Intro
Qemu Review
Vbox Review
VMware Review
VM File Sharing
Freedos in DOSEMU
Freedos in QEMU

Linux Distro Reviews
Antix Review
Puppy Linux Review
  Puppy On Flash
  Frugal Puppy

Favorite Sites
Science T-shirts
Science Limerick Posters
Math T-shirts
Linux T-shirts
Comical T-shirts
Bowling T-shirts
Free Craft Howto's
Building a Dobsonian Telescope


How do you share files between a Linux host and Windows guest?



So you've installed a Virtual Machine on your Linux system, and you've successfully installed one or more Windows guest operating systems.

Now you wish to be able to share files between the guest and the Linux host.

How do you do it?

I've worked with a few different Virtual Machines, including VMware server, VirtualBox, and QEMU. Each has its own suggested method of file sharing between guest and host. I found that each left a bit to be desired.

Some VM recommended methods

VMware file sharing methods

VMware has a couple of fairly direct methods to share files with the host. If you have spare disks or disk partitions, you can format them in vfat. Then in the VMware setup menus for any given guest, you can add the entire disks or partitions to the guest, where they will appear as other drives, like E:, etc.

With this method, the disks or partitions are always attached to the guest when it's booted, and can be mounted to Linux when the guest is not booted. What you don't want to do is try to have the disks or partitions mounted to both the guest and Linux at the same time.

If you set up networking in the guest, either as host only or as NAT, then you can simply FTP files to and from the host from the guest.

VirtualBox file sharing methods

The more recent versions of VirtualBox (versions 1.4 and newer) can, like VMware server, connect entire disks or disk partitions to the guest system. As with VMware, this system can work well, but precautions must be exercised.

As with VMware, it is only safe if the disks or disk partitions involved are only exclusively mounted to either the host or the guest, and that both systems do not try to mount the disks or partitions at the same time.

Through the guest additions packages in VirtualBox, a folder sharing mechanism is also available. This package makes available file sharing similar to the sharing between Windows systems. This method of sharing is only available to Windows guests of Windows 2000 or newer, and Linux guests.

Qemu file sharing methods

Qemu doesn't support the mounting of entire disks, but it can mount host directories as additional disks with the -hdb and -hdc command line parameters. While it is permissible by qemu to mount these directories in read/write mode, it's only safe if done in read only mode.

Thus this procedure, while easily implemented, is only useful for delivering files from the host to the guest.

Direct FTP support for qemu doesn't work. There is a described feature using TFTP for moving files to and from the host, but I was unable to get it to function. I also found from web surfing that apparently I wasn't the only one having trouble with that feature.


Another solution: SAMBA

After experimenting with the different Virtual Machines and guests, I was a bit frustrated that each Virtual Machine had its own preferred method of file sharing, and each method seemed either a bit clumsy (FTP or TFTP) or potentially dangerous (disk or partition sharing).

What I resorted to was a method I used some time ago when my network was setup to accommodate both Linux and Windows operating systems natively installed on respective computers. I made my Linux host a SAMBA server.

This proved easy to do, worked the same on guests in all of the Virtual Machines mentioned in this article, and worked even in older Windows guest systems such as Windows NT.

The procedure followed in my Debian Etch system was as follows:

Installed SAMBA with: sudo apt-get install samba
Added a user I wanted to use to the Linux system with adduser
Used smbpasswd to assign that user password for samba
Made entries into /etc/samba/smb.conf for folder shares
Made host directories corresponding to smb.conf entries
Edited workgroup name in smb.conf (if desired)
Made sure the virtual machine Windows install used the same user/password

In my Debian Etch distribution, the only changes I had to make to my smb.conf file were to set a workgroup name (use same workgroup in the guests) and add the directory access entries.

You really only need to change the default workgroup name if you have more than one samba server on your network. Each server should service a different workgroup.

The following is an example smb.conf entry for a shared folder:

[winnt]
browseable = yes
path = /home/bob/winnt
read only = no
valid users = bob
create mask = 0666
directory mask = 0777

Of course, you'll adjust the path and valid users to reflect requirements on your computer system.

For each host folder you wish to share, make an addition smb.conf entry like the one above, giving each a unique label (the bracketed entry).

On the guest, set the workgroup to match the setup in smb.conf.

Now add desired users to the smbusers file as followes:

sudo smbpasswd -a user

The smbpasswd utility will ask for the user password and add the user to the /etc/samba/smbusers file. If it does not, you may have to edit the /etc/samba/smbusers file and add the user and password, such as:

joe joespassword

You can read more about setting up samba at Samba Setup Guide.

With samba installed and these smb.conf entries, the guest network neighborhood should show the host as a local connection, and under the host the folders (smb.conf bracketed names). Now the guest can use the map drives feature to map the folders as a drives.

Whenever a guest with mapped drives is activated, the user will be prompted for the samba password, then the drive(s) will be mounted.

I find this to be one of the easiest, safest, and most universal file sharing methods across Virtual Machines running Windows guests.


Keen Designs T-Shirts and Mugs