1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Linux Fileserver guide using Debian

Discussion in 'Software' started by Glider, 18 Feb 2007.

  1. Glider

    Glider /dev/null

    Joined:
    2 Aug 2005
    Posts:
    4,173
    Likes Received:
    21
    After the "What is this Linux thing?" it seemed about time to write an other guide. More and more people are having the need for a fileserver on their network, and while FreeNAS works great and easy to set up, the geeky-ness level is quite low. There for, let's do it all on our own.

    In this guide we'll install a Debian System and add SSH, Samba and proFTPd to the system, so that our server will dish out files to everyone on the LAN, and is remotely accessible for administration.

    Hardware
    A fileserver doesn't require great hardware. Actually, about any system will do.
    CPU : Anything 500MHz or higher is plenty for home usage.
    RAM: I'd recommend using 128MB or more.
    HD: The sky is the limit. The Debian install will take ~500MB + SWAP, but I recommend 1.5 - 2 GB for the OS. That will also leave some room for expansions.

    For this guide, I installed Debian in a virtual machine, by VMware. This gave me the advantage of taking screenshots.
    [​IMG]
    The virtual machine is networked, using DHCP. I'll also include a paragraph how to set up a static IP after the install has finished.

    Installing Debian
    Installing Debian to a system starts with downloading the correct ISO. Since I'm on a DSL line, I got the net install cd. The advantage to this is, that you don't have to download anything you don't need.

    Burn the ISO to a blank CD and boot from it, just like you would do with a Windows install. When the system has booted, you'll be greeted with a nice splash screen. (For all the thumbnails, click on it to open the image full size)
    [​IMG]
    At this prompt, just typ
    Code:
    linux26
    ...and hit <enter>. This will boot a 2.6 kernel and start the install. You'll see a lot of text flashing by, this is the installer booting.

    Once it has booted, you'll be greeted by a dialog. The entire process of installing Debian is based upon these dialogs. They are straightforward select and enter dialogs. For this guide, I allways tried to set the selection box right, so it will be easy to follow all the steps.

    [​IMG][​IMG][​IMG]
    First we start with language selection, followed by country selection & keyboard layout. All are straightforward select and enter operations.

    [​IMG][​IMG]
    Then, we name our server. For the ease of the guide I chose "fileserver". We also need to input the name of the network. I chose "bit-tech.net". On a LAN the network name doesn't matter that much, as long as you keep it the same on all your machines.

    [​IMG][​IMG][​IMG][​IMG]
    Then we move on to the partitioning of the drive. We will manually set up the partition layout.
    A typical layout is:
    • hda (Primary IDE)
      • /boot ( ~50MB ) => Boot partition
      • SWAP ( 2 * RAM ) => ~Windows pagefile
      • / ( > 1,5 GB ) => The main system
      • /tmp ( 1 GB ) => Temporary directory
    • hdb (Secondary IDE)
      • /home ( entire hdb ) => ~My Documents

    Because these are "new" drives (in the VM), none contain a partition table. So first select the first drive and hit enter. The installer will ask us if we want to create a new partition table. Of course we do. We now have a device, which has free space for us to partition. So select the "FREE SPACE" and hit enter.

    [​IMG][​IMG][​IMG][​IMG]
    The installer now will ask us some questions. We are creating a new partition, with a size of "50M", which is a primary partition at the beginning of the drive.

    [​IMG][​IMG][​IMG][​IMG]
    Then, we define the partition (Filesystem, mountpoint,...). First select mountpoint, hit enter and change it to "/boot". Because /boot needs to be bootable, also select that. All the rest is correct, so we are done setting up the partition. We now have a Primary partition at the beginning of the drive, ~50MB big, with an ext3 filesystem and it will be mounted at /boot.

    [​IMG][​IMG][​IMG]
    We repeat the above for the other partitions. Create following partitions:
    • swap: 2*RAM ; Primary ; Beginning of the drive ; Filesystem "swap area" ; non-bootable
    • / (root): >1.5GB ; Primary ; Beginning of the drive ; Filesystem "ext3" ; Mountpoint / ; non-bootable
    • /tmp: 1 GB ; Primary ; Beginning of the drive ; Filesystem "ext3" ; Mountpoint /tmp ; non-bootable
     
  2. Glider

    Glider /dev/null

    Joined:
    2 Aug 2005
    Posts:
    4,173
    Likes Received:
    21
    Fileserver guide using Debian (part 2)

    [​IMG][​IMG][​IMG][​IMG]
    Now we repeat it for the 2nd drive. Create a new partition table, and create a new partition;
    • /home: Entire drive ; Primary ; Filesystem "ext3" ; Mountpoint /home ; non-bootable
    After this we are finished with the partitioning, and we write the new partiton tables to the disks.

    [​IMG][​IMG][​IMG]
    The installer will now start to install the base system. At the end it will ask us if we want to install the bootloader into the Master Boot Record of the drive. Because Debian will be our only OS, we answer "YES" to it. Short time after the base install is complete. Remove the CD and press continue. Your system will reboot into it's own environment.

    We aren't done tough, now it's time for some post install configuration.
    [​IMG][​IMG][​IMG]
    After the welcome, we start setting up the clock info. This is important for further updates. For servers, it's best to set the hardware clock to GMT, and select the correct timezone. For all the English people this isn't a problem because GMT = local time.

    [​IMG][​IMG][​IMG][​IMG][​IMG][​IMG]
    Now we continue with setting up the users. First, we set, and verify, a root password. Since Root = Administrator, try setting up a strong password. After that, we add a new user by giving it's full name, logon (username), and password.

    [​IMG][​IMG][​IMG][​IMG][​IMG]
    Then we will set up APT, the Debian package manager. A package manager is a program that installs and deletes "software packages" to the system, and resolves their dependencies. Later on we'll be using APT to upgrade/update our system, and install the needed packages.

    Since we used the netinstall cd, there are no more packages to install from cd. Users who chose the full install might use this tough. We add in another source at this time, a fast FTP server. I chose the Britain server of Debian, but you can choose an other one here. For now, this is the only server we'll add.

    [​IMG][​IMG]
    Now, APT will ask us what we want to do with our system. All tough File server is a choice, we'll go for a manual package selection. This is because a lot of unneeded junk will be installed otherwise. When Aptitude opens we just press "q" and quit aptitude. We will install packages later on.
     
    Last edited: 11 May 2008
  3. Glider

    Glider /dev/null

    Joined:
    2 Aug 2005
    Posts:
    4,173
    Likes Received:
    21
    Fileserver guide using Debian (part 3)

    [​IMG][​IMG][​IMG]
    Every Debian system must have a Mail Transfer Agent configured. But the standard MTA has the option to only allow local delivery. So that is what we'll do. Let it deliver system mails to the standard user (created earlier).

    Congratulations, you've just installed your Debian System.

    [​IMG]
    Just log in as "root", using the earlier set root password. You greeted with the powerfull CLI. The CLI is the real strenght of Linux.

    Now we'll set the static IP. Issue:
    Code:
    nano -w /etc/network/interfaces
    Look for the line containing "iface eth0 inet dhcp", and change it to:
    Code:
    iface eth0 inet static
       address <IP Adress>
       netmask 255.255.255.0
       gateway <Gateway>
       dns-nameservers <IP DNS>
    Type "<ctrl> + x" to quit, and confirm with "y" and "<enter>".
    NOTE:I set mine to 192.168.123.129, because of the virtual machine

    Now we restart the networking
    Code:
    /etc/init.d/networking restart
    And check if it works by pinging something:
    Code:
    ping -c 3 google.com
    If you get 0% package loss, then you are good to go...

    Now, we will upgrade our system from "stable" to "unstable". But don't fear the word unstable. The unstable repositories are stable, just not guaranteed 100%. Something we won't have problems with on our system.

    But before we update & upgrade, we remove some unneeded stuff.
    Code:
    dpkg -l
    This command gives us a list of all installed packages. But because that list is way too long to fit on the screen, we need to 'pipe' the output of the list to less, a command line file viewer. Piping is an other strength of Linux, and is done though the " | " (vertical line) character. So to make the output viewable, issue:
    Code:
    dpkg -l | less


    Just browse through the packages, to get a feeling of what it takes to make a Debian system tick. You exit less by pressing "q". I selected "iptables", "ipchaines" and "ppp" as packages to be removed. If you want to use iptables, ipchaines or ppp don't do the following step! You remove these packages by issuing:
    Code:
    apt-get remove --purge iptables ipchaines ppp

    NOTE: the '--purge' also clears all related config files. For more info issue "man apt-get"
    You'll get an overview of what is going to happen.
    [​IMG]
    Apt will ask us to confirm our comand, just hit enter.

    Now we will upgrade from "stable" to "unstable". Issue:
    Code:
    nano -w /etc/apt/sources.list

    ... and change from
    [​IMG] to [​IMG]
    ... And exit with save.

    We now have added the unstable repositories to our system. Now we first need to update the repository list. We do this by issuing:
    Code:
    apt-get update

    After the repositories are updated, we upgrade our system by issuing:
    Code:
    apt-get dist-upgrade

    NOTE: In the future, we issue a "apt-get upgrade" to update our system, dist-upgrade is only issued when we switch repositories

    Because we update all core packages too, we will be once again greeted by some dialogs with questions.

    [​IMG][​IMG][​IMG][​IMG][​IMG][​IMG][​IMG][​IMG][​IMG][​IMG]
    Mostly the choices are straightforward.

    At one time during the upgrade you'll get this (disturbing) message:
    [​IMG]
    Don't let this scare you! We have to remove the "stable" kernel to install the "unstable" one.

    glibc is one of the core packages of the C compiler. Because it is such a core system library, you'll be prompted for it's update. Go ahead with it.

    Also, in linux you'll won't need to reboot the system if a service is upgraded. You do need to restart it tough. So we answer "y" to that question.

    [​IMG][​IMG][​IMG][​IMG][​IMG]
    And more straightforward configuration...

    Now we install the new kernel.
    Code:
    apt-get install linux-image-2.6-686

    NOTE: This will install the latest kernel from the unstable branch, optimised for 686 processors. If you use old machines, there are also 586,486 and 386 versions available.

    [​IMG]
    Don't you love it how apt resolves all dependencies? You'll notice that there are some other packages (like udev) that are installed with the new kernel. This is normal.

    After this is finished, reboot into the new kernel.
    Code:
    reboot


    Congratulations, you just installed & upgraded Debian on your server.
     
    Last edited: 18 Feb 2007
  4. Glider

    Glider /dev/null

    Joined:
    2 Aug 2005
    Posts:
    4,173
    Likes Received:
    21
    Fileserver guide using Debian (part 4)

    SSH
    After the system is rebooted, log in as root once again. We will now install a SSH server, so that we can remotely administrate our server.
    Code:
    apt-get install ssh

    And let Apt do it's magic...
    [​IMG]
    After the install is complete, we go configure the ssh server...
    Code:
    nano -w /etc/ssh/sshd_config

    The default config is quite secure by default, and hardly needs changes.

    Just look for the line containing X11Forwarding, and change "yes" to "no". We won't be installing an X server, so this is not needed at all. I'd recommend you browse through the rest of the configuration file tough, just to get a feel of it.

    And then, just start the SSH server by issuing:
    Code:
    /etc/init.d/ssh restart


    [​IMG]
    You can check wetter the server works by connecting to it from an other PC using Putty. I tested it by sshing from an other linux system.

    Samba
    Next step is installing and configuring samba, to share our files with other systems.
    Same procedure as allways...
    Code:
    apt-get install samba

    [​IMG]

    [​IMG][​IMG][​IMG][​IMG][​IMG]
    And again some configuration. First set the "WORKGROUP", and then answer the other logical questions. This gives us a base setup of our samba server.

    Code:
    nano -w /etc/samba/smb.conf

    This is the main samba configuration file. It is documented, and you should read it.

    For the impatient ones, I made a base config. Make sure that you replace <name> and <server name> with the correct values!


    Now that our config is set up, we just need to add users to the samba system (it uses an independant user db). That's why we need to issue an other command to set up a samba user. Issue:
    Code:
    smbpasswd glider

    NOTE: Passwords you input aren't shown

    Finally, we restart the samba server by:
    Code:
    /etc/init.d/samba restart
    And there you go, samba is set up.

    proFTPd
    Last thing to set up is the ftp server.
    Code:
    apt-get install proftpd

    We know the drill by now...
    [​IMG]

    [​IMG]
    We will run the ftp server as a standalone. Not because of performance, but because of userrights. As standalone, the ftp connection will run as a user.

    Again, configuration is done through /etc/... (which is the main configuration dir on Linux)
    Code:
    nano -w /etc/proftpd/proftpd.conf


    For the impatient ones, I made a base config.

    While it isn't really needed, restarting the ftp server will make sure the new config is used
    Code:
    /etc/init.d/proftpd restart
    And the ftp server is set up.

    Aftermath
    Now we have a server which dishes out files via samba or ftp to our main user. Of course we want more then that. To have an other user connect to the server, we need to make a useraccount for the user, and add him/her to the samba password backend. Don't worry, I made a short script for it (not te nicest of scripts, but it works).

    First, get the script:
    Code:
    wget http://glider.sin.khk.be/linux_guide/fileserver/useradd.sh
    Then, make it executable:
    Code:
    chmod 700 useradd.sh
    And then, to run it:
    Code:
    sh useradd.sh
    If you don't need that much security, and just want everyone to acces the shares, uncomment (remove the # at the beginning) the "public = yes" line in /etc/samba/smb.conf. That makes the samba shares public, and accessable via anonymous login. In the /etc/proftpd/proftpd.conf there is also a section about anonymous logon. It's pretty straightforward.

    That concludes this guide. It's just an drop out of the Linux ocean, but I hope it helped you to up a fileserver. Any questions/suggestions, just shoot!
     
    Last edited: 18 Feb 2007
  5. r4tch3t

    r4tch3t hmmmm....

    Joined:
    17 Aug 2005
    Posts:
    3,166
    Likes Received:
    48
    Great guide:thumb:, have it bookmarked for when this computer becomes a file server.
     
  6. Woodstock

    Woodstock So Say We All

    Joined:
    10 Sep 2006
    Posts:
    1,783
    Likes Received:
    2
    just out of curiosity can this be run without a gpu?
     
  7. ajack

    ajack rox

    Joined:
    17 Apr 2003
    Posts:
    2,695
    Likes Received:
    2
    Yep, not much point in hooking up a monitor to it anyhow since you can do any maintenance over ssh.
     
  8. Woodstock

    Woodstock So Say We All

    Joined:
    10 Sep 2006
    Posts:
    1,783
    Likes Received:
    2
    what i thought but i thought id ask to be sure
     
  9. Glider

    Glider /dev/null

    Joined:
    2 Aug 2005
    Posts:
    4,173
    Likes Received:
    21
    You surely can, but sometimes motherboards require a GPU to be installed to boot. But any, and I do mean any, GPU will do.
     
  10. techguru

    techguru New Member

    Joined:
    28 Feb 2008
    Posts:
    1
    Likes Received:
    0
    debian server setup

    I downloaded amd64 netinst and started to setup my server, but the first instruction of typing linux26 did not work could we look at this?
     
  11. steveo_mcg

    steveo_mcg New Member

    Joined:
    26 May 2005
    Posts:
    5,841
    Likes Received:
    80
    Just hit enter and it should install using the default options. This guide is quite old now etch installs a 2.6 kernel by default the guide was using Sarge (I think?)
     
  12. BioSniper

    BioSniper New Member

    Joined:
    5 Feb 2002
    Posts:
    3,815
    Likes Received:
    18
    Actually, seeing as how this has bee bumped to the top, Glider; is it possible to have some shares totally public while other shares only being accessable by user/password combos?
    For instance my media centre records to a share which I would like everyone to be able to view without the need for a user, but I want my folder with my documents in it to be user/pass protected.

    Is this actually possible with samba?
     
  13. evilgreenie

    evilgreenie Standby for Main Engine Burn

    Joined:
    30 Aug 2002
    Posts:
    83
    Likes Received:
    0
    You can run a debian fileserver on pretty much anything all the way down to a 50 quid Linksys NSLU "Network Storage Link" using a specially cut-down distros.

    Debian on a NSLU
     
  14. Elv13

    Elv13 New Member

    Joined:
    26 Apr 2006
    Posts:
    107
    Likes Received:
    0
    Yesterday i did install debian sarge (old) on a p1 100mhz with 32mb of ram and no cdrom drive using floppy (3 (boot, root and net)) + pcmcia network card, then i upgraded to etch (current stable version). It work fine, not it is compilling X (kdrive/xVesa module) to get a decent Xserver on it. If it dont work, i will try xfree86 4 or 4.2 to see witch one still build after all these years.
     
  15. scimmy

    scimmy Member

    Joined:
    17 May 2005
    Posts:
    198
    Likes Received:
    4
    A most excellent tutorial, many thanks
     
Tags:

Share This Page