Tag Archives: samba

Debian NAS

I wanted a centralized home storage system that could feed all my other toys. Data stored on this will include MySQL datafiles, our MP3 collection, website directories and all our receipts printed out in PDF format (Yay! CutePDF) among other things. And so the fun began…

I did some test installs of various “turnkey” solutions such as Openfiler.

Openfiler just didn’t seem stable enough. Arrays would claim to have faulty drives and start rebuilding the arrays at the strangest times. Only to find out, via 3rd party tools, that the drive was fine. The web interface was ok but I would have organized it differently. Minus that, Openfiler has a lot of potential.

In the end, for what I wanted, it was easier to do a netinstall of Debian and add the things I needed.

Started with this: Debian RAID

Raid5 first
Raid1 with leftovers
Flat filesystem
Swap on Raid5

Bad mainboard
Bad harddrive
BIOS truncation of HD hardware address forcing me to "find" the bootdisk manually.

ECS RS482-M754 w/ AMD Sempron 3200+ (Bundled)
4x Seagate Barracuda 7200.10 ST3250620AS 250GB
2x AllComponents 512MB 184-Pin SDRAM DDR 400

The mainboard had problems POSTing but I couldn't really determine if it was board, memory or CPU, so it (board, memory and processor) was replaced with:

AMD Sempron 64 3400+ Manila 1.8GHz Socket 754
2x Kingston 512MB 240-Pin SDRAM DDR2 800

Ended up having a dodgey harddrive too. Awaiting the RMA return. But that didn't stop the project, it's just running without a spare at the moment.

NFS with assigned ports: Securing NFS

This is used for our websites' files and MP3 collection. The MP3's are accessed internally via Jinzora and accessed via laptops, HTPC's etc.

9 times out of 10, we're accessing the NAS interactively from laptops running windows. I didn't really look for a site that explained how to setup Samba on Debian. Just knit picked around google until my shares were up and running.

AoE for database files: AoE on Debian

First, the above URL is not quite complete, it's missing a few steps, which I have outlined below.

There are some security risks one should be aware of when implementing AoE. One item is the ability to X-mount an AoE LUN on another server causing corruption and all sorts of other nastiness. I've heard there are certain implementations that allow MAC filter and other security mechanisms to make this more secure. But in the end, you will still be shipping data in the clear over the wire.

I decided the ease of use were worth the risks.

Given that data files were going to live on the AoE devices, I wanted some extensive, longterm testing. I kept the originals and did some link chicanery for the test.

As I stated earlier, the AoE How-To linked is not complete but still makes a decent starting point. Below is a quick step-by-step.

Keep in mind the initiator is the "client" and the target is the "server". These are Debian specific instructions.

Install the client tools
apt-get install aoe-tools

Create the /dev structure
aoe-mkdevs /dev/etherd

apt-get install vblade

Create a device to export
lvcreate -n myAoE --size 10g my_vg0

Export device in userland for testing
vblade 0 1 eth1 /dev/my_vg0/myAoE &


List AoE devices

Create filesystem on device
mkfs.ext3 /dev/etherd/e0.1

Mount our new AoE device
mount /dev/etherd/e0.1 /data

And there you have it. In the end, I have 500GB of usable space in the first array. This includes a spare. All told, $415 delivered from NewEgg.

Next, I will be adding 4x 500GB drives for another array. At the current prices, you just can't beat the $ per GB.

How to setup a basic SAMBA share

FreeBSD Samba how-to based on the one at www.bsdvault.net. Some errors have been corrected (from the original at bsdvault.net), but please let us know if you find any in this version.

1) Install the Samba port

cd /usr/ports/net/samba && make install

2) Read the files in /usr/local/share/doc/samba

They will help to drag you out of the pit of ignorance.

3) Copy /usr/local/etc/smb.conf.default to /usr/local/etc/smb.conf

4) Before you edit smb.conf you will need a shared files directory. I tend to use /usr/smbshares/files so that will be used in this example:

mkdir -p /usr/smbshares/files

You’ll need to chmod

chmod 0775 /usr/smbshares/files

