Raspberry Pi - Part 05 - Extra Configurations
Raspberry Pi - Part 05 - Extra Configurations
-
Extra Configuration
On Your Raspberry Pi
Version: 2016-04-19
To prevent your Raspberry Pi's from writing a lot of data, and thus, wearing the SD card, you
can do a couple of things.
tmpfs
The first one is to mount a few folders in RAM as tmpfs. The folders are the folders where
temp files and logging is written to. This means that you won't have syslog available, but
most of the time that is not a problem.
Edit /etc/fstab
When you have finished press [Ctrl] + X. This will ask if you want to save the modified
files. Press 'Y' and then hit [Return] to save the file with the same name.
This will mount the above folders in RAM, with a max size of 10 megabyte. The noatime
option means that the access time of a file is not updated, saving a lot of writes as well.
You should also add the noatime option to your other partitions, for example on a standard
Raspbian:
Here the /boot partition is also mounted read only (ro). The noatime option is added.
Issue a mount -a command or reboot the machine to make this active.
Disable swap
Linux divides its physical RAM (random access memory) into chucks of memory called
pages. Swapping is the process whereby a page of memory is copied to the preconfigured
space on the hard disk, called swap space, to free up that page of memory. The combined
sizes of the physical memory and the swap space is the amount of virtual memory
available.
Swapping causes a lot of writes to the SD card. You would want to turn it off to save
writes. The downside of this is that when there is not enough RAM available the linux OOM
(Out Of Memeoy) killer will randomly kill processes to save RAM.
Raspbian by default has a swap file, dynamically managed by the dphsys-swapfile utility.
You can turn off this utility by issueing the following commands:
dphys-swapfile swapoff
dphys-swapfile uninstall
update-rc.d dphys-swapfile remove
After a reboot the swap will be gone, which you can check with the free -m command:
My Raspberry Pi's have a cronjob which reboots them once every seven days. This to apply
kernel updates and just a general good procedure to see if all still works after a reboot.
By default, fsck checks a filesystem every 30 boots (counted individually for each
partition). I decided to change this to every boot, so disk problems might be found earlier
and possibly fixed earlier.
To set up an fsck at every boot, execute the following command:
sudo crontab –e
0 0 * * * /sbin/reboot
When you have finished press [Ctrl] + X. This will ask if you want to save the modified
files. Press 'Y' and then hit [Return] to save.
To view handle files on a Pi from a Windows PC you need to install and configure a package
called SAMBA, which allows a UNIX file system to be seen by a Windows network client. The
following steps are based in information from http://elinux.org/R-Pi_NAS
Edit /etc/samba/smb.conf
[MyShare]
comment = My Share for log files
path = /var/log
read only = yes
guest ok = yes
writeable = yes
I found that I needed to grant access to the /var/log directory, which I did with a
Doubtless there are tighter protections I could have used. Now restart the Samba server
You now access the files from Windows just like any other network share, for example
C:\>dir \\RasPi-1\MyShare
Directory of \\RasPi-1\MyShare
Installing Imagemagick
If you have a PNG format image that you want to convert to JPEG; this can be achieved from
the command line:
To resize image to 150 pixel height and allowing width to scale accordingly:
If you like to use your Raspberry Pi as a full computer, you might find the lack of office
applications disheartening. While our favourite open source office suite will always be
LibreOffice, as Winkleink rightly points out above, it’s not the leanest or fastest option to use
on your credit card-sized PC.
AbiWord is an excellent Microsoft Word clone that has all the features you need in a package
light enough to run smoothly on your Pi. To install it all you need to do is type:
in a terminal window.
You’ll find it installed under ‘Office‘ once it’s installed
If you need to crunch numbers as well as letters, Gnumeric is by far the most popular Linux
solution, which adds the capabilities of Microsoft’s Excel application to your Raspberry Pi’s
repertoire. To install it simply type the following into a terminal window:
Like Abiword, you need to be within the Raspberry Pi’s desktop environment to use Gnumeric.
Another essential piece of software for your Raspberry Pi is Sonic Pi 2. It allows you to make
music with your Raspberry Pi using easy-to-learn code.
There’s a wide range of effects and capabilities added with Sonic Pi 2, including the ability to
live code music, use samples and emulate even more cool synths.
Installing the latest (stable) pre-release version of Sonic Pi 2 is really easy. Within a terminal
window, type the following to download the package:
wget http://sonic-pi.net/sonic-pi-RC11.tar.gz
./sonic-pi/bin/sonic-pi
You can find a really comprehensive getting started guide for Sonic Pi 2 on The Raspberry Pi
Foundation’s resources page.
When you install a package, apt-get retrieves the needed files from the hosts listed in
/etc/apt/sources.list, stores them in a local repository (/var/cache/apt/archives/), and then
proceeds with installation.
In time the local repository can grow and occupy a lot of disk space. Fortunately, apt-get
provides tools for managing its local repository: apt-get's clean and autoclean methods.
apt-get clean removes everything except lock files from /var/cache/apt/archives/ and
/var/cache/apt/archives/partial/. Thus, if you need to reinstall a package apt-get should
retrieve it again.
apt-get autoclean removes only package files that can no longer be downloaded.