Raspberry Pi first steps and basic network configuration on a Mac

Here are my first steps. And I hope you will find something useful here, while configuring your Pi...
First of all. Mine have been bought on ebay, from resellers. And were delivered a while ago. Main purpose of this purchase war to attach a headless server to my router. I have 2 external HDD's and would like to have torrents, Time Mashine fro my macs and so on. So buying a handheld computer like this would be a bargain for me.

As for built in decisions like some kinds of NAT devices and different routers with external HDD features... They are either cost a lot or lack some kinds of desired functionality. So the goal is to make some kind http/api manageable server in my local network with Time Mashine and file storage/backup. Just for fun. And to have only laptop on my work table.

SO back to the Pi. If you are buying "device only" configuration, like I did. First of all you'll need some different kind of things many computer fans usually have for backup purposes, or just in case... Those are device with HDMI port or either a TV set with AV input, e.g. SCART or Video in port. A keyboard (USB, of course) and SD card usually bigger then 2 Gigabytes.

I had this all. So I've connected my PI and tried to flash a card, having problems doing it. I'll try to cover most of them here.

1. Install a system. Usually it is a simple "burning an SD card" with Raspbian Linux distribution. To do this you need to download it from: HERE and do actions from official manual here with looking further note first.

Problem: "dd" does not work like intended, because volume is bisy.Solution: We need to unmount volume, using diskutil command with "force" flag for e.g.:sudo diskutil umount force /Volumes/my_flash_drive

You can run it afterwards using command "sudo raspi-config". Just in case you would missed something hitting Esc or similar. It will be available via ssh in future also.

Tools you will use here are similar to bios config on a PC. So to get started:

Here you need to expand rootfs (to use entire SD card space) I doubt you have original Pi Raspbian card. But you may skip this step in case you do. This will be executed on next start. So feel free to do it first thing.

Next important option is change pass and you need it no-mater what. It will change your default user's with username pi password. It is similar to user with root permissions... So be sure to do it. Note password symbols are not displayed during entry.

change timezone goes next. If you do not leave in other timezone, like I do, change it. ;) Note pi does not have an internal "bios" clock so you would need to do it. Because time is used from internet atomic clocks...

memory split is also important option that help you to manage precious pi's RAM. I've used 16 because I will not need GUI and will run "headless", using it via ssh/network services. To use GUI consider 32+ Mb or RAM for video memory. But note RAM is really in lack for most modern services. and you may need every Kb of it in future.

ssh is our main goal. To access it/configure it in future. Hit it to enable ssh connections.

and you can run update if you have already connected network somehow :).

That's it with basic config for our needs. Here goes...

3. Static network configuration.
I think this is the most important part. Because I have googled a lot to find a proper solution for my needs.

Pi is connected via dhcp IP address, usually given randomly by your router. And you need to make it static to know you will always have pi under certain network address.

You may know your Pi's ip address by entring route command into prompt. Yo will see something like this.

Here you can see your network is in range 192.168.1.x. Biut if you are configuring your Pi without actual network config, like I did, you will need to do something like this:

You need to know it from your router config. And you can simply connect it via network, if you did it properly in past. Or either connect, like you did for initial router config. You need something like this, saying about your LAN network address. I have a wired mix of different network decisions in my router. So note your typical network router address here:

Here you can know your router's DHCP address. And usually you can do it by examining your router's user manual.
Anyway this tells me that I have a wire (LAN) IP network with adress range 192.168.1.x where x is between 1 and 254. Your DHCP in router may work in another way and have different interface. So you may have other IP range set. E.g. Mine had a 100-199 range by default:

I've chosen a 192.168.1.140 IP for my PI, because I would not have 40 devices in my network and would not have any possible IP conflicts this way.

This are data required for our Pi network config. We need to manually change this in our Pi's config files.

Try to do this:

cd/etc/network
sudo nano interfaces

This will start default Pi's text editor, called "nano", pointing to networks configuration file. Here is how it might look like:

You can notice nice hotkeys here in the bottom. So I think you will be pleased with this user interface. Let's replace the line iface eth0 inet dhcp with lines.

This will create a static address for our Pi. Now to make sure we have a proper DNS. Go to editing /etc/resolv.conf. E.g. type:

sudo nano /etc/resolv.conf

Mine had a a line:

nameserver 8.8.8.8

Pointing to google's DNS. And I've left it, adding my router as a first DNS. So my resolv.conf became looking like:

nameserver 192.168.1.1
nameserver 8.8.8.8

And that's it. After doing this you would have to restart network interfaces. Or better do "sudo reboot" to make sure everything is configured. At this point you are OK to go running headless already. You can now do ssh connections to static ip at your pi.

So to use it you would need only to type in your terminal:

ssh pi@192.168.1.140

This will connect you to your pi. And you are ready to go ahead.
you may see something like this:

And to finish here is how my Pi looks like in a "printable case" The Punnet from user "E". Thanks to him.

Comments

Post a Comment

Popular posts from this blog

I have a task to generate thumbnails of uploaded PDF's. And seems like there no really solid decisions yet. Just garbage on the surface in google results. after googling for a while I found out about many ways to do so. E.g. use python stdin/out to run external command line tool. It might work for you to. But it seemed not so pythonic for me. So I have searched fo better decision. My current is for now to install ImageMagick and MagicWand binding.
Install ImageMagick.
I have used PIL a while ago to work with images. But it made me cry, before I have met sorl-thumbnails. It helped me a lot. But now I have to deal with PDF's. And ImageMagick seems like a complete decision to master it all. It has to convert pdf to my direct desirables - jpeg. So to install ImageMagick I have used brew. Like this:brew install imagemagick
However there are many other ways to do so, depending on a platform. But I strongly recommend to look at brew.

I have had a task recently. It was about adding a forms/mechanism for resetting a password in our Django based project. We have had our own registration system ongoing... It's a corporate sector project. So you can not go and register yourself. Admins (probably via LDAP sync) will register your email/login in system. So you have to go there and only set yourself a password. For security reasons you can not register. One word.

First I've tried to find standart decision. From reviewed by me were: django-registration and django password-reset. These are nice tools to install and give it a go. But I've needed a more complex decision. And the idea was that own bicycle is always better. So I've thought of django admin and that it has all the things you need to do this yourself in no time. (Actually it's django.contrib.auth part of django, but used out of the box in Admin UI) You can find views you need for this in there. they are:password_resetpassword_reset_done passwo…

Sometimes you need to disable/enable the form element like input or textarea. Jquery helps you to easily make this with setting disabled attribute to "disabled".
For e.g.://To disable $('.someElement').attr('disabled', 'disabled');

To enable disabled element you need to remove "disabled" attribute from this element or empty it's string. For e.g://To enable $('.someElement').removeAttr('disabled'); // OR you can set attr to "" $('.someElement').attr('disabled', '');

Javascript

My case was a bit different. I had to disable simple control element used without a form. <aclass="rotator"href=""onclick="return rotate(this, parameter, url)"> I made a javascript like this: /** script */ var disabled = false; function rotate(button, parameter, url) { if (disabled) returnfalse; disabled = true; /** some before post operations like making element visually dis…