Saturday, June 23, 2012

Raspberry Pi -- Installing Samba (Windows Share) File server

Having successfully run Debian Wheezy on my Raspberry Pi, I went forward with my initial idea of setting up a low cost power efficient file server for accessing my external hard disks from my Windows7 desktop, HP-Mini running Ubuntu and Mac Mini running OS X Lion (yeah I do like bragging about my machines :D ).

This turned out to be pretty straight forward.

As expected, the external Seagate USB disk immediately got recognized and appeared as /dev/sda
[  579.948350] usb 1-1.2: New USB device found, idVendor=0bc2, idProduct=3001
[  579.948384] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  579.948405] usb 1-1.2: Product: FreeAgent
[  579.948421] usb 1-1.2: Manufacturer: Seagate
[  579.948447] usb 1-1.2: SerialNumber: 2GEX323R
[  579.967638] scsi0 : usb-storage 1-1.2:1.0
[  580.970520] scsi 0:0:0:0: Direct-Access     Seagate  FreeAgent        102D PQ: 0 ANSI: 4
[  589.142942] sd 0:0:0:0: [sda] 1953525168 512-byte logical blocks: (1.00 TB/931 GiB)
[  589.144669] sd 0:0:0:0: [sda] Write Protect is off
[  589.144717] sd 0:0:0:0: [sda] Mode Sense: 1c 00 00 00
[  589.146298] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[  589.171762]  sda: sda1
[  589.180680] sd 0:0:0:0: [sda] Attached SCSI disk

Next step is to create a mount point
pi@raspberrypi ~ $ sudo mkdir /media/terradisk
Add the correct entry to /etc/fstab (edit this with your preferred editor)
pi@raspberrypi ~ $ sudo vim /etc/fstab
So that it looks like the following,

And mount it
pi@raspberrypi ~ $ sudo mount -a
The new usb drive should now show up
Next install samba,
pi@raspberrypi ~ $ sudo apt-get install samba samba-common-bin
Once finished, open the samba configuration file
pi@raspberrypi ~ $ sudo vim /etc/samba/smb.conf
and edit as follows.
In the Authentication section, uncomment
   security = user
and add the following section in the end
comment = Data Dump on Sam Raspberry Pi
path = /media/terradisk
writeable = yes
guest ok  = no
Remember to change
with the share name you want and
path = /media/terradisk
with the path to wherever you mounted your external disk.
Add the smb password for the default pi user
pi@raspberrypi ~ $ sudo smbpasswd -a pi
Set permissions so that pi user can access the share,
pi@raspberrypi ~ $ sudo chown -R pi:pi /media/terradisk/
Restart samba
pi@raspberrypi ~ $ sudo /etc/init.d/samba restart
And done!
Try accessing the share,

 And it works!

Friday, June 22, 2012

Running Debian on Raspberry Pi (and SD card woes)

After waiting for nearly 3months, I finally got my Raspberry Pi last week from Element14. Plan was to set it up as a file server for network enabling my external hard disks.

Raspberry Pi debugging setup
Debugging setup
Attempts to use a SandDisk 8GB Class 10 Extreme SD card and Debian Squeeze image, following the instructions here, were completely futile. Tales of my woes and subsequent hardware level debug attempts can be found in this thread.
Plugging in the card and attempting to boot the RasPi failed miserably initially.
Damn ugly pull up resistors on the
SD IO lines
Implementing the pull-up resistor hack suggested by jhasler, resulted in a fugly looking but partially working RasPi. It was atleast attempting to boot now, although it was throwing up a kernel panic immediately after loading the kernel.

After loading kernel card drivers
SD DAT0 line, before kernel is loaded.
Probing the SD card IO lines with a high BW scope, revealed some glaring anomalies. The SD Clk speeds up and the pulses on the SD DAT lines become terribly distorted once the kernel mmc driver is loaded. Apparently the kernel driver is pushing things outside the hardware specs of the RasPi. Hopefully this will be addressed in the future firmware or patched kernel releases.

Anyway, finally had great luck with a 4GB SanDisk Class 4 SD card and the 2012-06-18-wheezy-beta image. It immediately booted up and within a few seconds, I was greeted by the friendly raspi-config menu similar to the one below, which lets the user configure the GPU memory share, KB layout, locale and a few other useful stuff.

raspi-config menu inside a ssh session.
A few simple choices and finally I get the much awaited Debian login prompt!

For powering the RasPi I was initially using my Nokia 5800 (yes I am still using this pre-historic phone!) micro-usb cable connected to my desktop but later on replaced it with a Belkin powered usb hub.

RasPi powered by Belkin USB Hub.
One of the downstream ports of the hub powers the RasPi. while the upstream port of the hub is plugged back to the USB port of the Pi. The arrangement looks a bit funny though ( no, this is not a perpetual machine, the external power connector to the hub is yet to be connected :P )

The external HDD, one additional USB to ethernet connector (I am connected to 2 different subnets) and keyboard (temporarily) were all plugged into the HUB. My Mac Mini's HDMI to DVI connector, was of great help during the initial setting up. Once that was done, SSH is now working just fine for me, no longer need the KB or display.
I'll keep jabbering about my further experiences with this tiny beast, in the next few posts!!