Warning: include(tech/techhead.html) [function.include]: failed to open stream: No such file or directory in /home/schrantz/computer-vet.com/tech/linuxfileserver.html on line 2

Warning: include() [function.include]: Failed opening 'tech/techhead.html' for inclusion (include_path='.:/usr/local/php5/lib/php:/usr/local/lib/php') in /home/schrantz/computer-vet.com/tech/linuxfileserver.html on line 2
Setting up a Linux File Server on a Windows network ~ The Computer Vet
Warning: include(tech/pagetop.html) [function.include]: failed to open stream: No such file or directory in /home/schrantz/computer-vet.com/tech/linuxfileserver.html on line 10

Warning: include() [function.include]: Failed opening 'tech/pagetop.html' for inclusion (include_path='.:/usr/local/php5/lib/php:/usr/local/lib/php') in /home/schrantz/computer-vet.com/tech/linuxfileserver.html on line 10

Setting up a Linux File Server on a Windows Network

by Scott Schrantz
June 25, 2003

This week I've been learning how to set up a Linux file server. This page is a rough amalgam of what I've learned about the process. It's at a beginner level, and it's probably pretty naive in parts. Mostly it's just me writing down what I did so I don't forget it. If someone else can learn from it too, that much the better.

This page is specifically geared to my situation: popping a FAT32 hard drive in a Linux box, and getting those files shared over the network using Samba (Samba is the program that lets Windows and Linux talk to each other over a network). I'm adding this server into an all-Windows network, with a Windows NT domain controller. I'm using FAT32 instead of a Linux file system so I could drop the drive back into a Windows machine without any fuss. Security is very lax, as you can see later in the page when I recommend mapping user accounts to root. Don't do that unless you really trust your co-workers!

This document assumes Red Hat 9 as the Linux distribution.

First Steps

First, when you install Linux, you have to make sure to install Samba with it. If you don't, you can always go and install it from the RPMs.

Linux should already be installed, running, and active on the network. Getting to that point is the topic of a million other tutorials.

Mount the Drive

You will need to install the FAT32 drive in the computer, and then you'll have to mount it for Linux to be able to recognize it. Linux can read FAT32, but it won't load up the disk automatically. You'll have to mount it by hand and edit a config file so it mounts at system startup every time. First you need to realize how Linux sees your hard drive, and how to reference it.

Devices

All hardware devices are located under /dev in the Linux tree. Hard drives are specified like so:
Primary master      /dev/hda
Primary slave       /dev/hdb
Secondary master    /dev/hdc
Secondary slave     /dev/hdd

Then each partition has a number. The 1st partition on the primary master is known as /dev/hda1. And so on. This is how you refer to each partition while using Linux.

Once Linux has started, go to a command line as root. If your FAT32 hard drive is properly installed, say as the primary slave, then it will be /dev/hdb1. You can check by bringing up a list of all active partitions.

cat /proc/partitions

That will show you every hard drive and partition, mounted or not. When you have the info, you can use it to mount the drive.

Mounting

mount -t vfat /dev/hdb1 /windows

The "-t vfat" option forces Linux to realize that you are mounting a FAT32 partition. This command will mount the primary slave (/dev/hdb1) to the /windows directory. This directory must already exist before you run the mount command. If there are files in the directory, they will be hidden as long as the drive is mounted. You can mount a drive to any directory or any subdirectory you want. I'm just using /windows as an example.

Auto-Mount

If you want a drive to be automatically mounted when the computer boots, you will have to edit the /etc/fstab file. This file keeps a list of all the partitions that are auto-mounted. Add a line that looks like this:

/dev/hdb1  /windows    vfat  defaults  0 0

The primary slave will be mounted to /windows as a FAT32 drive every time the computer starts. This line uses the default options, which makes the directory writable for the root user, but read-only for everyone else. That can be changed by altering the options used.

/dev/hdb1   /windows   vfat   auto,users,async,exec,dev,suid,rw,mode=777,umask=000

That line seems to give it permissions of 777, which makes it read/write for everybody (it probably also does a bunch of other stuff that I have no idea about). This is important for making the Windows sharing easier later on.

Your FAT32 drive is now mounted as the /windows directory. The next step is to share that directory over the network using Samba so Windows computers can reach it.

Share it with Samba

Samba config

The Samba configuration file is /etc/samba/smb.conf. This is the file you will edit to set up Samba to work on your network. Most of the lines can be left as they are. The following lines are the ones that are really important to our task, so change or add or uncomment them as needed:

   workgroup = {your Windows domain}
   netbios = {Linux computer name}
   security = server
   password server = {your Windows PDC}
   username map = /etc/samba/smbusers
   local master = no
   wins server = {your domain WINS server}

Back in /etc/samba/smb.conf, you need to set up the shares. Public shares are set up like so:

[windows]
   comment = Windows Files
   path = /windows
   read only = no
   public = yes

With that line in smb.conf, the /windows directory that we mounted will be shared over the network as windows. Any computer accessing the Linux server through Network Neighborhood will be able to see this share and have full access rights to it.

smbusers

You also might need to edit the /etc/samba/smbusers file if you want to give certain users special access to the computer. By default, Linux will look at the Windows user name that is accessing files, and try to match it to a user name on the Linux system. If one doesn't exists, it will give it the permissions of the lowly nobody user. Since we mounted our directory with read/write access for everyone, that shouldn't matter. But for a higher level of control, use /etc/samba/smbusers. You can either add each user name in as a Linux user, or you can map them to an existing Linux user in smbusers. Edit the file, and add lines like this:

   root = administrator scotts

This line will take the administrator and scotts Windows user names and give them root access on Linux. Possibly not the best configuration, but the easiest if your security needs are light. And handy for remote administration.

Run Samba

One last step, Samba must be restarted.

service smb restart

Now that the drive is mounted and Samba is running, this computer is ready to be used as a file server. Any Windows computer can connect to its shares just the same as a Windows file server, and everyone has full access rights. Tighter security is possible, but I haven't quite learned that yet. This is a setup for a wide open share.

And with that, you're done!

Home Page | Weblog | About Me


Warning: include(tech/pagebottom.html) [function.include]: failed to open stream: No such file or directory in /home/schrantz/computer-vet.com/tech/linuxfileserver.html on line 147

Warning: include() [function.include]: Failed opening 'tech/pagebottom.html' for inclusion (include_path='.:/usr/local/php5/lib/php:/usr/local/lib/php') in /home/schrantz/computer-vet.com/tech/linuxfileserver.html on line 147