Académique Documents
Professionnel Documents
Culture Documents
Samba setup
Since I only want to allow file sharing on my own laptop between the host
system and the virtual guest systems, I told Samba to only bind to the local
loopback network interface and a virtual local network that we are going to
set up in a minute. The configuration is done in the file /etc/samba/smb.conf:
[global]
# We will use the workgroup XLTOOLBOX for our virtual guests as well.
workgroup = XLTOOLBOX
wins support = yes
dns proxy = no
interfaces = 127.0.0.0/8 192.168.200.0/24
bind interfaces only = yes
When set up in this way, Samba will only respond to requests from the local
network. Please note that the network 192.168.200.0/24 was chosen
arbitrarily by me; it is different from the LAN that my FRITZ!Boxwifi router
creates (which is 192.168.178.0/24). Any requests that the router might let
slip through to us should not be responded to by the Samba server, since the
Server does not listen to the router network.
It is necessary to create a Samba password:
smbpasswd
Sharing a folder
Sharing a folder in Ubuntu is as simple as right-clicking on the folder in the
Files window, and choose Sharing Options:
Make sure to not allow others to create and delete files in this folder.
Alternatively, if you like to use the terminal, issue something like this:
net usershare add documents /home/daniel/Documents "Vhost documents" daniel:f
Of course, you need to adjust the paths and user name to your own.
The net usershare command also provides options to list and remove shares;
the options are displayed when the command is issued as-is.
Note the usage of start on stopped rc RUNLEVEL=[2345]. Many Upstart jobs use
the stanza start on runlevel [2345]. The VirtualBox kernel module is loaded by
an old-fashioned System V job. System V jobs are executed when runlevel
2 is reached. We must delay execution of our custom Upstart job until the
System V jobs have been executed. This is why it says start on stopped rc
RUNLEVEL=[2345]. Withstart on runlevel, our vboxnet job and the System V init
jobs would start to execute simultaneously.
To make the Samba server wait until the VirtualBox network is up and
running, change the following line in /etc/init/smbd.conf:
start on (local-filesystems and net-device-up)
to
start on (local-filesystems and net-device-up and stopped vboxnet)
When you restart the system now, the host-only network will be set up and
the Samba server will correctly bind to the network interface:
ifconfig
[...]
vboxnet0 Link encap:Ethernet HWaddr 0a:00:27:00:00:00
inet addr:192.168.200.1 Bcast:192.168.200.255 Mask:255.255.255.0
inet6 addr: fe80::800:27ff:fe00:0/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:794 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:115199 (115.1 KB)
[...]