Creating A Home Media & File Server With Ubuntu

For the past two years, I have used FreeNAS 7.x as a file-server. After the development was bought-out, the home-designed service fell by the wayside. The unfortunate consequence is that all of my data was stored on UFS GPT partitions which is does not have native support by either Windows or Linux kernels. The solution I decided upon was to purchase another 2TB hard-drive to use as a storage buffer to copy UFS data and repartition into EXT4 using Ubuntu 11.10’s terminal with a mount command.

After that hiccup, I set out to setup the best server option for my needs.

This HOWTO will give you the BEST home media and file server out there at a cheap (free) cost. It includes SSH2, Remote Desktop, UPNP/DLNA server, SAMBA Shares (Windows file-sharing), VPN server, and the Transmission bit-torrent server. The final piece of the schema is a new toy: Subsonic. This gives you web-based media streaming to watch your content anywhere via a web-browser.

Whilst Ubuntu may be installed on all sorts of hardware specifications, I recommend that you have no less than a 1GHZ dualcore machine (old AMD’s work great!), 2GB of RAM (I have 4GB), 40GB dedicated hard-drive space for Ubuntu, and an internet connection of decent speed (no old dial-up!). I have an AMD dualcore x64, 4GB of RAM, 40GB hard-drive dedicated to Ubuntu, two 2TB hard-drives for storage, and one 500GB hard-drive just for emergencies if space gets low.

Assumption: this guide assumes that you have had some minor, newbie experiences with Ubuntu or Linux at the least. If you haven’t, install Ubuntu and play around and explore the ecosystem for 10 to 20 minutes before continuing.

Assumption: you are not using this server as a router and are not using a firewall on this server because it is behind a home LAN network. If you use it as a router, take note of ports to open with your firewall script and the firewall rules used in the Remote Desktop section.


Let’s start!

Install Ubuntu 11.10. I recommend this being on its own hard-drive. I used a 40GB hard-drive partitioned with EXT4 at / with 32GB of space. The remaining 8GB was partitioned as SWAP space.

Once Ubuntu is installed, reboot into the system and run Software Update to install all of the latest packages. Reboot once more so that we are working from the latest kernel and software suites going forward.



Setting up SSH is very simple. This will give you console access should you be unable to reach the machine with Remote Desktop or like playing in terminal windows!

  1. Open up Terminal.
  2. Type
    sudo su
    so that we have root control. The password you used when setting up the Ubuntu user account will work for this.
  3. To install the software package type:
    sudo apt-get install ssh
    If you’re not worried about security, this is a stopping point as SSH is good to go.
  4. Let’s secure the daemon by editing the configuration. Type:
    gedit /etc/ssh/sshd_config
    to open up the config file.
  5. Find PermitRootLogin and set it to no
  6. Add a line below that variable and type AllowUsers (username) where (username) represents your Ubuntu account’s username.
  7. Type
    restart ssh


Remote Desktop

It’s a simple GUI to enable. The downside is that you must use TightVNC or some other VNC viewer for Windows if that is your OS of choice to Remote from. But if you want to have an RDP compliant server running (meaning want to use Windows native Remote Desktop client to connect to the server), complete the following steps.

  1. Open up Terminal.
  2. Type
    sudo su
    so that we have root control. The password you used when setting up the Ubuntu user account will work for this.
  3. To install the software package type:
    sudo apt-get install xrdp
  4. Forward the external WAN port 3389 to the LAN IP address for the server.

For RDP: Make sure to forward any port to the server’s internal port 3389. I use 3401 external port forwarded to the server’s LAN IP at port 3389.

For Ubuntu’s built-in VNC: Make sure to forward port 5900 to the machine. If you want to use JAVA viewer to access the Remote Desktop, you must also forward 5800.


SAMBA Server

Installing and configuring data-sharing which functions with Windows file-sharing. We will set up a share system whereby all LAN computers can navigate, access, and modify the shares. You may wish to do something further to secure SAMBA if your LAN environment isn’t "home" use.

  1. Open up Terminal.
  2. Type
    sudo su
    so that we have root control. The password you used when setting up the Ubuntu user account will work for this.
  3. To install the software package type:
    sudo apt-get install samba smbfs
  4. Edit the configuration. First,
    mv /etc/samba/smb.conf /etc/samba/smb.conf.orig
    and then
    gedit /etc/samba/smb.conf
    workgroup = HOME #(Set this to your Windows workgroup)
    netbios = HOME #(Set this to your Windows workgroup)
    security = share
    [Shared Drive] #(Set this to the name you want the shared folder to have)
    comment = entire shared drive #(Comments about the shared folder)
    path = /mnt/storage2/ #(Path to the shared folder or mount-point of harddrive)
    read only = no
    guest ok = yes
    writable = yes

