In this second instalment I will go through the thought process of installing my chosen OS, Minibian, and using it to setup a Minecraft server that can easily host 2-4 people. Also the different Minecraft server options are briefly explored such as Spigot, finally close some best practices I’ve discovered.
If you haven’t seen my first post I recommend reading it here to get some context – if you’re just here for the dirty details, read on!
Download the OS
After doing some searching it quickly became apparent that to start you need to download a pre-built image of the Minibian OS. You can create your own but for our purposes a pre-built image is sufficient. The latest release can usually be found at: https://minibianpi.wordpress.com/download/
Once downloaded you’ll have a nice little file less than 512mb, but you can’t simply copy and paste it to your micro SD card. You will need to flash it properly which is much easier than it sounds – there’s a great set of tutorials on the Hypriot blog (running Docker on the Pi) for the three major OS distributions as well as a Github project to automate it for you if you just want to get going.
I highly recommend the Hypriot Flash Utility (HFU) if you have a Linux or Darwin based machine. Using the HFU you need only to take the following steps:
Open the Terminal or Command line
This can be done easily on a Mac with “Cmd + Spacebar”, typing “Terminal” and it should be the first result – some of you may be using iTerm like me if you’re a little more of a power user.
Change to a directory and download the HFU
mkdir ~/Sandbox cd ~/Sandbox git clone https://github.com/hypriot/flash.git
Usually I have a directory in my home folder called “Sandbox” alongside Music, Documents, Pictures etc. The funny squiggle “~” is known as a tilde and is a shortcut for your user directory e.g. “/Users/charlesrice” on a Mac would be mine.
One thing we may want is the progress bar whilst it’s flashing – the install instructions are on the Github project but I’ll repeat them here for simplicity.
On a Mac:
brew install pv
(You do have brew, right? If not, check the link!)
sudo apt-get install -y pv curl python-pip unzip
If you’re using a different flavour you may need to use yum instead of apt-get.
Flash the Image to your SD card
Now this is where the magic happens – normally you would have to figure out which entry is your SD card, craft the flash command and define the byte size. Not even taking into account you need to mount and unmount the drive in the process. The HFU does this all for you! So navigate to your distribution’s folder and run the flash utility, for me it’s the Darwin folder as I’m on a Mac.
Before you do, now is a good time to insert your SD card and confirm for yourself which disk is your SD card. On a Mac you would run “diskutil list” and find one with either the name of your card or where the size is approximately the same. I have a 4GB visible under “/dev/disk3”, you’ll be able to see below:
Filesystem Size Used Avail Capacity iused ifree %iused Mounted on /dev/disk1 112Gi 104Gi 8.0Gi 93% 27213399 2108327 93% / devfs 191Ki 191Ki 0Bi 100% 663 0 100% /dev map -hosts 0Bi 0Bi 0Bi 100% 0 0 100% /net map auto_home 0Bi 0Bi 0Bi 100% 0 0 100% /home /dev/disk3s1 3.7Gi 2.5Mi 3.7Gi 1% 0 0 100% /Volumes/NO NAME
Note down or remember this drive. Now, all we do is run the flash command:
charlesrice$ pwd /Users/charlesrice/Sandbox/flash charlesrice$ cd Darwin charlesrice$ ls flash charlesrice$ ./flash ~/path/to/the/minibian.img
You can explore these commands to get a better feel for what’s happening; essentially I’m checking my present working directory (pwd), changing directory (cd) into the Darwin folder and listing (ls) the files in there. Then I execute the file inside using “./” where the period means my current directory. You could also use:
Your minibian.img file may be somewhere along the lines of “~/Downloads/minibian.img” if you’ve downloaded it directly off Sourceforge. Get comfortable exploring files using the terminal, you’ll need it!
The HFU will confirm with you if the disk it thinks is your SD card is indeed the one you want to flash – I have a hunch that it looks for a drive formatted as FAT or FAT32, but haven’t checked the source code yet. Double check the drive you noted down earlier and if all looks good, type “yes” and let it do the work!
Filesystem Size Used Avail Capacity iused ifree %iused Mounted on /dev/disk1 112Gi 104Gi 8.0Gi 93% 27213399 2108327 93% / devfs 191Ki 191Ki 0Bi 100% 663 0 100% /dev map -hosts 0Bi 0Bi 0Bi 100% 0 0 100% /net map auto_home 0Bi 0Bi 0Bi 100% 0 0 100% /home /dev/disk3s1 3.7Gi 2.5Mi 3.7Gi 1% 0 0 100% /Volumes/NO NAME Is /dev/disk3 correct? y
Booting up your Pi
Once the flashing is complete we are ready to fire it up and get going. Slot in your SD card, plug in your keyboard (or use your machine and SSH in, the password is normally “root” or “raspberry”), HDMI cable and finally the power cable! In a few short moments you will see the screen fire up, some text on the screen and a little picture of the Raspberry Pi logo at the top. Eventually, you’ll see the command line like so:
This is relatively straightforward as I assume you will know about the “minecraft.jar” file. Make a folder on your new Pi and place it in there; I like to have it in /opt/minecraft for simplicity. To get Minecraft working all you need to do is install Java and then fire it up.
pi@raspberry:~ $ sudo apt-get update; sudo apt-get install oracle-java7-jdk
That’s it! All the hard work is out of the way.
In the next post I will go through my personal folder layout of Minecraft and save games, and automatically backing up your worlds on a separate USB stick.