| Setting Up a Home File Server Part 1 March 20, 2008 1:20am in tech |
Computers are starting to get cheaper nowadays and many people are upgrading, and getting new computers leaving them with older desktops that either are just thrown out or left sitting around collecting dust. One use for these computers is to run as a home server for the family or the individual. Servers don't need to have the latest hardware so that makes the older computers the perfect candidate to be turned into a server. Servers have a whole range of possible functionalities, the most popular for home use being a file server where all can share their files in a central location. All a server really needs is some hard drive space and a network card (along with functional components, but for this, I'll assume that the computer works). I would recommend at least 100GB of hard drive space, the more, the better, but 100GB should do for starters. The first choice is what operating system will it run. If you're more comfortable with Windows and the desktop will run XP, you can go with that. The other choice is Linux, which as I've stated before has become significantly more easy to use, and in my opinion Ubuntu is the perfect candidate for this. Linux does have a slight learning curve, but its nothing that can't be overcome with some time and effort, so if you're willing to try it, Linux makes a perfect candidate to run as a server. I chose Ubuntu to set as the Linux distribution for this tutorial. Windows 2000 can also be used, but I would strongly recommend Ubuntu over Windows 2000. And if you're worried that if you host a file server under Linux, Windows and OS X won't recognize it, worry no longer, the shares will be accessible for all operating systems. Ubuntu Linux 7.10 Ubuntu Linux 7.10 Gutsy Gibbon is Ubuntu's latest version of their popular Linux Distribution and it's a pretty good one. The first thing you want to do is go to http://www.ubuntu.com and download the i386 desktop CD. I'd say the server version but I want to gear this tutorial to a basic user so it'd be a help for them to have a graphical desktop to help them out. Once you finish downloading the .iso file, burn the image to a CD using your CD burning software such as Nero or Roxio. Okay, now you have your CD burned so insert it into your CD drive and boot your computer up from the CD. At the initial menu, choose the option to Install Ubuntu. This will actually start Ubuntu as a live CD which means that you will be able to see basically how your system will look when its all finished. Keep in mind though that any changes you make won't be saved at this time. When you're ready, you should see an icon on the left of your desktop that says "Install". Double click on that to bring up the installer. Follow the prompts and choose the selections until you get to the partitioning menu. Make sure to note what you named the computer in the Hostname field. I don't have any real way to actually get screen shots for you easily so here's a link that will help with the entire setup, including partitioning. http://psychocats.net/ubuntu/installing My personal recommendation is that you set aside double the amount of RAM you have (so if you have 512MB of RAM, use 1GB) for your swap partition, give 10-20GB for the root (/) partition and then use the rest for data storage. You have to choose a name for the mount point which must begin with the forward slash (/). I mount my drives as '/data1', '/data2', etc but you can choose whatever names you'd like. The swap partition should be formatted as 'swap' and the others are probably best formatted as 'ext3'. After this just follow the prompts and let the system install. Ok, I'm now going to assume that the system is all installed, you rebooted and are now looking at your brand new Ubuntu desktop. The first thing you're going to want to do is to get the file share tool up and running. To do this, open up your terminal and type in the following sudo apt-get install samba smbfs It's going to prompt you for your password. That command will download and install Samba and the Samba file system. The next thing you will need to do is set up the shares. Now is the time when you have to decide how you want to arrange your files and shares. You can share multiple folders so don't worry about trying to fit all the folders and files into one folder if you want to organize it differently. If you open up your home folder, and then click on Filesystem, you can then navigate to where you mounted your data partition during the install. you can create folders in here for the directories you want to share, just remember what the locations are. The next part we're going to do the old fashioned way because I've always had more success this way so bear with me. The way I configure my shares is through the configuration file. It may sound difficult, but its actually not terribly difficult so bear with me. The first thing we want to do is to set up a samba user account. This is necessary for other computers to be able to connect as it sets up the credentials. First navigate to samba's directory. Open up a terminal window and type: cd /etc/samba when there type the following command to add a user to the list: sudo smbpasswd -a username The first thing its probably going to ask for is your password for the server itself. The next two prompts will be for you to enter the samba user's password and then to re-enter for confirmation. After that is done, the user is all set up and you're ready to go set up the shares themselves. In the same folder you're in now, you should see an 'smb.conf' file. This is the file you need to edit to add the shares. The first thing you should do is create a backup of it just in case something goes wrong, so run this command: sudo cp smb.conf smb.conf.backup This will create a backup file called 'smb.conf.backup' in the same directory should something go awry. Ok, now lets get into the actual configuration. Type in the command: sudo gedit smb.conf This will bring up a text editor to edit the file in. scroll all the way to the bottom of the file. This is where you're going to put the shares. It's important to know that each share will follow the following template: [share name]
One more comment, on the writeable section, you want to put yes if you want users to be able to write to the share (aka delete, move, copy files to). If all you want is just for a read-only share, then by all means put no instead. So now lets show an actual example. Lets say I want to share a family pictures folder with other computers in the house. I want people to be able to copy their photos into the share and be able to view the pictures. Let's also say that I created a directory /data1/photos to store the pictures. Here is how I would add the entry into the smb.conf file [photos]
That's it, not too hard at all, right? You can add all the shares you need to just make sure to put the share name in [ ] brackets to separate them. After you're done with that save the file and close the text editor. You should be brought back to the terminal window. There's one last thing you need to do in order for it to work. You need to restart the samba server for the changes to take place. To do so, just type the following command: sudo /etc/init.d/samba restart It will tell you that the samba service is stopping and then starting back up. Once you get to a prompt, thats it, the shares are all set, so go ahead and give it a try. In windows, go to Start - Run and type in: \\servername\share Where servername is the computer's name or hostname, which you set during the install process. So for my photo share if I named my server "Darker" then I would enter: \\darker\photos This should then ask you for a username and password (the one you set up using the smbpasswd command earlier), or if your windows username and password are the same as the samba username and password you set, then it should just bring up an explorer window with your share. In Windows, you have the option of mapping shares to drives so a share would be given an actual drive letter like a hard drive and DVD drive are given. To do this, right click on My Computer and select 'Map Network Drive'. The following dialog box should come up. The first field will let you choose which drive letter to assign it to, it doesn't matter so pick one. (it won't let you choose one that's already in use). The second field is where you type in your share name, which we went over in the last paragraph. The final checkbox determines whether the share should connect every time you log in. Since I'm going to assume that you want to be able to access the share all the time, you can just leave it checked. Just click 'Finish'. If it asks for a username and password, then enter it, otherwise it should pop up an explorer window showing the contents of the share. So there you have it, you now have your very own file server to host your files on. While this may sound obvious to some, in order for people to be able to access the shares you create, you must keep the server turned on. Some other uses for your server could also be as a MySQL database server, an Apache/PHP web server, if you're a developer, a subversion repository, as well as countless other possibilities. If any of this peaked your interest, feel free to do some research into them, Linux has a lot of potential that if you choose to put some time into, you can unlock. Also if you're brave enough, you can set up an ssh server on your server so you can access your server's terminal remotely. Next week, I'll go over how to create a server using Windows XP as the operating system. If you have any questions, need clarification, have comments, or have an alternate way of doing things, or more insight or help, then please, comment and let me know. Tags: ubuntu, linux, fileserver, howto |
| 2 Comments |