Alternatively, you may want to have this as a share system where usernames and passwords or another form of security is in place. This isn't hard to do and many tutorials are available, but will not be a part of this "home" guide.


VPN: Set up a PPTP VPN which is supported by Microsoft and Android

  1. Open up Terminal.
  2. Type
    sudo su
    so that we have root control. The password you used when setting up the Ubuntu user account will work for this.
  3. To install the software package type:
    apt-get install pptpd
  4. gedit /etc/pptpd.conf
    # TAG: ppp
    # Path to the pppd program, default '/usr/sbin/pppd' on Linux
    #ppp /usr/sbin/pppd
    # TAG: option
    # Specifies the location of the PPP options file.
    # By default PPP looks in '/etc/ppp/options'
    option /etc/ppp/pptpd-options
    # TAG: debug
    # Turns on (more) debugging to syslog
    # TAG: stimeout
    # Specifies timeout (in seconds) on starting ctrl connection
    # stimeout 10
    # TAG: noipparam
    # Suppress the passing of the client's IP address to PPP, which is
    # done by default otherwise.
    # noipparam
    # TAG: logwtmp
    # Use wtmp(5) to record client connections and disconnections.
    # TAG: bcrelay <if>
    # Turns on broadcast relay to clients from interface <if>
    bcrelay eth0
    # TAG: localip
    # TAG: remoteip
    # Specifies the local and remote IP address ranges.
    # Any addresses work as long as the local machine takes care of the
    # routing. But if you want to use MS-Windows networking, you should
    # use IP addresses out of the LAN address space and use the proxyarp
    # option in the pppd options file, or run bcrelay.
    # You can specify single IP addresses seperated by commas or you can
    # specify ranges, or both. For example:
    # 1. No spaces are permitted between commas or within addresses.
    # 2. If you give more IP addresses than MAX_CONNECTIONS, it will
    # start at the beginning of the list and go until it gets
    # MAX_CONNECTIONS IPs. Others will be ignored.
    # 3. No shortcuts in ranges! ie. 234-8 does not mean 234 to 238,
    # you must type 234-238 if you mean this.
    # 4. If you give a single localIP, that's ok - all local IPs will
    # be set to the given one. You MUST still give at least one remote
    # IP for each simultaneous client.
    # (Recommended)
    # or
  5. gedit /etc/ppp/chap-secrets
    # Secrets for authentication using CHAP
    # client server secret IP addresses
    username pptpd password *
  6. /etc/init.d/pptpd restart
  7. Create a new document in /etc/init.d/ by doing
    touch /etc/init.d/ipv4pptpd
  8. Edit the document with
    gedit /etc/init.d/ipv4pptpd
    and insert the following text:
    # Provides: IPV4PPTPD
    # Required-Start: $remote_fs $syslog
    # Required-Stop: $remote_fs $syslog
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: Start daemon at boot time
    # Description: Enable service provided by daemon.
    echo 1 > /proc/sys/net/ipv4/ip_forward
    iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
  9. Type
    update-rc.d ipv4pptpd defaults
  10. Either reboot the machine so that the new routing tables are used, or type
    sh /etc/init.d/ipv4pptpd
    to start those tables.


uPNP DLNA MEDIA Server: Mediatomb

  1. Open up Terminal.
  2. Type
    sudo su
    so that we have root control. The password you used when setting up the Ubuntu user account will work for this.
  3. To install the software package type:
    sudo apt-get install mediatomb
  4. http://localhost:49152/
  5. Edit the config.xml to set up your own username, disable username requirements, add transcoders, and to enable Playstation3 requirements for playback. This can be done with:
    gedit /etc/mediatomb/config.xml


