Setting up a NAS on a spare machine

with Fedora and Samba server.

After being highly disappointed with a number of commercial NAS products, I begrudgingly decided to try and set up my own Linux-based file sharing system on a spare computer of mine. Now there is nothing wrong with Linux and it's associated applications. They actually work quite well. The begrudging part is the initial setup. Linux-based systems are best suited for hackers and seasoned system administrators. Set up is often done on the command line by editing configuration files using archaic text-based editors (I don't care how powerful those editors are, they are dinosaurs of the past that should have gone the way of the floppy drive). Some of this is elieviated with newer applications that run on either the Gnome or KDE GUIs for Linux, but it still feels like a chore. Tutorials almost don't exist in Linux-land. Learning how to do something is often a long process of reading "man" pages, searching message forums, and searching for relevant tech articles on the web. And to make it that much worse, seasoned Linux users, even when well intentioned, can be quite annoying as they are generally overflowing with God complexes.

In the end, I got it all set up, and so far it works great. But it took me many many hours to figure out something that should have taken far less time. To help others that may want to set up a similar system but don't have the time and/or ambition to spend a lot of time on it, I have summarized the steps I took in setting up my system to serve as a sort of quick reference to get your system up and running as quickly as possible.

A few caveats. The steps I took are not the only approach. It's the approach I figured out. There may be a better way to handle certain steps, or at the very least, alternate ways that others may find more appealing. Second, I did not care one iota about security. At my house, there is me, my wife, and my 1.7 year old son. I trust my wife, my son is too young to break anything, and I don't get too many visitors or people breaking into my house at night to use my network. So why hassle with security? I therefore set up parts of the system in insecure ways to gain additional ease of use and simplify setup.

So lets get to it. For my Linux OS and GUI, I chose Fedora. To enable the file sharing, I chose Samba, as it is fairly standard and works well with both Windows and OS X. That's all it takes. But it sounds a lot easier than it is. So here it is, step by step.

Fedora 18 with Samba 4.x

  1. Download Fedora. It's provided as an ISO disk image, small enough to fit on a CD-R. Burn it to disk.
  2. Configure your BIOS. On your spare machine, go into the BIOS and configure it to boot from the CD-ROM first. While you are at it, you might also look around for a setting that will make the system boot up automatically after a power outage. That's a nice feature to turn on if you want maximum up-time with minimal maintenance. Some motherboards have it, some don't, so you may or may not find it.
  3. Install Fedora 18. Place your Fedora disk into the CD-ROM and boot it up. It should boot right into Fedora from the CD-ROM. However, that doesn't mean it's installed. There should be an icon that appears on the desktop to install Fedora to the hard disk. Double-click it and install Fedora to your hard disk. I'm not providing any help on that part. Fedora has decent installation docs you can access online for assistance. Once installed successfully, you may want to go back into the BIOS and set it to boot from hard drive first.
  4. Set Host Name. When I installed Fedora 18, it didn't give me the option to set the host name. It just defaulted to "Localhost". To set the hostname, issue the following command (replace "whatever" with whatever host name you want):
    hostnamectl set-hostname whatever
  5. Do all setup as the root user (*Linux nerds everywhere gasp in horror*). Make your life a lot easier, and just perform all setup using the root account. Unlike Fedora 13 I used previously, you should be able to log in as root without having to modify anything first.
  6. Install/Update Additional Software. Right out of the box (or CD), Fedora is missing a few things you will need. Linux (or some versions of it) luckily come with a magic installation utility called "yum". Apparently it tastes good. However, to use it, you need to know the magic command-line parameters and package names. I don't know where to get those...there is probably a directory of package names out there somewhere, but you won't need them because I tell you all you need to know here. So lets go ahead and install some of those missing components. Open up a terminal window. I don't know if there is a GUI for running "yum". So well just enter the commands from the terminal.
  7. Enable Samba. In Fedora 13, I suggested enabling Samba through the system-config-services tool. However, in the latest Samba 4.x, the smb and nmb services no longer show up in that tool. Instead, you need to issue some console commands:
    systemctl enable smb.service
    systemctl restart smb.service
    systemctl enable nmb.service
    systemctl restart nmb.service
  8. Free Samba to do it's job. This step consists of configuring the system so it doesn't get in Samba's way.
  9. Configure Samba. In older versions, it was easiest to set the value for security to "share", but "share" has apparently been disabled in Samba 4.x. You also need to set the "map to guest", which you might not be able to do through the GUI, so you may just need to manually edit the samba.conf file for that line.
    [global]
    security=user
    map to guest=Bad User
    I'm not sure if "Bad User" is a special name or if the value just needs to be something that doesn't really exist. To set up which directories to share and how they are shared, I recommend just using the Samba GUI tool; it's easier than doing the hand editing of the config file.

