Template for Help Pages

SHARING FILES BETWEEN AN UBUNTU HOST AND A VIRTUALBOX GUEST WITHOUT GUEST ADDITIONS

I. Introduction

This document outlines a procedure for setting up an internal network between a Virtual Guest Machine running on a computer using an Ubuntu operating system as Host, for the purpose of sharing files between the Virtual Guest machine and the Host Operating System. While much of what is covered may seem trivial to an experienced Network Administrator, setting up such a network can be a difficult issue for some of us. This is a special case involving the use of Windows 98SE as the Guest Operating System. Those most likely to benefit from this procedure include:

  • Those with a need to preserve legacy applications that will not run properly on newer equipment or operating systems
  • Those with a need for traditional asynchronous serial communications no longer supported by modern equipment (i.e., RS-232 Serial Communications)

This procedure most likely would not be necessary were one using a newer version of Windows for the Guest operating system.

Having made the decision to switch my computers to the Ubuntu operating system for a variety of reasons, I am faced with an issue regarding some critical legacy applications that were originally written for the Windows 98 operating system, related to several pieces of equipment that I use for data acquisition (although dated, this equipment is still quite functional and meets most of my data acquisition needs. To replace it would involve an investment of several thousand dollars. Some of the software does not function properly under later versions of Windows, like XP and Vista). Some of these applications run fine under Wine, but Wine does not support usb connections. Facing the issue of a lack of RS232 interfaces on newer computers, it is necessary to provide the required connection to external equipment utilizing an RS232 to usb adapter.

After evaluating a number of different virtualization solutions, we determined that the VirtualBox PUEL would be the most appropriate solution for our needs (we are using Version 3.1.2 r56127). The PUEL version is required for usb support. VirtualBox offers Guest Additions which include file sharing capabilities, but these Guest Additions are not available when using Windows 98SE. This means we need an alternative method for adding additional software packages to the Guest, since direct file sharing is not supported on VirtualBox without guest additions. We have circumvented this by putting the packages we are interested in either on a CD, or building an *.iso image that can be mounted into the VirtualBox instance as a separate drive. This is a bit awkward, but works. However, it does not address the issue of accessing the recorded data from the Host. Theoretically, one could e-mail the files to oneself, but I have an iron-clad rule that none of my Windows systems will EVER be connected to the Internet due to continuing problems with malware (in spite of conscientious efforts to avoid this!). There has to be a better way.

