Pi Eyed

Continued from here.

Your Pi is now sitting in the corner of the room, blinking its lights at you and presumably working.  Shall we see if we can do something with it?

3.  Setting up the interweb

Your Pi is working and sitting on the network, waiting for you.  But where is it?  You need to know its address on your network in order to log in, but it will have booted using DHCP, so its address is known only to the Pi and the router.  You need to set up your Pi with a permanent, static IP address of your choosing, as well as a gateway address (the address of the router on the LAN side) and subnet mask.  If you are a bit unsure how to select these, Appendix A might help.

We need to edit a configuration file on the SD card in order to change the settings.  Put your SD card back into your card reader.  What you do next depends on what sort of computer you are using.

If you use Linux on your PC then it’s easy enough – go into the “/etc/network” directory  in the larger partition and edit a file called “interfaces”, as shown below, with a text editor like gedit.  Do not use a word processor such as OpenOffice or LibreOffice.

The /etc/network/interfaces file looks like this:

# Used by ifup(8) and ifdown(8). See the interfaces(5) manpage or
# /usr/share/doc/ifupdown/examples for more information.
auto lo

iface lo inet loopback
iface eth0 inet dhcp

Leave the lines up to “iface eth0…” alone, change that line and add 3 new ones like this:

iface eth0 inet static
address 192.168.1.5
gateway 192.168.1.254
netmask 255.255.255.0

With “address” being the IP address you want to assign your Pi,  “gateway” your gateway and the “netmask” for your home network.  Once you have changed the text and saved the file over the top of the original, safely remove the card, put it in your Pi and reboot.

Unfortunately it’s not that easy for Windows users.  Windows can’t read the Ext3 partition the “interfaces” config file resides in.  This means we have to temporarily force the Pi to use a static IP and then edit the config file on the Pi itself.  Look in the list of files on the card (the 59MB partition) for a file called “cmdline.txt”  Open it up with a text editor – Wordpad is best, do NOT use Word or any sort of word processor.  You will see this:

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait

