Essaying a sashay with Samba

Just in case either of my kids are reading this, don’t panic. I’ve not suddenly decided to break the habit of a lifetime and indulge in a bit of Dad Dancing. No, this is a vain attempt to improve my geek-cred, rather than my street-cred. As promised in my last post, this is a wander through my adventures in configuring Samba to share files from my shiny new Ubuntu 9.10 Server installation.

Installing Samba

Connect to the server via SSH and at the prompt type :

sudo apt-get install samba

Now create a directory to hold the files and sub-directories that we want to make available over the network :

sudo mkdir -p /srv/samba/share
sudo chown nobody.nogroup /srv/samba/share

Edit the samba config to setup the share :

sudo vi /etc/samba/smb.conf

Add the following section at the end of the file :

  comment = Samba Share 
  path = /srv/samba/share 
  browsable = yes 
  guest ok = yes 
  read only = no 
  create mask = 0755 

Note – I also uncommented this line after having one or two subsequent problems copying files across :


Once the file has been edited, restart samba :

sudo /etc/init.d/samba restart

You should now be able to see the share in Nautilus ( i.e. Ubuntu desktop menu – Places\ Network).
At this point I had to refresh the view a few times to get Nautilus to display the Workgroup folder, again when I opened this up to display the server, and then again to display the share.

I’m not sure why this is. Once I’d put my music files on the share and pointed Rhythmbox at it, it all seems to work OK. When I start Rythmbox now, I immediately get the share folder icon on my desktop.
All of which brings me nicely onto :

Copying files from a USB Stick onto the server

Specifically in this case, these are the files I want to put on the newly created share. Of course, one way is to simply plug it into the client and then copy over to the share using Nautilus.The other, is to mount it onto the server.

Mounting the USB Stick onto the server

Create a directory to mount external storage under /media :

sudo mkdir /media/external

Plug the USB stick into one of the USB ports on the server
Find it on the server by :

sudo fdisk -l

This should return details of the hard disk and also the device it recognises as the USB stick.
In this case, with an 8GB stick, the output includes the lines :

Disk /dev/sdb: 8019 MB, 8019509248 bytes 
  Device Boot      Start         End      Blocks   Id  System

/dev/sdb1   *           1       10198     7831527+   c  W95 FAT32 (LBA)

We know that the device is on /dev/sdb1 and it’s formatted as FAT32, so now we can mount it :

sudo mount -t vfat /dev/sdb1 /media/external

Now just use cp to copy the files across to the share and then change the file ownership from root :

cd /srv/samba/share
sudo cp -r /media/external  .
sudo chown nobody.nogroup /srv/samba/share
sudo /etc/init.d/samba restart

The last line here re-starts samba. Once again, I’m not sure if this is necessary but I did it just to be on the safe side.

Finally, don’t forget to unmount the USB :

sudo umount /media/external

A word of caution – in the course of using both of these methods to copy, admittedly quite large amounts of data (over 2GB at a time), the server hardlocked, forcing a reboot.
Further research indicates that this is likely to be an issue with linux copy commands having problems copying large amounts of data. It would seem that the definition of “large” in this context probably depends to an extent on the hardware that you have available.

I managed to resolve this by copying the files across in smaller chunks.

This wasn’t a huge problem for me because the server isn’t being used for anything else at the moment and obviously no-one else was connected. However, I thought it worth mentioning just in case you have any bright ideas as to why this happened.

To finish with a happy ending, my fingers are now dancing across the keyboard to the dulcit tones of Motorhead ( Tear Ya Down – if you must know) playing from the share on the server.


2 thoughts on “Essaying a sashay with Samba

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.