Bittorrent Server: Transmission

  1. Open up Terminal.
  2. Type
    sudo su
    so that we have root control. The password you used when setting up the Ubuntu user account will work for this.
  3. To install the software package type:
    sudo apt-get install transmission-daemon
  4. We cannot modify the settings with this process running. Type
    /etc/initi.d/transmission-daemon stop
  5. Modify the settings of the settings.json to fit your needs. Make sure to use the CORRECT paths for your setup. Mine are within a heirarchy of /mnt/torrents/. My customizations of choice are:
      "alt-speed-down": 950,
      "alt-speed-enabled": false,
      "alt-speed-time-begin": 1,
      "alt-speed-time-day": 127,
      "alt-speed-time-enabled": true,
      "alt-speed-time-end": 585,
      "alt-speed-up": 1,
      "bind-address-ipv4": "",
      "bind-address-ipv6": "::",
      "blocklist-enabled": true,
      "blocklist-url": "",
      "cache-size-mb": 2,
      "dht-enabled": true,
      "download-dir": "/mnt/torrents/Downloads/",
      "download-queue-enabled": true,
      "download-queue-size": 5,
      "encryption": 2,
      "idle-seeding-limit": 5,
      "idle-seeding-limit-enabled": true,
      "incomplete-dir": "/mnt/torrents/Incomplete/",
      "incomplete-dir-enabled": true,
      "lazy-bitfield-enabled": true,
      "lpd-enabled": false,
      "message-level": 2,
      "open-file-limit": 4,
      "peer-congestion-algorithm": "",
      "peer-limit-global": 240,
      "peer-limit-per-torrent": 60,
      "peer-port": 51413,
      "peer-port-random-high": 65535,
      "peer-port-random-low": 49152,
      "peer-port-random-on-start": false,
      "peer-socket-tos": "default",
      "pex-enabled": true,
      "port-forwarding-enabled": true,
      "preallocation": 1,
      "prefetch-enabled": 1,
      "proxy": "",
      "proxy-auth-enabled": false,
      "proxy-auth-password": "",
      "proxy-auth-username": "",
      "proxy-enabled": false,
      "proxy-port": 80,
      "proxy-type": 0,
      "queue-stalled-enabled": true,
      "queue-stalled-minutes": 30,
      "ratio-limit": 0.1000,
      "ratio-limit-enabled": true,
      "rename-partial-files": true,
      "rpc-authentication-required": true,
      "rpc-bind-address": "",
      "rpc-enabled": true,
      "rpc-password": "password",
      "rpc-port": 9091,
      "rpc-url": "/transmission/",
      "rpc-username": "admin",
      "rpc-whitelist": "*.*.*.*",
      "rpc-whitelist-enabled": true,
      "scrape-paused-torrents-enabled": true,
      "script-torrent-done-enabled": false,
      "script-torrent-done-filename": "",
      "seed-queue-enabled": false,
      "seed-queue-size": 10,
      "speed-limit-down": 500,
      "speed-limit-down-enabled": true,
      "speed-limit-up": 1,
      "speed-limit-up-enabled": true,
      "start-added-torrents": true,
      "trash-original-torrent-files": true,
      "umask": 2,
      "upload-slots-per-torrent": 14,
      "utp-enabled": true,
      "watch-dir": "/mnt/torrents/Autoload/",
      "watch-dir-enabled": true
  6. If you're pleased with the setup as-is there is no reason to continue onward. If you would like to set up a script to automatically update the blocklists file, let's keep going. It’s important to note that Transmission doesn't automatically update and process the blocklist file even though the settings.json has a position for it. Let's create a script to do it. Here's mine. Remember to modify the path structure to fit your operation.
    # 2012-02-27 Rewrote for Ubuntu
    # Orignial for FreeNAS 7.5
    # By Derek Gordon (crypted or derekcentrico depending on forums)
    PATH=/bin:/sbin:/usr/bin:/usr/local/bin; export PATH;
    cd /var/lib/transmission-daemon/info/
    gzip -dfq level1.gz
    mv /var/lib/transmission-daemon/info/level1 /var/lib/transmission-daemon/info/blocklists/
    rm -rf level1.gz
    echo "Blocklist update RAN on `date`" >> "/var/lib/transmission-daemon/info/update-blocklists.log"
  7. Set the above file to chmod +x and execute it in the terminal
    sh filename
    to update the blocklists. You can set this as a cronjob to run daily if you wish.
  8. Once that's done, restart transmission.
  9. Access the web GUI at http://localhost:9091


Web-based Media Server 

Subsonic streams almost all video and audio files through a flash-player on a web interface. A small donation to the developers allows you to have access to apps for Android and iProducts. This means native streaming to them as well.

  1. Open up Terminal.
  2. Type
    sudo su
    so that we have root control. The password you used when setting up the Ubuntu user account will work for this.
  3. To install the prerequisite packages, type:
    sudo apt-get install openjdk-6-jre lame flac faad vorbis-tools ffmpeg
  4. Subsonic is not part of the repositories for Ubuntu. We must download the latest version at Download the version for Ubuntu/Debian. Put this file in your /home/username/ directory. Go to that directory in terminal.
  5. Type
    dpkg -i filename
    where as of this writing, my filename was titled subsonic4.6.deb so I typed
    dpkg -i subsonic4.6.deb
  6. Now, go to http://localhost:4040 and sign in and finish setup via the web interface. Do what it instructs in RED. Click the link to secure the admin account.
  7. Afterward, go to Settings and customize the system to your preferences. Make sure to add the media directories to the player.