Then chown (I tend to use smbguest:0 as I often need to write to the shared directory using my wheel grouped user)

chown owner:group /usr/smbshares/files

5) You will also need to create the file locks and logging directories:

mkdir /usr/local/locks
mkdir /var/log/samba

6) Create a guest account if you dont have one on your box already I use smbguest

Your entry for the smbguest account in /etc/passwd must look something like this:

smbguest:*:1002:1002:Samba Guest:/nonexistent:/sbin/nologin

Note the lack of a home directory and the use of the nologin shell, this is important.

7) Now edit the config file. It comes with lots of examples but for simplicity I provide BASIC lines here:

workgroup = FIGARO
hosts allow = 192.168.1. 127.
guest account = smbguest
log file = /var/log/samba/log.%m
max log size = 50
security = user
encrypt passwords = yes
socket options = TCP_NODELAY

comment = Files
path = /usr/smbshares/files
guest = yes
public = yes
writable = yes
printable = no

8) Add encrypted passwords for Samba users:

cd /usr/local/private
mv smbpasswd smbpasswd.orig
touch smbpasswd
chmod 0600 smbpasswd

Now create one for each user:

/usr/local/bin/smbpasswd -a (username)

9) Copy /usr/local/etc/rc.d/samba.sh.sample to /usr/local/etc/rc.d/samba.sh

cp /usr/local/etc/rc.d/samba.sh.sample /usr/local/etc/rc.d/samba.sh

10) Type /usr/local/etc/rc.d/samba.sh or reboot.


Contributed by: Crimson

SambaLESS Windows Printing

Printing from FreeBSD workstations to a Windows based print server without using Samba. I got fed up dinking with Samba in fairly short order, so this is the route I took. Enter CUPS (Common Unix Printing System). Works really well if you have no need for Netbios shares on your LAN. I also hear it works with Samba as well, but I didn’t spend any time on that.

Read on for information on how I got it working.

Read on for information on how I got it working.

Windows Server:

First, we need to make sure “File and Print Services for Unix” is installed.

Control Panel
Add or Remove Programs
Add/Remove Windows Components
Other Network File and Print Services
Print Services for Unix

Ensure that the box is checked. If it is not, check it and install.

Other than having a printer installed and shared, that is it for the Windows side of things.

FreeBSD Workstation:

First, install the CUPS port.

cd /usr/ports/print/cups
make install cleanThe CUPS port leaves the default lpr in place, so we’ll have to move things around a bit so applications will print without us having to edit the settings of each app.

CUPS puts its version of lpr in /usr/local/bin

mv /usr/bin/lpr /usr/bin/lpr.orig
ln -s /usr/local/bin/lpr /usr/bin/lpr

Now its time to make sure that the cupsd starts at boot.

mv /usr/local/etc/rc.d/cups.sh.sample /usr/local/etc/rc.d/cups.sh

You can start the cupsd now by issuing:
/usr/local/etc/rc.d/cups.sh start

I did NOT have to modify the cupsd.conf but you may have to depending on your configuration.

Let’s add a printer and test it! I will be using a HP PSC-2110 Multifunction printer. Change your setup as needed.

Open your browser and point it to http://localhost:631 and you should be seening the CUPS page. Click on the Administration link. It will ask for a username and password, I just logged in as root.

Click the “Add Printer” link.

Give it a Name, Location, and Description. This is just informational, so it can be whatever you want. Click continue.

Under device select “LDP/LPR Hosted Printer”. Click contiue.

Now we have to tell CUPS where the printer is. You can do it by either IP or hostname:


– or –


It’s worth noting that I am not sure if the port number (515) is actually required, but it worked for me and I saw no reason to remove it.

Click continue.

Select your printer manufacturer and click continue.

Select HP New DeskJet CUPS v1.1 (en)

* Remember that I am using a HP PSC2110 in this example, your selection may differ.

Click continue.

Click on your printer name link to take you to the Administration page for that printer.

Click print a test page link. If it prints, your all done, if not, you’ll have to do some troubleshooting and checking your settings.

As always, suggestions are welcome. Please leave a comment if you have any questions or anything to add.