I submitted this issue to the VirtualBox forums ( http://forums.virtualbox.org/viewtopic.php?f=7&t=31989 is the original thread), and a solution was found, thanks to Perryg, TonyPh12345, and especially ahnzb. The solution involved setting up a “Host Only” network between the Host and the Guest using Samba. The original thread includes some additional tips and suggestions beyond what is considered herein.

II. Brief Outline of the Procedure

It is assumed that one already has a version of Ubuntu installed on the computer. We will step through the following procedures to get the network set up and communicating:

  • Getting the pieces together- identifying the appropriate packages and versions required for the project, and identifying where these components can be found
  • Setting up the system. We assume that you have followed the instructions from VirtualBox to set up VirtualBox with a Windows 98SE Guest, a process that is well-documented in the VirtualBox documentation.

  • Setting up Samba by editing the smb.conf  file.

  • Connecting the Guest to the network.

III. Getting the pieces together

The computer we are using for this application is a Toshiba Satellite Laptop, running Ubuntu 9.04 (kernel 2.6.28-18-generic). It uses a Realtek RTL8101E/RTL8102E PCI Express Fast Ethernet controller (rev 2). The version of Ubuntu selected was pretty much arbitrary. We do have an instance of Ubuntu 9.10 64-bit running on the same computer, but, in this case, we do not necessarily need the 64-bit capabilities.

We are using the PUEL version of VirtualBox ( Version 3.1.2 r56127), available from http://www.virtualbox.org/wiki/Downloads. We use the PUEL version, which is different from the version that is available through the Ubuntu Packages system, because we want usb capabilities. If one does not require usb, the free version would serve just as well. VirtualBox has some very good and extensive documentation available, which should be of great value to those who have had limited experience with desktop virtualization. The documentation is quite good at guiding one through the process of setting up a Guest operating system. If one choses to use the “Free” version of VirtualBox, it is highly recommended that one use the normal software channels to load the package (although installing from the PUEL version is quite straight-forward).

Samba is an implementation of the SMB/CIFS protocol for Unix systems, providing support for cross-platform file and printer sharing with Microsoft Windows, OS X, and other Unix systems. It is available from Ubuntu Packages (I am using Samba 2:3.3.2-1Ubuntu3.4 installed from Synaptic Package Manager). The Samba documentation is quite extensive and detailed, but it does not address the specific setup I was trying to implement. Using Synaptic Package Manager under Ubuntu simplifies greatly the process of installing and initializing this software.

IV. Setting up the System

It is assumed at this stage that VirtualBox has been properly installed, and that the Guest system has been installed and is operating properly within VirtualBox. As noted, we are using Windows 98SE as the Guest operating system in this procedure, which has been loaded into VirtualBox utilizing an original Microsoft CD. You will want to set up a user account in the Guest operating system that will use the same username and password that we will be using as we set up Samba.

If you are going to be allowing access to files on the Guest from the Host, you must designate the folders you are going to share on the Guest operating system. This is done in Windows 98SE by right clicking on the folder name in “My Computer” and selecting “Sharing” from the sub menu. The Guest operating system should be powered down at this point so that we can access the Network settings in the VirtualBox main menu.

Next, one must have the “user” set up properly. The login name and password we set up on the Guest must coincide with a valid user on the host. One must first add this user to “Users and Groups” on the Host, and then set up a Samba user with

smbpasswd -a <username>

run as root. If the user has not been set up properly in “Users and Groups” on Ubuntu, smbpasswd will refuse to add the Samba user.

One must also designate the appropriate folders on the Host for sharing. On the Ubuntu host, one does this same thing by right clicking on a folder in the File Browser window and selecting “Sharing Options” from the pop-down menu.

One issue that I ran in to involved the original name I had used for the Host computer, which had 16 characters- not a problem for Ubuntu, but apparently Windows was truncating the name, and then could not find the host on the network. If you want to change the Host name of the computer, quoting ahznb, “the host name is in </etc/hostname> and </etc/hosts>, just change it in those two places and reboot.” These changes will have to be done with root privileges. If you are happy with your Host name, and it is not too long, this should not be necessary.

V. The <smb.conf> File

Configuring Samba will require a bit more effort. It is highly recommended that one review the documentation for Samba (available here: http://www.samba.org/samba/docs/). The Official Samba HOWTO and Reference Guide provides some examples of simple configuration files that help explain how to set up a configuration file, and it is highly recommended that one review this document before delving in to the process. The man page for smb.conf  also gives a lot of valuable information about all of the available options (a rather extensive list, much more than what we will be dealing with here).

The Samba package comes with a default smb.conf  file, which we used as the basis for setting up our configuration. This file is well-commented, and the comments can be quite helpful in setting things up. Before making adjustments to this file, it is very important to make a backup copy of the original so that, should any changes made render the network inoperable, one has a beginning point to return to.

An abbreviated version of the default smb.conf , found in /etc/samba , that came with the Samba package we installed looks like this:

#
# Sample configuration file for the Samba suite for Debian GNU/Linux.
#
# This is the main Samba configuration file. You should read the
# smb.conf(5) manual page in order to understand the options listed
# here.
...
# NOTE: Whenever you modify this file you should run the command
# "testparm" to check that you have not made any basic syntactic
# errors.
...
#======================= Global Settings =======================

[global]

## Browsing/Identification ###

# Change this to the workgroup/NT-domain name your Samba server will part of 
   workgroup = WORKGROUP

# This must be the same workgroup name used in the guest. 
...
# "security = user" is always a good idea. This will require a Unix account
# in this server for every user accessing the server. See
# /usr/share/doc/samba-doc/htmldocs/Samba3-HOWTO/ServerType.html
# in the samba-doc package for details.
   security = share
# When this is set to "user", we lose access to host shares from the guest system.
# "Share" works for us.
...
########## Domains ###########
...
#======================= Share Definitions =======================
# Un-comment the following (and tweak the other settings below to suit)
# to enable the default home directory shares.  This will share each
# user's home directory as \\server\username
[homes]
   comment = Home Directories
   browseable = yes
# Uncommented above 3 lines to add [homes] section and changed browsealbe from no
# By default, the home directories are exported read-only. Change the
# next parameter to 'no' if you want to be able to write to them.
   read only = yes
   guest ok = yes
#Uncommented "read only", added "guest OK = yes" 6/20/10. This may not be wise if
#you are exposing your host computer to access by others through another route!
...

“...” indicates that I have left a lot of stuff out that we found did not really impact the setup we were trying to achieve. Most of the smb.conf  file was left set to default settings, and we have highlighted our own comments regarding what was necessary to change to get the setup to work.

The first note above did not require any changes, but it is important to insure that whatever you call the workgroup, it is the same in the Guest and the smb.conf  file. Next, we see the security  setting. When set to the default value of user , the network would not accept the logon from our Guest for some reason (telling us that the password was incorrect). Setting it to share  solved this problem (although this could have some potential security issues of the network is to be connected to a wider network or the Internet. In our case, we are only interested in connecting the Guest to the Host). In the default smb.conf  file, the [homes]  section had been commented out. We uncommented the lines and changed browseable  to yes . Next, we uncommented the lines read only  and guest ok  and changed guest ok  to `yes .

The smb.conf  file must be edited as root (I use sudo gedit /etc/samba/smb.conf  to accomplish this). Be sure to save a copy of the original before making any changes. Once the changes are made and the file is saved, one needs to restart both Samba and the guest machine for the changes to take effect.

Note that we did not attempt to share printers, because this is not important to us. There is another set of parameters that need addressing if one wants to print directly from the guest, a procedure which is well-covered in the documentation. Furthermore, the documentation tells us that a smaller smb.conf  file can improve performance, and once everything is running properly, you may want to remove a lot of what we have left in.

Restarting Samba can be accomplished with sudo /etc/init.d/samba reload , although I found myself rebooting each time I made changes before I was directed to this command. Rebooting works, too, but gets time-consuming.

To insure that everything is set up properly and one has made no typing errors, one should check the parameter settings with testparm /etc/samba/smb.conf , which should yield something like:

Load smb.config files from /etc/samba/smb.conf
Processing section "[homes]"
Processing section "[printers]"
Processing section "[print$]"
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions

[global]
       server string = %h server (Samba, Ubuntu)
       security = SHARE
       map to guest = Bad User
       obey pam restrictions = Yes
       passdb backend = tdbsam
       pam password change = Yes
       passwd program = /usr/bin/passwd %u
       passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\successfully* .
       unix password sync = Yes
       syslog = 0
       log file = /var/log/samba/log.%m
       max log size = 1000
       dns proxy = No
       usershare allow guests = Yes
       panic action = /usr/share/samba/panic-action %d

[homes] 
       comment = Home Directories
       guest ok = Yes

[printers]
       comment = All Printers
       path = /var/spool/samba
       create mask = 0700
       guest ok = Yes
       printable = Yes
       browseable = No

[print$]
       comment = Printer Drivers
       path = /var/lib/samba/printers
       guest ok = Yes

Note that in the above output, I have not attempted to share printers, so these settings may be incorrect.

VI. Connecting the Guest to the Network

Now it is time to connect the Guest to the network. In the VirtualBox main window, with the Guest system powered off, select “Settings” (which won't be available if the guest is running or in “Saved” state), then “Network”. One should have a screen like this:

VboxSettings.png

Note that “Enable Network Adapter” is selected. We have selected “Host-only Adapter”, and kept the “Name” as the default provided by VirtualBox. Under “Advanced”, the “Adapter Type” is the default. We experimented with other options available, but this is the one that worked for us. We let VirtualBox determine the “Mac Address”, and selected “Cable connected”. Select OK.

Now, start the guest machine, and log on as the user and with the password set up in the Host system. In our case, Windows 98SE using the “Found New hardware” network connection wizard which came up automatically when we booted the guest system after changing the VirtualBox network settings. We let Windows select and load the drivers automatically. Then, selecting (from the main menu in Windows) “Settings”, “Control Panel”, “Network”, we see that we have the following network components installed:

WinNetSet.png

Selecting the “Identification” tab, we have assigned the “Computer name” as “Vbox1” and used “WORKGROUP” as the Workgroup (which must coincide with the workgroup specified in the Samba setup). The “Computer Description” entry is arbitrary, but helps sorting out which computer is which in the “Network Places” window.

ID.png

Selecting the “Access Control” tab, we select “Share-level access control”.

Access.png

Finally, we select the “TCP/IP Properties” by highlighting this adapter entry in the “List of Installed Components” and selecting the “Properties” button. On the “IP Address” tab, we select “Obtain an IP address automatically”:

TCIP.png

All other Windows network settings have been left at the default.

When finished with the Network setup, Windows will want to reboot. After rebooting, if all has gone well, then in “Network Neighborhood” one should see the host and guest computers listed.

Neighborhood.png

If they are not, select “Entire Network” and one should see the Workgroup. Select this, and the computers should show up. If all has gone well, selecting the host computer should give you access to the shared folders (and printers, if you have set up printer sharing), and all is well. Windows may ask for a password when first accessing the host computer- insure that you are using the login name and password you previously set up on the host. If the network won't allow access to the network or host computer, then there is something wrong with the host setup- either the “security” setting or the share settings in the [homes] section of the smb.conf file, or you are not using the correct login name and password in the Guest.

Leaving the guest system running, switch to the host, and from the “Places” menu, select “Network”, which should give something like this:

UbuNet.png

Note that in this particular example, the “UBU904” is what I happened to name the Host. If the computers do not show up, try opening “Windows Network” and look for the Workgroup. If you can find the Guest computer name (as set up in the procedure outlined above), try accessing it, and see if you can open shared files. At one point, I was able to access the shared files on the Guest without access from the Guest to the Host shares. If this is the case, it may be due to the “Security” settings in the <smb.conf> file.

VII. Some Convenient Housekeeping commands

Another command of value is the loopback test with smbclient -L localhost -U%  which should yield something like:

Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.3.2]
       Sharename       Type      Comment
       ---------       ----      -------
       homes           Disk      Home Directories
       print$          Disk      Printer Drivers
       IPC$            IPC       IPC Service (Ubu904 server (Samba, Ubuntu))
       PDF             Printer   PDF
       Canon-PIXMA-MP160 Printer   Canon PIXMA MP160
       documents       Disk
       desktop9.04     Disk
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.3.2]

       Server               Comment
       ---------            ------- 
       UBU904               Ubu904 server (Samba, Ubuntu)
       VBOX1                VirtualBox on Ubuntu 9.04

       Workgroup            Master
       ---------            ------- 
       WORKGROUP            UBU904 

Which confirms that all of our computers are recognized and that the workgroup name is correct.

You should now be ready to share files...

There are tools available for editing the configuration file, one being SWAT , which allows you to administer a Samba server via a web browser. SWAT  is no longer actively maintained, and its default configuration is not secure for use over an untrusted network. SWAT  will also rewrite smb.conf , rearranging the entries and deleting all comments as well as include=  used in conjunction with hand-edited smb.conf  files or the default package-managed configuration. Somewhere along the line, an application called GADMIN-SAMBA  showed up in my System Tools  menu, but I found using this to edit the smb.conf  file to be more difficult than doing it manually. Information about this tool can be found at http://gadmintools.flippedweb.com . I suspect that someone more knowledgeable in setting up networks may find this useful. The package is available from the Ubuntu Packages.

SambaWithVirtualBox (last edited 2010-08-21 19:47:53 by 190)