Setting Up A Standalone Storage Server With GlusterFS And Samba On Debian Squeeze

Version 1.0
Author: Piotr Opara < piotr [dot] opara [at] gmail [dot] com >
Last edited 14/20/2012

This tutorial shows how to set up a standalone storage server on Debian 6.0, using GlusterFS and SAMBA, and custom scripts and settings to make life easier ;)

I do not issue any guarantee that this will work for you!

I do not issue any guarantee that you will understand my poor english ;)


1 Preliminary Note

Tutorial is based on Falko Timme article.

Linux Distribution:

I?m using the Debian 6.0 (Squeeze) distribution. The installation of the Debian is very simple, so I?m not going to explain it. Just remember that you'll need to have a disk or partition exclusive to data.


In this tutorial I use three systems, a two storage nodes and a windows client:

  • IP address
  • IP address
  • MS Windows client: IP address

2 Preparing The Nodes

We have to make sure, that both nodes are up to date and have installed SSH and other software that we like or need.


apt-get update

apt-get install mc ssh

We need to be sure, that both nodes should be able to resolve the other system's hostname:


vi /etc/hosts    localhost    node1    node2


Checking All Settings


ping -c 1 node2

PING ( 56(84) bytes of data.
64 bytes from ( icmp_req=1 ttl=64 time=0.818 ms

--- ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.818/0.818/0.818/0.000 ms


ping -c 1 node1

PING ( 56(84) bytes of data.
64 bytes from ( icmp_req=1 ttl=64 time=0.802 ms

--- ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.802/0.802/0.802/0.000 ms


3 Setting Up The Data Disks

On both nodes we have exclusive disk, we need to set them up:


fdisk /dev/sdb

Command (m for help): <-- n
Command action
  e   extended
  p   primary partition (1-4) <-- p
Partition number (1-4, default 1): <-- 1
First sector (1-1305, default 1): <-- ENTER
Using default value 1 Last sector, +sectors or +size{K,M,G} (1-1305, default 1305): <-- ENTER
Using default value 1305

Command (m for help): <-- t
Selected partition 1
Hex code (type L to list codes): <-- 83
Command (m for help): <-- w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.

Now run

fdisk -l

and you should find /dev/sdb1 in the output on both nodes:

Device Boot Start End Blocks Id System
/dev/sdb1 1 1305 10482381 83 Linux

Now we create a filesystem on /dev/sdb1, and mount the /dev/sdb1 to /data directory


mkfs.ext3 /dev/sdb1
mkdir /data/
vi /etc/fstab

/dev/sdb1 /data ext3 defaults 0 0

Now run

mount -a

After that, you should find the share in the outputs of

df -h

/dev/sdb1 9,9G 151M 9,2G 2% /data


/dev/sdb1 on /data type ext3 (rw)

Share this page:

3 Comment(s)

Add comment


From: Piotr Opara at: 2013-01-30 19:37:31

Yes You have right, from the point of view of Windows users it is much easier,  and more comfortable to use only one IP address or hostname like You said. And I'm sure that there is more options to do that, for example - CTDB or Heartbeat. But in my case, I had reason to not use virtual IP. In my real system, nodes of cluster are in different locations, i mean two branches in different ends of city. There are different subnets and nodes are connected together via IPsec VPN. That's the reason, why I didn't use VIP. I schould said it in my article, then it would be clear. Thank's for suggestion to use UCARP. I didn't know that before, so I have to try it :)

From: Murgulet Iulian at: 2013-01-30 08:07:52

From point of view of Windows clients, the following setup is better(in my oppinion):

- you can use ucarp( UCARP allows a couple of hosts to share common virtual IP addresses in order to provide automatic failover.

- the 2 servers(one nod is master, and the second is slave/backup) will share a VIP(cluster IP);

- on VIP up or down, ucarp it is capabile to run some scripts(in this case /etc/init.d/samba start on ucarp interface is up, and /etc/init.d/samba stop on ucarp interface is down);

- in  /etc/samba/smb.conf you can declare that the samba can use only localhost and ucarp(VIP) interfecaces;

  In this way, at any time you have only one samba daemon up(it is good for Windows browsing list, and you can use netbios name, \\CLUSTER) on the node where you have VIP(ucarp interface)  up. In case of problemens(on master node, who has ucarp up), ucarp begin to proceed(takeover) to stop samba, move the VIP on second nod, and start the samba (on second node). The takeover process complete in almost 5 seconds.

    The second improvment of this setup if you use ucarp, it is that you can extend the samba functions with: master domain, wins server, and so on. For master domain it is necessary to keep sa same SIDs on both samba(keep the /var/lib/samba on top of glusterfs).  

Have a nice ... cluster with samba, glusterfs and ucarp


From: Mihai at: 2013-01-30 22:00:58

True, i was thinking as you at ucarp. Maybe in addition ... one can use monit to monitor the sambe process (it may happen that the server is up, but samba is no longer responding) and restart the daemon in case it is not responding.

 Nice tutorial!