I want to play with computers and networking. My family doesn’t. They are content with a basic Windows XP PC with email, web browsing and support for MP3 players and digital cameras. Our XP PC is 5 years old and has exhausted its 80 GB hard drive. Rather than buying a new Vista machine, I decided to buy the parts to make a PC, then loaded CentOS Linux on it. In addition to the new Liunx machine’s function as a ‘lab’ for me to play with, it also had to provide additional storage and backup facilities for the family’s XP machine. I know the simpler thing to do would be to simply buy a USB HDD for the XP machine, but this isn’t about simple, it’s about creating ‘learning opportunities.’
So, I have a Linux machine with tons of HDD storage space (250 + 500 GB) . The XP machine needs additional space. And it must be transparent to the rest of the family. I used Samba to create file shares on the Linux machine, then created mapped network drives on the XP machine that connect automatically to the Linux machine’s HDDs at login. It wasn’t hard, but did trip me up on a couple points.
Samba is an open source software package that allows Linux/Unix machines to participate in Windows networking as nodes in the Windows “Network Neighborhood” and therefore provide file sharing between Linux and Windows machines. It was easy to install the Samba package on CentOS, using the Add/Remove software package from the desktop GUI, and included a GUI configuration tool for Samba. The CentOS deployment guide provides good guidance for configuration, and the samba.org site provide an excellent extra level of detail for the software. A couple of points to add that were key learnings for me:
The Samba GUI provides a simple, easy configuration tool for the basic samba config, identifying the workgroup name, shared volumes and users/passwords. The manual config is accomplished via the smb.conf file in /etc/samba. Manual edit of the conf file provides more options than the GUI, including logging level, source IP address filtering, and preventing access to home directory. However, if you make changes to this conf file, then make changes to the config via the GUI, your manual changes to the conf file will be removed. So make the simple GUI config changes first, get a functioning system, then tweak the configuration with vi edits of the smb.conf file.- Windows XP required that I set samba up with “user” authentication, not “share”, and I had to encrypt the passwords on the Samba config. Windows would not attempt to make connections when Samba was configured with unencrypted passwords.
The Samba config was easier to config than the Windows XP side. Once I had the Samba server running, I was able to go into “Network Neighborhood”, view the “workgroup nodes” and connect with the user/password set up in Samba. Then I could map a drive letter to a share folder on the Linux box. Easy, right? Almost. Even though I asked Windows to ‘reconnect at login’, Windows could not. Looking at the Samba logs in var/log/samba/smbd.log (with logging set to level 3 via the conf file “log level = 3) I could tell that the problem was with XP, not Samba, and I suspect that Windows was not chaching the password.
The solution was a batch file that runs at startup on the XP machine. I found a forum post that explained the syntax very well, using the net use command. My specific command was “net use S: \\server\storage passwd /USER:username” Then I just had to store the batch file in the ’startup’ programs folder for “All Users”, and now the drive maps automatically at startup. Then I’ll convert the “My Pictures” folder to a shortcut to a folder on the Samba shared volume. Perfectly transparent to my family.
As long as the power is on the Linux box.
Update Jul 20, 2009:
I rebuilt my machine and used a firewall and Security Enhanced Linux (SELinux), which created a couple additional challenges. First, the firewall had to be configured to allow smb protocol for Samba, which was easy. Second, (and a bit more tricky) the smb.conf file had notes for SELinux, indicating that the shared folders needed to be marked with “samba_share_t”. The current labels can be displayed with “ls -ldZ /path”, and the label on a share folder can be set with “chcon -t samba_share_t /path”. Once I resolved these issues, all was fine.
Photo credit, eheçatzin