I’ve read many articles about serious use of the Raspberry Pi and I’m now convinced that there is very little chance of mounting a Pi in a cupboard with MSQL and other write-intense programs – and expecting it seriously to last for a year or 3 because of the limited writes you can do to SD memory – that includes the ones that have wear-levelling.
With that in mind I’ve just strapped a hard drive to the Pi2. You cannot (it would seem) BOOT off the hard drive but you can put your entire file system onto there.
There are many, many ways to do this but as is often the case, Adafruit have a simple way.
Make sure you back up your SD before starting any of this in case it all goes to pot.
So in total:
I found a lead that has 2 usb and one mini-usb plugs – so that you can plug the drive into a power AND into the Pi – I did this because the Pi will not power a hard drive – just not quite enough juice available. I plugged everything in and made sure the drive was whirring.
I followed the instructions on the above line from just under half way down below “If you’re using a stock Raspbian install”. I grabbed their helper. As I tried to follow the next instruction it went off to the internet for an update but proceeded automatically from that point on.
This helper program not only formats the external drive – but also uploads all your material from the Pi onto the external driver AND changes the file that determined on boot where to get materials from.
The instructions said “this will take a long time” – it took around 5 minutes as I wrote this blog. At the end of it I noted “your new root drive is accessible under /mnt. In order to restart with this drive at /, please type: sudo reboot”.
With a slightly elevated heart rate, after all this really WAS too simple…. I followed the instructions.
Well, much to my HORROR – tests showed that although there was indeed a new drive, I was not using it. I found 2 www. directories (one on the SD, one on the drive) and modified the one attached to the hard drive. a quick run of the default web page (in the process of installing webmin you end up with a LAMP installation and hence a web server) showed that I was NOT running on the hard drive.
So – I went looking into /boot/cmdline.txt – which is the file that tells Pi where to use for the root directory. It had INDEED been updated from:
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p6 rootfstype=ext4 elevator=deadline rootwait
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
All very nice but not what I wanted – it should be pointing to the external drive. Could it be a simple as changing that bold text to /sda1 ??
YES was the happy answer.. I updated the file and checked the web page and sure enough I was now looking at the updated version!!
And now, to back up that hard drive before I go any further!!
Or maybe a trip out with my good lady for a beer… (which is what actually happened…)