Make sure that line wrapping is turned off (View->Word wrap->No wrap for Wordpad) and add the text in bold at the end of the line after “rootwait” (with a space between “rootwait” and “ip=192…”:

... rootwait ip=192.168.1.5::192.168.1.254:255.255.255.0::eth0:none

That’s your desired IP for your Pi, two colons, the gateway address, one colon, the netmask, two colons, “eth0”, colon, “none”.  Make sure that the text is all on one line with a newline at the end, and save the file over the original.  Safely remove the card, put it in your Pi and start it up.  Keep following the tutorial for now.  We’ll sort your Pi out permanently once you’ve logged on and used the text editor a bit.

4.  Logging in

Like any sane computer, the Pi uses SSH to provide an external terminal (or “shell”) in which to do your work.  It is secure because it is encrypted from log in onwards – no one can sniff your password, username or anything you type during your session.  If you use Linux on your home PC then you’ve already got a SSH client, but if you are unlucky enough to be using Windows, you’ll need to download PuTTY from here.  Start PuTTY up and enter the IP address you picked where it says “Host name (or IP address)” and click “Open”.  Linux users, start a shell and type ssh -l pi 192.168.1.5 (replace the 192… with your Pi’s IP address).  The username is “pi” and the password for it is “raspberry”.  You should see this:

Linux raspberrypi 3.1.9+ #168 PREEMPT Sat Jul 14 18:56:31 BST 2012 armv6l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.

Type 'startx' to launch a graphical session

NOTICE: the software on this Raspberry Pi has not been fully configured. Please run 'sudo raspi-config'

pi@raspberrypi:~$

Hooray!  You are logged in and the world is your lobster.  From now on we’ll be typing commands to do things.  Whenever you see the line that says “pi@raspberrypi:~$” (or a variant of it), it means the Pi is waiting for you to type something in.

5.  Initial configuring

You see that bit where it says “NOTICE: the software on this Raspberry Pi has not been fully configured. Please run ‘sudo raspi-config'”?  That’s sound advice.  Type sudo raspi-config or copy and paste the words from the login text.

ââââââââââ⤠Raspberry Pi Software Configuration Tool (raspi-config) ââââââââââââ Setup Options                                                                â
â                                                                              â
â    1 Expand Filesystem              Ensures that all of the SD card s        â
â    2 Change User Password           Change password for the default u        â
â    3 Enable Boot to Desktop         Choose whether to boot into a des        â
â    4 Internationalisation Options   Set up language and regional sett        â
â    5 Enable Camera                  Enable this Pi to work with the R        â
â    6 Add to Rastrack                Add this Pi to the online Raspber        â
â    7 Overclock                      Configure overclocking for your P        â
â    8 Advanced Options               Configure advanced settings              â
â    9 About raspi-config             Information about this configurat        â
â                                                                              â
â                                                                              â
â                     <Select>                     <Finish>                    â
â                                                                              â
ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ

You will see a menu pop up with loads of options.  Move the highlighted line with the up/down arrow keys and hit return to select an option.  The options in “<>”s are selectable with the tab button, so tabbing twice would take you to the “Finish” option, where you hit return to do it.

  • If your SD card is larger than 2GB then choose option 1 – “Expand Filesystem”.  This will allow you to use all the card’s memory rather than just 2GB of it.
  • Don’t bother with 2 – “Change user password”.  We’ll be getting rid of the user in a minute anyway.
  • Don’t do 3 – “Boot to desktop” either.  We are being macho and using the command line only.
  • Select 4 – “Internationalisation Options” to go to the options page to set the timezone and “locale” (which sets various preferences like number format, date-time format) to your country.  “Timezone” is fairly straightforward, but “locale” is less so.  It offers you a list of baffling lines of text, which is comprised of  language_territory.codeset with abbreviations for “language” and “territory”.  If you are in the UK then “en_GB.UTF-8 UTF-8” is the one you want.  When you find the one you want, hit the space bar to star it and then tab a couple of times to the “OK” button.
  • 7 – Overclock: This setting allows you to speed up your pi by tweaking the clock speed and voltage of the CPU.  Higher values mean your Pi runs faster, but too high a value could make it unstable.  Experiment a bit with it and if you find you have problems, lower the settings until it’s happy.

There are a couple of things in 8 – “Advanced options” that we need to do, so select it and choose:

  • A3 – “Memory Split”: RAM on the Pi is split between the CPU and graphics chip (GPU).  As it’s not plugged into the TV you don’t need graphics.  Choose this option and enter a number for how much memory the GPU should have.  The number to use is 16, which is the minimum memory you can assign for the GPU.
  • A4 – “SSH”: Make sure that this is set to “Enable”.  Otherwise you won’t be able to log in again.

Once you’ve finished with the config program, press Tab twice to highlight “Finish” and hit return.  You can reboot your Pi when prompted or drop back to the command line (“pi@raspberrypi ~ $”) and type sudo reboot to do it manually.  Leave it for a couple of minutes and then log in again (pi/raspberry).  As a quick check to see if your Pi is now using the whole SD card, type df -h

naich@raspberrypi ~ $ df -h
Filesystem      Size  Used Avail Use% Mounted on
rootfs          3.6G  3.4G   72M  98% /
/dev/root       3.6G  3.4G   72M  98% /
tmpfs            22M  208K   22M   1% /run
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs            44M     0   44M   0% /tmp
tmpfs            10M     0   10M   0% /dev
tmpfs            44M     0   44M   0% /run/shm
/dev/mmcblk0p1   56M   34M   23M  61% /boot
naich@raspberrypi ~ $

Look at the line that starts “rootfs”.  The “Size” column should report something close to the size of your card – in this case it’s a 4GB card.  If it still says it’s under 2GB then the resizing didn’t work.  You could try resizing it with the configuration program again (sudo raspi-config) or use this tutorial.

If you are familiar with Linux on the command line you can stop reading my wibblings now.  You have, for all intents and purposes, installed Debian Wheezy on your Pi.  Go forth and do with it what you will.  The rest of you can read on while we do some basic maintenance and then add some USB storage, install a Bittorrent client to download your perfectly legal torrents and a uPNP Media Server to watch them on your TV, PS3 or whatever.

Continued here…

Yummy Pi – what to do with a Raspberry Pi

So you’ve got your Raspberry Pi and it’s sitting there, staring at you PCB-ily while you are wondering why you ordered it in the first place.  If you don’t know what to do with your Raspberry Pi, don’t bother plugging it into your TV, booting it up and clicking despondently at a few things before chucking it in the loft.  Use it for something useful and learn a bit about Linux at the same time.  Don’t tie up the TV with your Pi, use it on your home network as your faithful assistant – always on and connected to the internet, ready to do whatever you want at any time.  Use it headless (no monitor, keyboard or mouse) and install a whole load of useful stuff on it: a Bittorrent client, media streamer, network-attached-storage or any of these ideas.  You have a PC that is more powerful than the best computer you could buy 10 years ago and it uses less power than a low power light bulb.  It would be a crime not to use it for something.

A Raspberry Pi in a snazzy Lego case

These series of posts are aimed at someone who knows a bit about computers (above the level of randomly clicking at things in a blind panic, but below reprogramming the BIOS with a 9 volt battery and a hair clip) but not much (or indeed anything at all) about Linux.  You will learn to use your Pi at a fairly intimate level, gently stroking its settings by typing in commands and editing files.  This is not pointing and clicking, as you do with Windows, Macs or Linux distributions like Ubuntu, but typing stuff in is not difficult and it makes you feel like a hardcore hacker.  Embrace your inner geek and learn to love your Pi.

1.  Plugging it in

If you want to, you can plug your Raspberry Pi into your TV, stuff a mouse and keyboard up its USB ports and use its (quite slow by all accounts) GUI, but I don’t do these sorts of shenanigans.  I have a simpler setup where it’s just plugged into the network and accessed remotely, with no keyboard, mouse or anything.  To run it this way, you need three things: a power supply, an SD memory card and a bog standard CAT5 network cable.  Don’t panic if you are running your home network wirelessly – your router will have sockets on it for plugging in network cables.  You won’t need physical access to your Pi after the initial set up, so you can leave it next to your router – in the cupboard, under the sofa, or wherever your router lives.

To power it up, you need a 5V power supply that can provide at least 700mA with a mini-USB connector on the lead.  Have a look in that collection of phone chargers you’ve got rattling around in your crap drawer.  Jen’s Samsung charger worked a treat.  Failing that you can buy one for less than a fiver from Amazon – something like a Nokia AC-10x charger..

2.  Booting it up

You need a SD card of at least 2GB, but 4GB is better if you want to install anything.  There isn’t really an upper limit, so 16, 32 or 64GB cards should work, with faster (class 10) cards giving you a faster system overall.  It used to be the case that some cards worked better than others but later firmware versions fixed the problems that some Pis had with faster cards.  If you find that your Pi is not booting, it is worth trying a different type of card just in case.

There is no software built into the Pi, so it boots and runs off the SD card as if it were a hard drive.  That means you need to install all the software it needs on the card before you plug it into the Pi.  This page shows you how to do it. using a disk image that you copy onto the card using a card reader and software on your PC.  Here is where you download the image fileto copy to the card.  Download Raspbian “wheezy”, which is basically Debian optimised for the Pi.

If you have just finished installing the image, unplug the card from the reader now.  Plug the card back into your card reader and a window with a 59MB partition in it should pop up on your PC.  This contains the files that boot the Pi. If you are using Linux, you will also see a 1.9GB partition in another window – this contains the the rest of the files for the Raspbian system.  Because Windows can’t recognise the type of filesystem (EXT3),  Windows users can’t see this partition, but don’t worry about that.  You might be wondering what has happened to the rest of your SD card – you can only see about 2GB of it.  The file system can be adjusted to use the rest of the card’s memory once the Pi is up and running.

Now safely remove the card, lob it in your Pi, plug it into your router with the CAT5 cable and plug in the power supply.  If it’s all OK, the red LED should come on for a few seconds followed by the other ones, with the green one flashing occasionally.  The LEDs are stupidly bright.  Congratulations!  Your Raspberry Pi is now ready for use.  If only the red light is on then something is wrong.  If you have followed all the instructions and have the correct partitions and files on it, then it is probably the card itself which is the problem.  Try a different card and see if that fixes it.

Continued here…

And another thing…

Sorry, you’ve got me started on the Vectra now. The Vectra’s central locking has 2 “features” I’ve not seen on other cars – one press of the remote unlocks the driver’s door and you need another press to unlock the rest of the doors and the boot and filler cap. The reason for this is … absolutely no idea. It’s like it was put in just to piss me off. 95% of the time I have to press it twice and there’s no actual benefit that I can think of in only unlocking one door. Maybe they think that I occasionally want to lock out the wife and kids and go scooting off on my own? Actually… nah, let’s not continue that line of thought.

The other feature is that if you don’t open the drivers door within 30 seconds of unlocking, it locks all the doors again. I can’t count the number of times when this has been useful because I’ve accidentally unlocked the driver’s door. I can’t count them because it’s 0. This has never happened with any car I’ve ever owned. I unlock the door because I want to get in, not on a passing whim or because I like pressing buttons. Any usefulness of this feature in the remote possibility that I might lose my mind and accidentally unlock the doors for no reason, is somewhat outweighed by the number of very real occurrences when I’ve unlocked the doors, been momentarily distracted by children and found myself and my family locked out again.

Now, put these two features together and you get me, attempting to fill up the car and finding the petrol flap is jammed shut. After a few minutes of trying to pry it open I remember that I went out on my own, so I single clicked to unlock the car and only the driver’s door is unlocked. The flap was secure, and thank god it was – a petrol thief might have been passing while I was getting in, looking to empty my tank in the few seconds before I drove off down the road. So I lock the car up again and double unlock to get the flap open, I fill up (75 QUID!!!) and – buggery arseholes, the poxy thing has jammed open now. It’s banging against the lock and won’t close. A few more minutes of thumping and swearing and I remember that since I only locked and unlocked the doors to open the sodding petrol flap, the car has noticed that I didn’t open the driver’s door and has vigilantly locked itself up again, with the petrol flap open. Sure enough I have to unlock it (double sodding click) again in order to close it.

Thank you Vauxhall, for making my life so much easier with your little helpful details. Sorry, I’m going on again aren’t I?

I’m so popular!

"We must invite Naich. He's so fucking sophisiticated."

Gosh, where do I start.  There are so many people want me to join their exclusive circles.  I had a letter from the Vice Chancellor of Cambridge University (or “Vicey”, as I call him), asking me – actually more like begging me to join him for a swanky reception with canapes and vino.  He used the excuse that it was for my 25 years service working at the uni, but come off it – who wouldn’t want the company of a badly dressed, slightly brain damaged electronics technician, staggering around guzzling wine and belching pastry fumes?

But even more exciting was my email invitation to join the Freemason Illuminati.  I didn’t even realise there was one until I got their mail!  They obviously like the cut of my gib and I was just thinking it was about time I heard from the shadowy evil secret rulers of the world.  If anyone would like any favours once I’ve joined the select elite, let me know.  This is what they sent.  It all seems totally legit.

Date: Sat, 17 Mar 2012 09:30:03 +1200
From: freemason illuminati <noreply@freemason.org>
Reply-To: order@illuminati.umail.net
To: yourorder@fi.org
Subject: we call

You are receiving this mail in regards of the freemason confraternity  of the
whole wide world (FCWWW).

You are moving well in what you are doing but in order to make it easier for
you, we have concluded for you to be a part of us as a member to sign your
life to us and have any thing you need.

Be it any thing in the whole wide world.

You can’t refuse us now for it’s too late.

Get back to us now for your Illuminati membership Order and also for you to
know more about the ancient ILLUMINATI FORUM and also the Orientation and
goals that we pursue.

Get back to acquire your goal now.

I can’t wait to set up some sort of super-villain style base on a Caribbean island.  I’ll need some sidekicks if anyone is interested.  You’ll have to improvise with the sinister weapons until I get set up properly.  I’ll see if I can get some sort of poisoned dart cigarette holder made up, or maybe a miniature gun in a mobile phone, but in the meantime you could use a brick in a sock to bludgeon people to death.

Cat 0 : Linux 1

I went to do some stuff on my PC the other day to find that the cat had been sleeping with her paw on the “Print Screen” button. This button starts up a program that takes a screenshot and brings up a window asking where you want to save it.

Holding down a key keeps repeating the keypress, so as long as the key is held down it’ll keep starting up new copies of the program, again and again and again, as fast as it can.   It is the PC equivalent of sitting stationary in your car with your foot firmly pressed down on the accelerator. The cat had been sitting like that for quite a long time.  Everything had ground to a halt and the status bar was just 1 pixel wide grey stripes. There was a black box on the screen where the last “take a screenshot” window had popped up but the poor PC didn’t have enough CPU left to actually fill it with anything.

The mouse was barely moving so there was no hope of actually using it to close the windows. It was time to use Geek powers and drop to the command line. I hit CTRL-ALT-F2 and waited for a while. Several seconds later the terminal came up and although it took a few seconds for each keypress to register, after a couple of minutes I was actually able to log in. An incantation of “ps -ef |wc -l” showed there were 3,600 processes running. Each screenshot capture takes 3 processes, so there were 1,200 screenshot programs running simultaneously. I gave it some Linux magic – “killall gnome-screenshot” and everything instantly sped up. I did some more killing and everything went back to normal – in fact there were no ill effects whatsoever and the computer worked fine for the rest of the day, with no need for a reboot or anything.

Jimbo once started up 140 text editors which barely slowed the PC down and Luna couldn’t kill it with 1,200 screenshot programs. Linux – impervious to cats and kids.

Update: It’s been pointed out that I should have used “pkill” rather than “killall”.  Killalling, while relatively harmless on a Linux box – a bit like trimming a dog’s claws, is the Unix equivalent of taking it out back and shooting it in the head with a rocket propelled grenade.

A new plan

I want to discover a fundamental force of nature. What I’ll do is give it the unit of a “manilli”. Everyone will wonder why until they realise what 1/1000th of a manilli is. Then they will get that awful tune stuck in their head and hate me.

It’s a bit quiet isn’t it?

I’ve not had much to say for myself recently.  Obviously I’ve had no interesting thoughts since June, and then it was about getting bits of metal out of a skip.  What a life I must lead.

Highlights since the last blog entry:

  • Fixed the brakes on my bike
  • Fixed the washing line
  • Poisoned two rats
  • Pumped up the car’s tyres
  • Went bungee jumping in Wales, fell 200 feet before the rope snapped, crashed head-first into an underground cavern where I discovered that Keith Harris was plotting to use a nuclear arsenal to overthrow the world’s governments and install Orville the Duck as Supreme Overlord of the Earth, beat him up with my bare hands, pulled Orville’s stuffing out and disarmed 24 nuclear bombs using nothing but my knowledge of Portable Appliance Testing and an elastic band the postman had dropped outside the front door
  • Mowed the lawn
  • Bought a long handled spoon

I made one of those up, by the way.

The enchanted skip

And lo! did Naich go rummaging in the Cav. skips in search of a bit of metal that would hold his reservoir securely in his chiller box.  Praying to Ceilliau Blewog, the goddess of salvage, he dived head first into the metals skip.  And in her wisdom Ceilliau Blewog did deliver unto his hand the perfect bit of metal, complete with holes already drilled in it.  And there was much rejoicing.  And Naich did praise Ceilliau Blewog and promise to offer up a sacrifice of a small annoying cat on his return home.

Not funny

Have a look at this story – http://www.bbc.co.uk/news/education-12449643 Headline: “Million children ‘severely maltreated’, says NSPCC”.

Holy shit! “One in four people in the UK, aged between 18 and 24, claims to have experienced severe violence, sexual abuse or neglect as a child, says the children’s charity the NSPCC.”

Then you read the article and find out that the study which was about rape, attempted rape and physical abuse “also included ‘serious emotional neglect or lack of physical care or supervision’, which it defined as including ‘parents never or hardly ever asking their child who they were going out with or where or what they were doing’.”

Ah. That’s bad, but it’s not in the same league as rape or physical assault.

“This category also included children reporting that ‘the child’s family never let the child know they cared about them’.”

Again, not good but putting it in the same category as rape and physical assault? But maybe I’m cynical and it’s not the case that the vast majority of abuse was in this far lower category that just happened to be lumped into the ones that grab headlines? Let’s take a look at the report and see the actual numbers. Ah. The “report” seems to be mainly pictures of sad looking children, quotes of horrendous abuse and NSPCC logos. Not many numbers to work with.

This is why I don’t give money to the NSPCC – they use dodgy data to lobby and further their own cause. They use tabloid tactics to mislead people into a think-of-the-children panic based on scary headlines.

Every time I see bullshit like this it reminds me why I donate to Barnardos instead.

A cunning plan

Here’s how to get rich.

1.  Hire an empty shop for a couple of weeks.

2.  Find a sofa/bed/whatever shop that is doing one of these “if you can find it cheaper, we’ll give you double the difference” deals.

3.  Buy a sofa/bed/whatever from the shop.

4.  Sell  it in your shop at 1/2 the price you bought it for.

5.  Go back to the sofa/bed/whatever shop and demand double the difference, citing the prices at your shop.

6.  Go back to step 3, using the money they just gave you.  Keep doing this until you have all their stock in your shop.

Congratulations!  You now have a fully stocked shop for the price of one sofa/bed/whatever.  Everyone will buy from your shop because that other one is twice the price and never has anything in stock.