If you prefer a barebones media server, I suggest checking out VLC. It takes a lot more work to get up and running and its web-interface isn't as nifty.

Share this page:

20 Comment(s)

Add comment

Please register in our forum first to comment.



If this guide proves sufficient, I will add a couple more things to it at least... 

 Right now I have incorporated PS3 Media Server with Logitech Revue recognition and Handbrake GUI for video conversion.

 As it stands now:  this really makes a great media server, worthy VPN gateway to get around corporate or school DNS blocking, and a wonderful remote desktop environment for data processing.

By: Anonymous

do you support web access to the server? more specifically, can user login using web browser and run picture slide shows or upload his picture, etc? thanks.

By: Anonymous


 Another product I find that just works is Serviio. PS3Mediaserver, I found struggles.



By: Jerrac

Does the Xbox 360 support streaming from this set up?


I do not own an XBox but PS3MediaServer and Mediatomb both supposedly work with it.  I'm running both concurrently at this time.

By: Jason

One suggestion I would have as I'm going through the guide which so far is excellent. On step 4 though I'd find it helpful if you walked through the process much like you did in earlier steps. e.g. how to go about forwarding external WAN port 3389 to LAN IP addy?

By: Joey

I just wanted to thank you for putting together this HOWTO. It was wonderful and now I have a great media server to run on my home network. Thanks 5 Stars!!!

By: Joe

You state to load Ubuntu but do not mention which version, Desktop or Server.  It would be nice to make mention to that in the How-To.

By: TheTechMan711

You can actually tell what kind of ubuntu he is using (desktop or server) becuase on server you cannot use "gedit" because that command brings up a gui, which ubuntu server doesnt have. Hope that helps everyone!

By: Anonymous

have you ever tried apt-get install ubuntu-desktop on a ubuntu-server

By: TheTechMan711

Well, even if he is running ubuntu desktop on his server, he is still running the GUI version.

By: shome

Wondering which approach would be good for home media server. Buy the NAS or build it? Which one is good among these NAS servers?

By: dan

Here's my new media setup:  I took a windows server that was pretty nice, but I no longer needed, installed Plex on it, then mapped a directory off of my Synology Diskstation.

So, that gives me Plex, which shows up right on my Roku and Amazon fire and phone and any web interface.  Very very nicely.  The synology, may seem totally unnecessary, BUT, it is fan-tastic with bittorrent.  Basically, if I want to see a movie or show, I just look it up on my phone, click the torrent I want and the synology starts loading it.  Plex is scanning for changes, so.... after a few minutes, it appears on my Roku.  Since the server is pretty big  (it's got 1gig of memory with nothing but Plex running on it), the transcoding is practically instant.

I tried running transmission from it.... there's very little remote capability that's professional.  all in all, I'd say that the ideal media server would probably be a decent Mac.  (which I used to have)  linked to the Synology.Here's what I'd recommend to people:  Go get an old mac with a few gig of memory off ebay or craigslist.  Get a 112 or 111 synology used.  Get an old Roku (or just use a tablet).  Install Plex on the Mac, install Download Station on the Synology.  Map the ports.  The only coding you may have to do is to set up the mac to map the drive to the diskstation.  If you've got a crappy windows workstation you want to recycle..... don't.  Go mow a few lawns and get that mac.  Seriously.  You'll spend a TON of time screwing around with Linux if you don't know it already, and once you get it to work, when it breaks (and everything breaks) a year later, you'll have to learn it all over again.

By: James

Great tutorial, very helpful.  Thank you my friend!

By: Bob

Where is ?

By: Frans

SSH don't work anymore on Ubuntu 11.10

By: andrew

Thanks for this. I was able to do this with a few slight changes, main one was replacing MediaTomb with Gerbera (built on MediaTomb)


By: jelabarre59

So just how ***OLD*** is this article? There's no date anywhere, and even the comments don't have dates. The only clue to it's age is someone's comment that something no longer works with Ubuntu 11.10. That means *AFTER* the article was written, someone was trying it on an Ubuntu install in late 2011. It is now late 2020 (for anyone reading this comment in 2030, and wondering just how stale the information is).

By: till

The article mentions in the first chapter that it is written for Ubuntu 11.10.

By: Mate Lover

Thank you for the howto. I'll see if I can build it on 220.04 LTS