Gentoo x64 - RAID5 and Samba

Web, General Add comments

Today, I continued setting up my Gentoo server. With internet access available to my windows machine through NAT and remote administration working through SSH, I could easily look up resources on the internet and copy & paste between the linux console and my web browser :)

RAID5 was a simple matter of activating the required kernel options (which I already did beforehand). Somehow, mdadm created a RAID5 array with one spare. I haven’t investigated this much further, but it seems this allows the array’s initial synch to work faster. Whatever, I didn’t want it, so after finding out how to take the RAID array down again, I used mdadm with –spare-devices=0 and –force to have all disks UP from the beginning.

Using –chunk to set a block size of 128 kb and mke2fs with the -E stride=n,stripe-width=n options allowed me to tailor the RAID array’s stripe size to the file system. Not that I expect any noticeable gain, but it’s easily done and can’t hurt.

Next was samba. Gentoo makes this surprisingly easy. emerge samba, edit /etc/samba/smb.conf and you’re done. It took some effort to figure out how to create a password protected share, so this is what I did:

I’ve got a linux user named ‘cygon‘ on this system. This was created with the good ol’ useradd script. I added this user to /etc/samba/smbusers as an alias for “administrator” and “cygon“, so the file now looks like this:

# Unix_name = SMB_name1 SMB_name2 ...
# $Header: /var/cvsroot/gentoo-x86/net-fs/samba/files/config/smbusers,v 1.1 2007/09/07 21:07:40 dev-zero Exp $
#root = administrator admin
nobody = guest pcguest smbguest
cygon = administrator cygon

Then I set up a password for this user with smbpasswd -a cygon.

Finally, I created a folder that I wanted to share, assigned it to the user “nobody” (this is what samba uses for all files creates by guests) with chown nobody:nobody /var/storage/raid -R. This I then added in my /etc/samba/smb.conf:

[Protected]
  comment = Administrative share for the entire RAID array
  path = /var/storage/raid
  public = yes
  guest ok = no
  writable = yes
  printable = no
  force user = nobody
  force group = nobody
  create mask = 744
  directory mask = 755
  valid users = cygon

Public‘ says the folder can be seen by other network users. ‘force user‘ and ‘force group‘ make samba assign all files and folders created from networked users to the ‘nobody‘ linux user account and ‘nobody‘ linux group. Likewise, ‘create mask‘ and ‘directory mask‘ are the attributes assigned to folders created by network users. Finally, ‘valid users‘ tells samba to only let the listed users access the share.

That’s all it took to get this working.

The funny thing, again, is that performance and reliability increased by an order or magnitude compared to Windows Server 2008. I configured Samba to always act as my domain master browser, so when I browse my network neighborhood in windows, one click and all PCs on the network appear — immediately. Instead of 20 seconds of searching and then maybe half of the local PCs showing up.

File copies to and from the array are easily 4 times faster than with windows. And, most notably, they run much smoother. Windows Server 2008 accepted an average 20 MB/s for several seconds, then blocked hard for a while (probably flushing its insane cache), then accepted data again. Download speed was kept up longer, but also wouldn’t go over around 25 MB/s (30 MB/s tops) during the whole transfer (at least until the cache grows to the size of the physical RAM and the OS starts paging out unimportant things, like its own kernel, the DHCP server, its TCP/IP stack, DNS database, the RDP server and any running foreground application the user is currently working with)

Now Samba, which is just an implementation of Microsoft’s SMB protocol, pieced together by logging network packets, combined with a (Soft-)RAID 5 partition manages a stable 20 MB/s upload and a stable 60 MB/s download. And the kernel just takes the load - no suicide by paging, swapping out of vital system components or anything noticeable happening at all! The copy beats the original - by far.

Leave a Reply

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Login