TECHIE WARNING: This article uses a lot of jargon, so if you aren’t sure, ask questions or if you aren’t interested, read on.
And it comes with a little pitfall if you don’t know computers that well. Mine was a slight issue which the operating system I was using, which is called Ubuntu Mate. I went from an AMD computer to a Raspberry Pi as I thought my AMD system which is by the way, an AMD A4-5000 based system, with 2 2.5″ hard drives, an ATI Radeon 240 graphics card and 16GB of ram, shoved in a case that hooks on to the back of a monitor.
I changed because I didn’t want the distractions when having important stuff to do, like using eBay to sell stuff or my applications I’m suppose to be doing. The Raspberry Pi, or more correctly, Raspberry Pi 2 as a fully fledged desktop computer made sense. Add a Sony monitor, DVI to HDMI cable, USB keyboard and mouse, USB wifi device and a 16GB Transflash card with Ubuntu Mate and you have a perfectly working computer that actually isn’t half bad. Except one problem, too many programs slow the computer down. It took me a while to find out and the problem is actually a simple fix. Now, I strongly recommend if you are going to use the Pi as a general purpose computer, follow this. For me, I went to Applications > System Tools > MATE System Monitor then watched the RAM usage. The Pi has 16x less RAM than my AMD system. (32x than another system I own). So, its a little wonder when I used my Pi for a few tasks, it ran out of RAM. Its a surprisingly simple fix – create a swap partition.
A Swap what?
Whats swap? Simple, its like RAM or memory. I assume you know the difference between Memory (Temporary) and storage (permanent). Memory isn’t where your files live. Thats a hard drives job. The Hard drive, in the case of my Pi, lives on a small Transflash card which when I remove any power to it, my files stay there no matter what happens.
Memory or RAM is different, its temporary use, this blog was made in RAM which if I was to unplug my Pi, everything will be lost and I have to start again which is very annoying. But RAM is very fast temporary access, which is often very limited because it is expensive. Storage is much slower but you can buy more of it. So what do you do when you run out of RAM? The computer just simply stops without a swap partition. Lets say you have 512mb of RAM (temporary space). Your operating system will probably take around 100mb of that and an email client about 60mb, web browsing will consume 250mb and add a game which takes up another 130mb and then the computer goes “well, what do I do with the rest of the 28mb I need? I have no space!” and then crawls or locks up completely.
A swap file or partition more like in this case, the Operating System goes “Oh, I got some space to use. Its slow, so I’ll put the oldest/least used files in there”. And then the computer doesn’t crash. The computer basically thinks it has more RAM than it actually does. It sounds great but there are at least 2 problems:
- For flash based drives, you’ll eventually wear out the drive far quicker with a swap file than normal read and writes. Its not a problem as it used to be as the drives themselves are often rated at 1m write cycles and unlimited read cycles. Besides at £10 per 16GB transflash drive, why worry?
- Its slower to access despite my Pi has a Class 10 card.
But we still need it more. Or don’t use the humble £35 Pi as a desktop. (Which by the way, is a silent desktop!)
To do this, open your favorite terminal, on Ubuntu Mate, it can be found under
Applications > System Tools > MATE Terminal.
You’ll see a text screen, get your password ready for this and you won’t see what you typed, you will need it. Type first “Sudo apt-get update”. Once that finishes, type “Sudo apt-get install gparted”. You are installing a partition editor, what does it do? Allocates disk space across a disk for different uses.
Then type “Sudo gparted”, you should see a partition editor. You should see a button saying “New”, click this, then under the partition type which is probably “ext4” by default, select “swap”. Set the size to either 1024 or 2048 (up to you), create it, then right click on the new swap partition as its called (the red outlined bit) and select “swapon”. Close, restart and it should be fixed. You can also resize your existing stuff to take up a bit more space if your drive is rather large.
Now check with the “System Monitor” to see if it gives you the size of the swap partition and notice a huge improvement in speed.
That should be all you need. No I don’t have any screenshots sadly. 🙁