2010-05-12, on some version of PCLinuxOS.
Way back when, I was using Linux on some very very low-end systems. I remember that at one point I stuck in some more memory, and because I couldn't actually see a performance difference I went back to 64MBs. Heh.
There are two things which I've always struggled with. One is the amount of memory "needed" and the other is the existence of the swap partition. At one point I got a new system with 1GB of memory - a fairly significant upgrade from 64MBs - and at some point I decided that a swap partition was a stupid idea.
I had always been a proponent of security, and to me the use of a swap partition was a security leak. Around this time in my Linux career, I had been heavily-using encrypted filesystems and so I did have legitimate concerns about a swap partition. Yes I did know about encrypting the swap partition as well, but I figured that with enough system memory there would be no point in having a swap at all.
So at some point I decided disabling the swap file. Many distributions still require that you have some dud partition to use as a swap partition before you can actually install, so I had always kept an 8MB partition kicking around for this purpose.
The symptom? ∞
Well not really, at least not for the reasons I had thought. But the blame started to lay on Firefox's massive (memory usage) shoulders.
There are a number of things which I may be doing which would trigger an infinite loop of disk-access. Unfortunately, I can't remember the term - or at least the nickname - for this. It was always at a point of high memory usage.
I had lots of "fun" trying to get a shell going so I could kill a task, or playing with SysRQ-REISUB, or waiting for long enough that several applications would predictably crash: LXPanel, XScreenSaver and Firefox.
The problem ∞
The problem was high memory usage. Everything worked fine up until nearly maximum memory usage, and then my system would grind to a halt. After quite enough of this mess I did some thinking and some research to learn that this is caused by a combination of issues.
Programs need memory to run. This is obvious enough. Running out of memory is bad. You either cannot start new programs or existing programs cannot allocate additional resources and then they die.. if you're lucky.
Having a swap partition alleviates the memory concern. I could talk about how it works but I'd be making shit up, and I don't feel like researching this.
Some Research ∞
While diagnosing this issue, one of my uses was with Firefox and the Skipscreen add-on. I would leave my computer on overnight leeching files off of Rapidshare, and then I'd return to have a bunch of download dialogs to work with. Save, Ok, Save, Ok.. argh. Ok, alt-s, enter, alt-s, enter. Wait, maybe I can hover the mouse over s, click, enter, click..
I had done a bunch of research to get Firefox to shut the hell up about those dialogs, but it's apparently impossible because Rapidshare doesn't send files with the proper MIME type, and Firefox is a cunt about standards. Sigh. I ended up switching to the RDown add-on, at least for Rapidshare downloads. It's simple but it works spectacularly well.
At any rate, one of the issues was that Firefox is set by default to use
$TMP for downloading files. This means that
/tmp would get filled. Actually, it wouldn't. It was somehow magical. But when I delved into things, I did end up researching both Firefox's save locations and settings as well as the
tmpfs is an automatically-resizing ramdisk. In situations of low memory, it resizes itself and starts to rely on the swap partition instead. This is just awesome.
And so therein lies the problem. At high memory usage, tmpfs would dump contents into the swap partition, and my system would get into an infinite freakout loop that would probably make hard drive manufacturers alternately cringe and grin.
Why? I forgot to disable my 8MB swap partition. Oops.
The Solution ∞
Ok, so first off.. I had no real excuse to not have a swap partition. Even though my main drive is "only" 64GB (lay off, it's an SSD) I could spare a couple of gigs easily.
And yes, it's perfectly fine to have swap on an SSD. Whatever paranoia that's still out there is for old drives. What I've got is just as reliable as an everyday HDD.
I resized my partitions (after backing up my data) using GParted. It's in the repository so it was trivial to install. Actually it wasn't.. I needed to boot off of the install cd and install it from the LiveCD. Resizing an actively-mounted ext3 partition is apparently still a faux pas.
Second, don't use tmpfs for
/tmp. tmpfs is a great tool, but the idea of "cleaning out
/tmp at every boot" should be a simple
rm and not this elaborate setup. That little checkbox is seriously misleading.
Some time in the future, I'll play with tmpfs for my use of BitTornado's logs. I never did like the idea of a fixed-size ramdisk. While I'm at it, I ought to check out some other more regularly-run cron job thingy.