Fedora 13 with Samba 3.x

  1. Download Fedora. It's provided as an ISO disk image, small enough to fit on a CD-R. Burn it to disk. If your system doesn't have software for handling ISO images (mine didn't), there is some free burner software out there that will work. I used InfraRecorder.
  2. Configure your BIOS. On your spare machine, go into the BIOS and configure it to boot from the CD-ROM first. While you are at it, you might also look around for a setting that will make the system boot up automatically after a power outage. That's a nice feature to turn on if you want maximum up-time with minimal maintenance. Some motherboards have it, some don't, so you may or may not find it.
  3. Install Fedora 13. Place your Fedora disk into the CD-ROM and boot it up. It should boot right into Fedora from the CD-ROM. However, that doesn't mean it's installed. There should be an icon that appears on the desktop to install Fedora to the hard disk. Double-click it and install Fedora to your hard disk. I'm not providing any help on that part. Fedora has decent installation docs you can access online for assistance, such as the Installation Quick Start Guide. Once installed successfully, you may want to go back into the BIOS and set it to boot from hard drive first.
  4. Do all setup as the root user (*Linux nerds everywhere gasp in horror*). Make your life a lot easier, and just perform all setup using the root account. However, you need to edit a couple of files before Fedora will let you log in as root in the GUI. Log in with a regular user account and open a terminal window. Switch to the root account by issuing command
    su - root
    . It should then prompt you for the root password. Then navigate to the /etc/pam.d folder. In there, edit the files gdm and gdm-password. To use the GEdit GUI editor, issue command
    gedit gdm
    for the first and
    gedit gdm-password
    for the second. Remove the line that says "user != root", or just change "root" to some user name you won't use. Save and exit. Once you have edited both files, you should be able to log out and log back in with user "root".
  5. Install/Update Additional Software. Right out of the box (or CD), Fedora is missing a few things you will need. Linux (or some versions of it) luckily come with a magic installation utility called "yum". Apparently it tastes good. However, to use it, you need to know the magic command-line parameters and package names. I don't know where to get those...there is probably a directory of package names out there somewhere, but you won't need them because I tell you all you need to know here. So lets go ahead and install some of those missing components. Open up a terminal window. I don't know if there is a GUI for running "yum". So well just enter the commands from the terminal.
  6. Free Samba to do it's job. This step consists of configuring the system so it doesn't get in Samba's way.
  7. Setup Swat. (optional). Edit /etc/services. It's a big file. Search for "901", to see if any services are already set up for that port. The line you are looking for should be something like: "swat 901/tcp". If you don't find a line that sets up swat for 901/tcp, add it. Now edit file /etc/services/xinetd.d/swat. It probably has a line that says "disable = yes". Change it to "disable = no". You then need to restart xinetd, which you can do in the terminal with command
    service xinetd restart
  8. Configure Samba. You can either edit the file /etc/samba/smb.conf, or if you installed SWAT, point your web browser to "http://localhost:901/". To setup a low security "shared" folder that everyone could access, I set up my parameters somewhat like this (some content omitted):
    [global]
        security = share
    [homes]
        read only = No
        browseable = No
    [shared]
        path = /home/shared
        read only = No
        guest ok = Yes
    (*Linux hackers gasp again and pass out*)
    Make sure to change permissions on the directories you are sharing with Samba (this would include the "/home/shared" directory in the example). Find those directories in your file browser, right-click them, and set the permissions as needed.
  9. Setup Samba to start automatically when system is booted. In the Service Configuration utility (refer to 3rd sub-bullet of step 5), enable both "smb" and "nmb". This will ensure they are auto-started.