My scripts have been running pretty well these last few weeks. I added some error checking in case something does go wrong. But overall they have been humming along nicely. Time to move on to the next project, which is transitioning my station computer over to one of my Raspberry Pi microcomputers. In case some of you aren’t familiar with the Raspberry Pi, it is a small, single board microcomputer that was originally designed as an educational device. While it serves that purpose well, its’ low price allowed it to be used by hobbyists for many other purposes. For more information on the Raspberry Pi you can browse to raspberrypi.org to get more information on the board.
The Raspberry Pi is similar in many ways to the GuruPlug computer I had used previously as my weather station computer. That computer, as well as the Pi uses an SD card as its’ primary storage device. So the operating system and any files it needs are all located on a storage device rather than a traditional hard drive. While the access speeds are fairly fast compared to a hard drive, the SD card has limited storage and a finite number of write cycles. This isn’t a big problem for many uses, but my weather station software writes to the file system fairly often. And since I keep a database with my weather data the limited storage could eventually become a problem.
I had a spare external hard drive with a USB interface I could use to add storage to the Pi. Utilizing this drive would permit the weather station software to write to a hard drive and avoid wearing out the SD card so quickly. It also had plenty of storage if I wanted a database to store the weather data. Sounded like a win/win type of situation. Then I thought about taking it one step further and installing the operating system on the hard drive and having the boot loader mount the drive and load the operating system from there. I did some quick Web searching and came up with the solution.
The page I found is The Raspberry Pi Hobbyist: Running From an External Hard Drive. This page had detailed instructions on how to set everything up. If you aren’t familiar with Linux the instructions will look like some arcane version of gibberish. But to somebody familiar with installing hard drives on Linux/Unix it will make sense. You can look at that page for details, but here are the high level steps.
- Attach the USB drive and make sure it is recognized
- Partition the drive as desired, making sure to at least create a partition for the OS and a swap partition. I created an additional data partition.
- Format the partitions as needed
- Set up the swap partition on the hard drive
- Copy the OS partition from the SD card to the hard drive partition. This uses a block by block copy from the SD card to the hard drive, creating a mirror image on the hard drive.
- Check the hard drive OS partition for errors.
- Resize the newly copied OS data to use the entire hard drive partition which is most likely larger than the SD card partition.
- Modify the boot file on the SD card to boot from the hard drive rather than the SD card
- Change fstab to mount the new partitions
- Prevent the system from using the swap partition on the SD card
I made all of these changes to my system and then rebooted. It still requires the SD card to initiate the boot process, but then mounts up the hard drive and boots from there. It booted up just fine and when I checked the root partition was on the USB hard drive. So that step worked just fine. I also set up Postgresql and configured it so that databases are created on the data partition I created on the USB hard drive. Then I installed Java and the rxtx library so that my weather application can run. I don’t really have a whole lot of work left to be able to swap computers and use the Pi for my weather station. But I have several other unrelated activities that must take precedence over the weather station. So it may be a little while before I switch over. I’ll post an update when I make the switch. Then I need to fix the humidity sensor by replacing the sensor chip once again. I always seem to be able to find ways to stay busy.