Note: This post is part of a series. Each post builds on the previous ones. If you are just trying to add one thing to an existing system that was not built following this series, then I cannot promise that these instructions will work for you, although they probably will. If you’ve started from something other than a non-NOOBS Raspbian image, then you’ll probably need to adjust for that.
Please refer to the series Introduction for a list of all the different posts in the series.
Self-Promotion: I have recorded this series as a screencast for Pluralsight:
If you have a Pluralsight subscription, please consider watching it. Reading the instructions is one thing, but watching it done demystifies the whole process.
What’s a Raspberry Pi?
The Raspberry Pi (http://amzn.to/2ecP7Zi) is a Linux computer about the size of a deck of cards (Uno cards if you put it in a case), and it’s not the prettiest computer in the world. The early models didn’t even really have a “front”. Because it’s so small, there were ports sticking off every side of the board. The newer models (B+, 2B, Zero, 3) have consolidated the ports so that cables are only sticking out of one or two sides now.
The Raspberry Pi was designed as an affordable computer to teach students computer programming with. Before long, it found a following in the “maker” community for its ability to act as an affordable, low-power brain for a wide variety of electronics projects. With its low cost, power consumption, and size, it has been used for a surprisingly large number of projects.
There have been several different models for sale. The $25 Model A+ has 256 MB of RAM, and 1 USB port. The $35 Model B has 512 MB of RAM, 2 USB ports, and a built-in Ethernet port. The B+ builds on the B and while it doesn’t change any of the key attributes of the system like RAM or CPU speed, it doubles the number of USB ports to four, moves some of the connectors around into a little nicer arrangement, and uses a bit less power. There was an earlier, 256 MB version of the Model B as well, but that was completely superseded by the 512 MB version. The Raspberry Pi 2 introduced a quad-core processor to the mix, keeping the same physical layout as the B+.
Next came the Raspberry Pi Zero, which only costs $5 (Usually), but has some serious limitations in both memory, speed, and connectivity. It’s a great choice for building small projects, or for fulfilling the Raspberry Pi’s original goal of teaching children to code, but it isn’t quite suitable for building this project.
Then, the Raspberry Pi Model 3 increased the overall speed of the system, and added built-in WiFi and Bluetooth.
Finally, the Raspberry Pi Zero W added WiFi and Bluetooth to the Zero.
I built my first Raspberry Pi Home Server with a Model B. These days I would recommend at least a Model 2, but you’ll get the best results using a Model 3.
But I don’t know Linux
Yeah… that’s pretty normal. Let’s face it, Linux is not an OS you’d put in front of your grandmother or non-technical spouse. For people used to Windows or Mac machines, Linux is going to be very unfamiliar. You generally don’t get to just right-click on things and pick “Properties” to set stuff up, and when you plug in new hardware, Linux doesn’t automatically download drivers from the internet and set them up for you. The desktop environment is getting pretty nice these days, though.
For those of us that were around for the first wave of home computers in the 80’s, and remember tweaking out the settings in autoexec.bat to get the memory settings just right so that we could play a certain game, this will be like a wave of nostalgia. For the younger folks, this may seem very strange and foreign.
Linux is an enchanted land full of magic words that you have to get exactly right in order for them to work. You have to stand in the right spot, at the right time of night, under exactly the right moon, and you’d better be sure that the chicken you’re about to sacrifice is a lefty, or you’ll bring doom and destruction on all the land.
Okay, it’s not quite that bad, but if you are uncomfortable with the idea of following instructions that tell you to type an obscure string of commands and parameters with little or no explanation as to what they mean, you’ll need to get over that fear. The internet is your friend, and you can look up how to do just about anything, but there are a lot of things to configure, and people aren’t always going to tell you why something has to be phrased the way it is.
In this series, I’ll try to explain the meaning of the obscure commands as best as I can, at least the ones that I understand well enough.
What hardware do I need?
Unless you bought some kind of bundle, your Raspberry Pi will need a few accessories before you can do anything with it. The Raspberry Pi doesn’t come with a power supply, or any kind of storage. When you buy a Pi, that’s all you get. A single-board computer, and nothing else.
You’ll need to supply your own monitor, keyboard, and mouse. The monitor can be anything with an HDMI or composite video input. There are adapters available to go from HDMI to VGA if that’s all you have available, but they can be pricey. Any USB keyboard and mouse will do.
Nearly everything in this series will be done from the command line, but the current Raspbian OS boots to the desktop initially, so you’re going to need a mouse as well, but only for the initial setup, and when configuring CrashPlan later on.
The power supply can be almost any Micro-USB phone charger, although it must provide at least 700mA for 1st generation Pis, 1800mA for the Pi 2, or 2500mA for the 3. Check here for a complete table of recommendations. Since the quality of the power supply can directly affect the stability of the system, I’d recommend buying a high quality supply like the official Raspberry Pi power supply. They’re only about $12, and will save you frustration later. I have some leftover chargers from old cell phones that claim to be full 1-Amp supplies, but can’t even power the caps-lock light on my keyboard. The better your supply, the better your experience will be. Trust me, it’s worth it.
Note: In general, you should try to avoid plugging things into the Raspberry Pi while it is running. Linux is more than capable of hot-plugging peripherals, but with such a small power supply, the Raspberry Pi has tendency to “brown out” and reboot when you plug things in. Your basic flash drive is probably safe, but plugging in a game controller might power-cycle the computer. You’ve been warned.
Storage comes in the form of an SD card. The larger the card, the more stuff it will hold, so you might be tempted to get the largest card you can. As part of this series, I’ll show you how to boot the Raspberry Pi from an external hard drive, so in the long run anything over 8GB will just go to waste, and will take longer to back up. For that reason, I usually stick to an 8GB card while I do the build. Similarly, once you’re booting from the hard drive, the speed of the card won’t matter anymore, but faster cards will make some of the initial setup noticeably faster. If you’re not planning to boot from the hard drive, then feel free to go a little larger on the SD card.
Finally, you may want to buy a case of some kind. There are plenty to choose from, and there are even plans you can print out and fold up to make a case out of card paper. Many people seem to like making cases from Lego bricks as well. I’d recommend a decent protective plastic case with keyhole slots on the back so that the whole thing can be mounted somewhere when you’re finished. You could also Velcro or tie-wrap the Raspberry Pi to the side of the hard drive if you want.
What software do I need?
The Raspberry Pi has no built-in operating system of any kind. It expects to find its OS on the SD card when it powers up, so you’ll need to get an OS onto the SD card before it’s going to do anything.
Note: Older versions of these posts talked about using the Raspberry Pi Foundation’s “NOOBS” image, but that really does cause more problems than it solves when building a server, so I have removed that information. If you really want to read that stuff, then you can dig around using the Internet Archive’s Wayback Machine:
These days, I only recommend getting a plain, Raspbian image from the Raspberry Pi Foundation’s download page, and writing it directly to the card using a program like Win32 Disk Imager or HDD Raw Copy
You might also want to go get the SD Association’s “SD Formatter” tool. This will help you reclaim the unallocated space on your SD card in the event that you want to use it for something else. When you write a 4GB image to a 16GM SD card, you can’t just stick it in a Windows machine, reformat it and expect to get all the space back. Windows is going to see an SD card with a 4GB partition, and 12GB of unallocated space which it will totally ignore. When you tell Windows to format the drive, it’s just going to format the 4GB partition, and leave the other 12GB alone. SD Formatter will format the whole card and get all your space back.
You can accomplish the same effect using something like diskpart on Windows or fdisk on Linux, and you’ll need them if things go really wrong, but in most cases, SD Formatter is all you need. See the supplemental post “SD Cards Gone Bad” for more information on using diskpart to recover corrupted SD cards.
That’s it for the introduction. In the next post, we’ll start building the initial OS image, and get the machine up and running.
Hi Mel, the last link “In the next post” is broken and redirects to this post again.
Thanks for your work!
I’ll fix it up. Because I was linking to things that hadn’t been published yet, I had to use the short links, and they are totally unreadable, unfortunately. Thanks for letting me know.
If I update my OS will all of my programs that I installed through your tutorials have to be redone or will they upgrade as well? I have successfully used them all and they work like a champ including OpenVpn. I don’t know what version I am using but I started this with you in January 2015. The only one that doesn’t work is the remote desktop VNC. This is one reason I would like to upgrade the OS but not at the expense of having to reprogram the Pi.
I’ve had good luck with the upgrades so far, but make sure you take a backup first, and test all the functions after the upgrade. You can expect a couple of the applications to make you choose between your config files and newer versions from the upgrades packages. I took the updated versions and then reapplied my customizations, but keeping your existing configs will probably work just fine. If you take the new configs, then making a second card with your backup image and using a second Pi will make it easy to go back and see what your original config said. I’d probably advise just keeping your existing configs unless something complains after the upgrades.
Thanks Mel for the advice. Should I be able to use the command sudo rpi-update to get the newest OS image?
Rpi-update does the firmware, not the os. Apt-get update/upgrade is what you’re looking for. If something doesn’t work after that, try doing a dist-upgrade may be required, but.I wouldn’t start with that.
Thank you very much for making this!
I’ve ordered a 16gb sd card and a 1tb external hdd, I made some research before and I imagined it this way: install Raspbian on sd card, enable USB boot, move everything to external hdd and put the sd card into my phone.
Now I have my sd and hdd but I realised that my sd card has to be in the pi to boot so no extra storage for my phone. I have some 2gb sd cards here and there, so my question:
Can I replace the 16gb card with a 2gb (I can’t flash the system on it because it’s too small, but it would be large enough for the boot partition) or can the pi run without sd entirely from hdd somehow?
It should be theoretically possible to take just the boot partition and move it to a smaller card. If you have a Pi 3, you might also be able to boot entirely from the hard drive. There’s a blog post on the Raspberry Pi site about doing this, and it doesn’t work with all devices, but I’m doing it right now using a SanDisk Cruzer Fit flash drive. It should work with a hard drive though. I suppose it depends on the enclosure the hard drive is in more than anything. In the not-too-distant future, they’re going to enable booting over the network too. That’ll finally let me free myself of all of these SD cards I have to keep straight.
So, just for me. If you flash the Raspbian image to a 16GB MicroSD card, it will occupy 4GB. The remaining 12GB will not be usable. I would like to use my pi as a Samba server. So my goal is to have the full 16GB filled with OS and blank space that I can use to put data on for the share.
From your post above it’s not clear if it’s needed to first flash the 4GB image to the card and then use the SDE Formatter tool to make the OS partition larger so it occupies all space. Can you tell me how this is done?
Thank you again for the great tutorial 🙂
Raspbian well automatically resize the partition the first time you boot up. You’ll have the full 16th available.