Guess what? My Raspberry Pi SD card got corrupted yesterday :(
I was faced with 2 options: Buy a new card with the Raspbian Wheezy operating system loaded; or re-build my own card.
So I decided to re-build my own.
The first step was to get an image of the most up to date copy of Raspbian onto my Windows netbook using this guide.
I then made a copy of the corrupted disk on my netbook because some of the files might stiil be useful (As it turned out, they was very useful).
Then I needed to download Win32DiskImager so that I could copy the image onto my SD card. The above guide explained all that too.
When I plugged the card back in the RPi and powered up, I got nothing on the PC monitor. So I copied over the config file from my copy of the original corrupted card. I found that it had all the settings I'd pieced together over the last few weeks! This saved me loads of time and got the PC monitor going.
Thankfully, my own blog helped me re-build my web server but I'd lost most of my prototype website. Bummer.
Of course, the way to avoid this kind of thing is to take regular back-ups of the SD card using Win32DiskImager or like this. Then, all you have to do, is copy your most recent back-up image onto the card. Simples.
Raspberry Pi From Scratch
Diary of a Newbie
Saturday, 15 June 2013
Monday, 20 May 2013
Creating A Website On the Pi
I've been spending a bit of time learning some of the skills needed to create a website.
A bit of research told me that I needed to know "basic" HTML and CSS to begin with. Then, when I'd got familiar with those, I could make my site more dynamic using Javascript and PHP.
I'm using the HTML Dog tutorials to get me up to speed on HTML, CSS, and Javascript. They're excellent. They come in bite-size chunks, get straight to the point, giving you all the skills you need, and they even have a sense of humour.
So far, I've done the basic and intermediate levels for both HTML and CSS and found it a pretty quick and painless process. Off the back of this, I can now put together a convincing looking website, complete with images, links, navigation bars, headers and footers.
I used a fake family news site as a prototype to practise the skills I'd learnt. The idea worked well - Forcing me to work through a number of problems that wouldn't have occured to me otherwise.
The starting place for your web pages is the index.html file in the /var/www folder. Apparently that file's more or less the standard place for most websites.
I found a really useful program for my web deveopment work called puTTY. It allows you to connect to your Pi remotely from a Windows PC. For example, I can connect to the Pi from my netbook, login, then edit the web pages. I can even copy & paste stuff from my netbook to the Pi using my right mouse button. More about puTTY here.
If you want to develop your web code on a PC then move it across to the Pi, use WinSCP (See here). By the way, you can't copy files directly to /var/www unless you change the ownership of this folder using: sudo chown -R pi /var/www
A bit of research told me that I needed to know "basic" HTML and CSS to begin with. Then, when I'd got familiar with those, I could make my site more dynamic using Javascript and PHP.
I'm using the HTML Dog tutorials to get me up to speed on HTML, CSS, and Javascript. They're excellent. They come in bite-size chunks, get straight to the point, giving you all the skills you need, and they even have a sense of humour.
So far, I've done the basic and intermediate levels for both HTML and CSS and found it a pretty quick and painless process. Off the back of this, I can now put together a convincing looking website, complete with images, links, navigation bars, headers and footers.
I used a fake family news site as a prototype to practise the skills I'd learnt. The idea worked well - Forcing me to work through a number of problems that wouldn't have occured to me otherwise.
The starting place for your web pages is the index.html file in the /var/www folder. Apparently that file's more or less the standard place for most websites.
I found a really useful program for my web deveopment work called puTTY. It allows you to connect to your Pi remotely from a Windows PC. For example, I can connect to the Pi from my netbook, login, then edit the web pages. I can even copy & paste stuff from my netbook to the Pi using my right mouse button. More about puTTY here.
If you want to develop your web code on a PC then move it across to the Pi, use WinSCP (See here). By the way, you can't copy files directly to /var/www unless you change the ownership of this folder using: sudo chown -R pi /var/www
Wednesday, 24 April 2013
Setting Up A Web Server
![]() |
| Look, it's a web server! |
In the end, I realised this web-page was bit of overkill for what I wanted. So I just gave that a read for background purposes, and went with the explanation in the Raspberry Pi User Guide by Eben Upton & Gareth Halfacre.
LAMP
Firstly, I logged on and installed what's called a 'Lamp Stack'. Lamp stands for Linux, Apache, MySql, and PHP. Linux obviously provides the operating system and is already installed; Apache is the web server; MySQL is the database handler; and PHP is the language that gives life to your web-site.[In fact, xAMP stacks are apparently behind the majority of servers. There are also WAMPs which have Windows instead of Linux, and MAMPs that have the Mac OS]
I installed the LAMP using the following commands:
- sudo apt-get update
- sudo apt-get install apache2 php5 php5-mysql mysql-server
Along the way, MySQL asked me to set a password, then confirm it. I made sure it was secure i.e. Not easy to work out by visitors to my site.
Once the installation had completed, the MySQL and Apache servers were running.
Final Checks
To check that the server was up, I got my netbook out (which is part of my home network connected via a router) and typed the Pi's IP address into a web browser (I got the IP address using the 'ifconfig' command and found it listed in the 'eth0' section).This displayed the default web page. Nearly done.
Finally, I had to confirm PHP was working, so, still following the guidance in above manual, I used the following command to create a test script:
sudo sh -c 'echo "<?php phpinfo(); ?>" > /var/www/phptest.php'
This new file asks PHP to provide an information page when called. And I did that through the netbook again, tacking /phptest.php onto the end of the ip address.
This also worked. Job done!
Final Note
From this point on, every time I switch on the Pi, it becomes a local web server. I don't even have to log in for this to happen.Friday, 19 April 2013
Next Steps With The Pi
Having read through my Raspberry Pi Users Guide, I've decided that my next step will be to set-up a web server to host a small website.
My reasons are basically: I've never done it before; I'll be able to learn and practise stuff HTML, CSS, Javascript, and PHP to build the website. Which could be useful in my current job.
I'll be using advise from that Users Guide I mentioned and this site to build my server.
I'll tell you how that goes soon.
My reasons are basically: I've never done it before; I'll be able to learn and practise stuff HTML, CSS, Javascript, and PHP to build the website. Which could be useful in my current job.
I'll be using advise from that Users Guide I mentioned and this site to build my server.
I'll tell you how that goes soon.
Saturday, 13 April 2013
USB Hubs
So, here's the thing: Not all USB hubs work with the Raspberry Pi.
Hard to believe isn't it? You just take it for granted that you can just plug these into any computer and they just work.
I got my first clue when I looked at the packaging for some of these hubs. Just about all of them say they're compatible with Windows or MacOS. No mention of Linux or anything Pi related.
So I got on-line and did a quick search. Sure enough I found this page. It lists known compatible and incompatible hubs. It's not an exhaustive list (how could it be?) but it's a start and gives you idea what to look out for.
I took the easy option, I just bought from a site that specialises in Pi accessories. I went for a CIT-UH207P-01-HUB, USB 2.0 7 Port (Not the one pictured above).
The reason I went for it was that it has 7 ports (plenty of room for expansion....but probably over the top), and it's got it's own power supply. That's important because the Pi's not up to powering a bucket-load of usb peripherals.
In fact, I've gone a step further and bought a USB A Male to Micro B Male lead so that the hub can power the Pi. That would save me a power socket. Let's hope it works!
Update: Nope, the CIT hub isn't beast enough to power the Pi. If I were to do this again, I'd go for the D-Link Dub-H7 7 Port USB 2.0 Hub. Now that will do the job properly.
Hard to believe isn't it? You just take it for granted that you can just plug these into any computer and they just work.
I got my first clue when I looked at the packaging for some of these hubs. Just about all of them say they're compatible with Windows or MacOS. No mention of Linux or anything Pi related.
So I got on-line and did a quick search. Sure enough I found this page. It lists known compatible and incompatible hubs. It's not an exhaustive list (how could it be?) but it's a start and gives you idea what to look out for.
I took the easy option, I just bought from a site that specialises in Pi accessories. I went for a CIT-UH207P-01-HUB, USB 2.0 7 Port (Not the one pictured above).
The reason I went for it was that it has 7 ports (plenty of room for expansion....but probably over the top), and it's got it's own power supply. That's important because the Pi's not up to powering a bucket-load of usb peripherals.
In fact, I've gone a step further and bought a USB A Male to Micro B Male lead so that the hub can power the Pi. That would save me a power socket. Let's hope it works!
Update: Nope, the CIT hub isn't beast enough to power the Pi. If I were to do this again, I'd go for the D-Link Dub-H7 7 Port USB 2.0 Hub. Now that will do the job properly.
Friday, 5 April 2013
VGA Monitors, Sound, And More Speed (Take 2)
It's taken me a while to get round to trying out the suggestions from my previous post but I've finally had success. Not without a struggle though.....
So I changed the config.txt file on the SD card (using the SD card reader on my netbook) to say:
hdmi_safe=1
This command sets the Pi to low resolution output and should always give you a picture.
When I re-booted, it worked. Now all I had to do was figure out how to get a higher resolution (Giant icons on your desktop is not a good look!).
I just had to match up the monitor's best resolution with the table given here, and change the config.txt file accordingly.
The settings that did the trick on my monitor were:
hdmi_drive=2
hdmi_group=2
hdmi_mode=83
hdmi_force_hotplug=1
disable_overscan=0
However, it took the best part of an evening to discover that each command needs to be on a separate line otherwise it doesn't work!
Anyway, hdmi_drive=2 means that the voltage output is for HDMI (1=DVI voltages).
hdmi_group=2 means I'm using a monitor (1=An HDMI TV).
hdmi_mode=83 is connected with the hdmi_group, 83 means I want 1600 x 900 resolution (See the table I mentioned above).
hdmi_force_hotplug=1 forces the Pi to use the HDMI port even if it can't detect a monitor.
disable_overscan=0 No idea why it works but it does.
However, the makers have now come up with a setting that speeds things up without killing your Pi or invalidating the warranty.
The way to set it is to login then use
sudo raspi-config
Now look for the overclocking option and work your way to this menu:
Select the Turbo preset.
Nightmare! I expected to just plug my headphones into the audio socket and get sound but it's not that simple.
In the end, I had to work through this entire link to get my audio set-up, including a full system update. Another couple of evenings blown. Why on earth should it be so difficult?! I get the impression the Pi is designed around connecting to an HDMI device and anything else is an afterthought.
Oh well, it's done now. I can finally get on with using it. I think I'll read through the Raspberry Pi User Guide to see what I'm going to have a go at next.
VGA Monitors
The problem I had when I switched from an HDMI TV to a monitor as a screen was that I was getting no picture.So I changed the config.txt file on the SD card (using the SD card reader on my netbook) to say:
hdmi_safe=1
This command sets the Pi to low resolution output and should always give you a picture.
When I re-booted, it worked. Now all I had to do was figure out how to get a higher resolution (Giant icons on your desktop is not a good look!).
I just had to match up the monitor's best resolution with the table given here, and change the config.txt file accordingly.
The settings that did the trick on my monitor were:
hdmi_drive=2
hdmi_group=2
hdmi_mode=83
hdmi_force_hotplug=1
disable_overscan=0
However, it took the best part of an evening to discover that each command needs to be on a separate line otherwise it doesn't work!
Anyway, hdmi_drive=2 means that the voltage output is for HDMI (1=DVI voltages).
hdmi_group=2 means I'm using a monitor (1=An HDMI TV).
hdmi_mode=83 is connected with the hdmi_group, 83 means I want 1600 x 900 resolution (See the table I mentioned above).
hdmi_force_hotplug=1 forces the Pi to use the HDMI port even if it can't detect a monitor.
disable_overscan=0 No idea why it works but it does.
More Speed
When I first got the Pi going on an HDMI tv, I noticed that some of the games were painfully slow. Apparently this is a common problem. The solution most people go for is so-called 'over-clocking' which boosts the CPU's clock frequency. However, the makers warn against this as it shortens the life of your Pi. For this reason it invalidates the warranty.However, the makers have now come up with a setting that speeds things up without killing your Pi or invalidating the warranty.
The way to set it is to login then use
sudo raspi-config
Now look for the overclocking option and work your way to this menu:
Select the Turbo preset.
Sound
Nightmare! I expected to just plug my headphones into the audio socket and get sound but it's not that simple.
In the end, I had to work through this entire link to get my audio set-up, including a full system update. Another couple of evenings blown. Why on earth should it be so difficult?! I get the impression the Pi is designed around connecting to an HDMI device and anything else is an afterthought.
Oh well, it's done now. I can finally get on with using it. I think I'll read through the Raspberry Pi User Guide to see what I'm going to have a go at next.
Friday, 8 March 2013
VGA Monitors, Sound, And More Speed (Take 1)
So the idea here was that, having got the Pi running using a TV, I would now make the move to a PC monitor which is in a more convenient position. However......I'm getting nothing from the monitor.
The problem seems to be with this HDMI to VGA cable adapter I needed to convert the HDMI to a standard VGA monitor.
Apparently you need to fiddle with the Pi's config.txt file to get a picture. Here's a helpful comment from 'GeekDad' on Amazon:
"I got this to go with my son's Raspberry Pi. At first it didn't seem to work, but after some googling managed to get it to work by editing the /boot/config.txt file on the SD card. First try with the hdmi_safe=1 option, which should give low-res (VGA) output when booted. If that works it is a matter of turning off safe mode and finding the settings that work for you. I tried:
disable_overscan=0
hdmi_drive=2
config_hdmi_boost=4
this worked after a reboot and gave full resolution on my old Samsung SyncMaster 172v. Haven't checked if all these options are needed.
So the product works with the Pi but you may need to experiment a bit to get it to work with your monitor."
Ah well. I shall report back soon hopefully.
The problem seems to be with this HDMI to VGA cable adapter I needed to convert the HDMI to a standard VGA monitor.
Apparently you need to fiddle with the Pi's config.txt file to get a picture. Here's a helpful comment from 'GeekDad' on Amazon:
"I got this to go with my son's Raspberry Pi. At first it didn't seem to work, but after some googling managed to get it to work by editing the /boot/config.txt file on the SD card. First try with the hdmi_safe=1 option, which should give low-res (VGA) output when booted. If that works it is a matter of turning off safe mode and finding the settings that work for you. I tried:
disable_overscan=0
hdmi_drive=2
config_hdmi_boost=4
this worked after a reboot and gave full resolution on my old Samsung SyncMaster 172v. Haven't checked if all these options are needed.
So the product works with the Pi but you may need to experiment a bit to get it to work with your monitor."
Ah well. I shall report back soon hopefully.
Subscribe to:
Comments (Atom)





