What if I told you that you can set up a low powered, virtually silent, fully functional linux home server for only $30 (not including shipping)? Because that’s exactly what I just did. I set up a home server for less money than I spent on groceries this week. Impossible? Not at all. It is not only possible but also practical.
Behold my tiny server running Squeeze (Debian 6.0.5):
The device you are looking at here is called PogoPlug and it is probably one of the best purchases I have made in the last few months. It is driven by low power, Feroceon 88FR131 rev 1 (v5l) CPU and has 256MB of RAM, a Gigabit Ethernet card, and 4 USB 2.0 pots which is actually not bad for a super-cheep NAS device. By default, it ships without a hard drive, which is likely why it is so inexpensive.
Out of the box it is running a locked down version of Arch Linux with proprietary extensions. But, it is not difficult to root it. Or better yet, you can configure it to boot from an attached flash drive instead of the internal storage. Which is great, because if you manage to fuck up the installation somehow, all you need to do to go back to square one is to pull out the flash drive and power cycle.
This is exactly what I did – I installed Debian Squeeze on an external 2GB flash drive connected to the device and so far it has been working great.
How to Set it Up
I can’t take any credit for figuring out how to perform this installation – I simply followed this excellent writeup an used one of their provided self-installation scripts. It is more or less a push-button setup… Only you have to push a few dozen buttons, and they need to spell out a few unix commands. But it’s easy.
The first step is figuring out the IP your PogoPlug will get from the DHCP. The easiest way to do this is to log into your router and watch it’s DHCP client list. For example, my D-Link router shows me something like this:
You will probably notice that my DHCP leases are set to never expire – that’s actually on purpose. I permanently assign IP addresses to machines on my network. This makes network issues easier to troubleshoot, and actually lets me make sense network logs. But since I use a lot of roaming mobile devices and share the network with people who couldn’t be bothered to set up static IP on their machines I use DHCP reservations to accomplish that. But that’s a digression.
In my DHCP list you can see PogoPlug on top. That’s because I gave it a unique low IP just to make it easy to remember. Let’s say that address is 192.168.1.100 or something like that. As soon as the device grabs a lease from DHCP you should be able to ssh to it:
The default password is ceadmin.
From here, you can explore a little bit and poke around the device. You will probably notice that most filesystems other than /tmp are mounted read-only and what you can do with the device is rather limited. Hence the need for Debian installation.
Next thing you want to do is to plug in the flash drive you will be using for installation. The first drive you plug in usually becomes /dev/sda1 but you can easily check that by running dmesg.
Next, you will want to partition your flash drive using fdisk. For some reason the binary was not in /bin/ or /usr/bin/ and therefore not in $PATH so I had to invoke it like this:
You can press p to see the partitions on your drive. Not sure why, but mine had four, so I deleted them using d command available from the menu.
Next I create two new partitions:
- Press n to create a partition, p to set it as “primary” and 1 to designate it as first
- Hit Enter to accept the default starting point
- Specify size using the format +[size]M where [size] is an actual value in MB. For example, I used +1536M designating majority of the space on my 2GB drive for my primary partition, and leaving 512MB for swap. If you have 4GB drive use +3582 and so on.
- To set up second partition hit n, p, 2
- Hit Enter to accept the default starting point
- Hit Enter once again to use all the remaining space
- Hit t then 1 to change the filesystem on partition 1 and use 83 (Linux)
- Hit t then 2 to change the filesystem on partition 2 and use 82 (Linux Swap)
- Hit a, 1 to make first partition bootable
- Hit w to write changes to the disk
Up until the last point the changes are fully reversible, so don’t worry if you mess up. Just quit and start over. When you’re done the p command should return something like:
/dev/sda1 * 1 911 3501853 83 Linux /dev/sda2 912 1018 411308 82 Linux swap
Finally the big step – installation. This is deceptively simple and I take no credit for it whatsoever. Just make sure you are in /tmp/ because that’s the only writable directory on the device:
cd /tmp wget http://projects.doozan.com/debian/dockstar.debian-squeeze.sh chmod +x dockstar.debian-squeeze.sh export PATH=$PATH:/usr/sbin:/sbin; ./dockstar.debian-squeeze.sh
If the above wget command does not work, you can download it from here instead:
The installation takes about 20 minutes or so. Note I used Squeeze and not Wheezy. That’s because the Wheezy script crapped out on me with a message “kernel too old”. Squeeze on the other hand worked like a charm.
Once the download and installation finished the device will reboot. If your router allows you to use DHCP reservations based on MAC addresses, it is a good idea to set one up before rebooting. When the device comes back, it reports as debian and not PogoPlug to the DHCP server.
Here is a little tip: don’t wait for green LED on PogoPlug before you try to ssh back in. That will never happen. The front LED control is one thing that does not work. It remains yellow/orange no matter what you do. But as soon as it stops blinking, the device should be ready to go.
The default password for the Debian install is root.
Note: if the PogoPlug LED blinks green, and you can’t log in with the default Debian password, it probably means the install did not take. Log in with ceadmin again and start over.
First few things you should do
First thing you should do upon logging into your newly created Debian box is to change your root password but that goes without saying. Second thing, is to decrease swappiness of the system. Most solid state drives have an upper limit of write operations per cell they can withstand until they break. So leaving Linux in it’s usual swap-happy mood will likely decrease the lifespan of my little server. Not the PogoPlug itself, but the drive I attached to it. So I ran:
The default is 60, and you can go as low as 0, but I figured better safe than sorry and opted to set it reasonably low. Ideally, you don’t want it to ever have to swap, but if for some reason you run out of memory, setting this to 10 and not 0 will prevent lockups and/or crashes.
Third thing is to fix your /etc/apt/sources.list. By default you get only the main repository, and no contrib, non-free and security updates. I have changed mine to this:
deb http://mirror.cc.columbia.edu/debian/ stable main contrib non-free deb http://security.debian.org/ stable/updates main contrib non-free
Why? Because those repose were the fastest. How do I know? Because netselect-apt told me so. It’s a nifty little tool you can use to generate a list of fast responding mirrors near you. It’s not installed by default, but you can get it by doing:
apt-get install netselect-apt
Running this tool will create an alternate sources.list file in your home directory from where you can copy it to /etc/apt/.
netselect-apt mv /etc/apt/sources.list /etc/apt/sources.list.bak mv ~/sources.list /etc/apt/ apt-get update
Next you want to get away from using root. I recommend installing sudo and switching to a Ubuntu like way of maintaining the system, where remote access as root is disabled, as not to provide easy in for potential intruders:
apt-get install sudo adduser luke visudo
This opens vi, and lets you edit your sudoers file. Basically what you want to do is to find the line that was auto-generated for root:
Then make an identical line for yourself:
root ALL=(ALL) luke ALL=(ALL)
Now, log out and log back in as the user to make sure everything works. Once you are comfortable, you can disable remote logins for root with the following command:
sudo passwd -l root
Finally, if you are planning to use this little server in a Windows centric network, you want to set it up to see, and be seen via NetBIOS. I already blogged about how to do this, but let me repeat it here for the sake of completion.
The linchpin of the entire operation is Samba. Yes, it is big, ugly and it sucks but you need it to do anything in NetBIOS world. You will also need it if you ever want to start using PogoPlug as a NAS again. Installing Debian actually wiped out all the auto-magical network hooks that made it discoverable on a windows network so we need to restore some of that manually. So first, get samba:
sudo apt-get install samba
Once it is installed and running, edit /etc/samba/smb.conf and put following lines in somewhere in Global Settings section:
workgroup = your_workgtoup netbios name = your_hostname
Your workgroup is usually WORKGROUP or MSHOME. You can easily check it on any Windows machine by right-clicking on Computer and choosing Properties.
Once you are done, restart Samba:
sudo /etc/init.d/samba restart
As soon as it comes back up, Windows machines should be able to ping your Pogoplug using it’s hostname. You won’t be able to ping windows machines from it though. If you want to do that, you will need to install Winbind package:
sudo apt-get install winbind
Then edit your /etc/nsswitch.conf and locate this line:
hosts: files dns
Change it to this:
hosts: files dns wins
Once you do that, your PogoPlug should start recognizing NetBIOS host name.
Uses for the PogoPlug
I know that the peanut gallery will chime in soon enough with the age old question: “that’s all great Luke, but what are you going to use this machine for?” To tell you the truth, I don’t have an answer for that. I have few random ideas though:
- I an use it for the purpose it was designed for – as a NAS. I will simply attach couple of network drives, and set Samba shares on them so that Windows and Mac machines get access them from the network.
- I may install apache, forward all inbound port 80 requests to it, set up a no-ip.com account and use it as a low powered web server for some personal bullshit of mine.
- I can configure my router to listen on one of the ports that are not blocked by the firewall at work, and forward that traffic to port 22 on the PogoPlug allowing me SSH from work and work on my home network.
What would you do with it? Do you have a low-powered mini-linux server at home? What do you use it for?