|
|
Subject: Swap file on USB
From: Theo Markettos
Date: 11/9/2007 2:55:54 PM
I have a Netgear wireless router (a WGT634U) on which I've installed Debian.
It has 32MB SDRAM built in, in a way which isn't upgradable (well, some
serious soldering would be required). I'm running some apps on it which are
using up most of the RAM, and I want to run some more which will be idle
much of the time (specifically I want a webserver and SQL database).
The only interface the router has is a USB port. Currently I have the root
ext2 partition mounted with -o noatime on a 2GB Kingston flash stick, which
seems to get reasonable performance (about 17MB/s read, 8MB/s write I
think). I've given it a 128MB swap partition on the flash, but I don't
think this gets used too much.
But I'm probably going to be swapping a lot more with the extra apps. Any
suggestions of the best way to run a swap file on USB? I don't want a hard
drive - I want a low power router. I can think of:
1) Just use the flash as swap until it wears out, then replace it. Will
wearout trash the other data on it, or will it just start returning disc
errors and/or garbage for the swap sectors and leave the rest unchanged?
2) Get another flash stick for swap. Easier to replace but means I need a
USB hub (the router doesn't have a huge amount of power to spare so it'd
probably be a powered one)
3) Does anyone do RAM on USB?
4) Use an IBM microdrive in a CF-USB adaptor. Would probably need it in
addition to the existing flash stick
5) Some kind of swapfile driver that tries to optimise writes to the medium?
6) Wear leveling over both partitions so that just the swap part uses writes
from the root partition
Any thoughts?
Thanks
Theo
Subject: Swap file on USB
From: Sinister Midget
Date: 11/9/2007 10:41:17 AM
On 2007-11-09, Theo Markettos <theom+news@chiark.greenend.org.uk> claimed:
> I have a Netgear wireless router (a WGT634U) on which I've installed Debian.
> It has 32MB SDRAM built in, in a way which isn't upgradable (well, some
> serious soldering would be required). I'm running some apps on it which are
> using up most of the RAM, and I want to run some more which will be idle
> much of the time (specifically I want a webserver and SQL database).
>
> The only interface the router has is a USB port. Currently I have the root
> ext2 partition mounted with -o noatime on a 2GB Kingston flash stick, which
> seems to get reasonable performance (about 17MB/s read, 8MB/s write I
> think). I've given it a 128MB swap partition on the flash, but I don't
> think this gets used too much.
>
> But I'm probably going to be swapping a lot more with the extra apps. Any
> suggestions of the best way to run a swap file on USB? I don't want a hard
> drive - I want a low power router. I can think of:
>
>
> 1) Just use the flash as swap until it wears out, then replace it. Will
> wearout trash the other data on it, or will it just start returning disc
> errors and/or garbage for the swap sectors and leave the rest unchanged?
>
> 2) Get another flash stick for swap. Easier to replace but means I need a
> USB hub (the router doesn't have a huge amount of power to spare so it'd
> probably be a powered one)
>
> 3) Does anyone do RAM on USB?
>
> 4) Use an IBM microdrive in a CF-USB adaptor. Would probably need it in
> addition to the existing flash stick
>
> 5) Some kind of swapfile driver that tries to optimise writes to the medium?
>
> 6) Wear leveling over both partitions so that just the swap part uses writes
> from the root partition
7) Get a cheap pocket drive of 5G or more. That's actually a small hard
drive and is made to handle longer-term repeated access, unlike a
flash. Plus it's faster than a flash on the same connection. If you
don't get carried away they usually don't cost a lot (might depened on
the country....I don't know).
> Any thoughts?
Just that one.
--
Be nice to your children, they are going to choose your nursing
home.
Subject: Swap file on USB
From: anton@mips.complang.tuwien.ac.at (Anton Ertl)
Date: 11/10/2007 12:57:50 PM
Theo Markettos <theom+news@chiark.greenend.org.uk> writes:
>1) Just use the flash as swap until it wears out, then replace it.
I would do that. And keep backups.
> Will
>wearout trash the other data on it, or will it just start returning disc
>errors and/or garbage for the swap sectors and leave the rest unchanged?
c't Magazine tried to wear out USB sticks, but failed. So they did
not give an answer to that.
Wear leveling built into the USB drive probably means that not just
the swap part will be affected, but everything; at least everything
that is written after some block fails (if the wear leveling does not
move other data around to make use of their lower wear, blocks should
be safe if they are written at the start and then only read
afterwards).
>5) Some kind of swapfile driver that tries to optimise writes to the medium?
I doubt that something like this exists. First, swapping is probably
pretty even in wear anyway. More importantly, the USB stick has its
own wear leveling, and how would such a driver interact with that?
>6) Wear leveling over both partitions so that just the swap part uses writes
>from the root partition
As mentioned the stick does its wear leveling anyway, so there's no
need for you to do something about it.
- anton
--
M. Anton Ertl Some things have to be seen to be believed
anton@mips.complang.tuwien.ac.at Most things have to be believed to be seen
http://www.complang.tuwien.ac.at/anton/home.html
Subject: Swap file on USB
From: et472@FreeNet.Carleton.CA (Michael Black)
Date: 11/10/2007 4:43:06 PM
General Schvantzkopf (schvantzkopf@yahoo.com) writes:
> On Fri, 09 Nov 2007 14:55:54 +0000, Theo Markettos wrote:
>
>> I have a Netgear wireless router (a WGT634U) on which I've installed
>> Debian. It has 32MB SDRAM built in, in a way which isn't upgradable
>> (well, some serious soldering would be required). I'm running some apps
>> on it which are using up most of the RAM, and I want to run some more
>> which will be idle much of the time (specifically I want a webserver and
>> SQL database).
>>
>> The only interface the router has is a USB port. Currently I have the
>> root ext2 partition mounted with -o noatime on a 2GB Kingston flash
>> stick, which seems to get reasonable performance (about 17MB/s read,
>> 8MB/s write I think). I've given it a 128MB swap partition on the
>> flash, but I don't think this gets used too much.
>>
>> But I'm probably going to be swapping a lot more with the extra apps.
>> Any suggestions of the best way to run a swap file on USB? I don't want
>> a hard drive - I want a low power router. I can think of:
>>
>>
>> 1) Just use the flash as swap until it wears out, then replace it. Will
>> wearout trash the other data on it, or will it just start returning disc
>> errors and/or garbage for the swap sectors and leave the rest unchanged?
>>
>> 2) Get another flash stick for swap. Easier to replace but means I need
>> a USB hub (the router doesn't have a huge amount of power to spare so
>> it'd probably be a powered one)
>>
>> 3) Does anyone do RAM on USB?
>>
>> 4) Use an IBM microdrive in a CF-USB adaptor. Would probably need it in
>> addition to the existing flash stick
>>
>> 5) Some kind of swapfile driver that tries to optimise writes to the
>> medium?
>>
>> 6) Wear leveling over both partitions so that just the swap part uses
>> writes from the root partition
>>
>>
>> Any thoughts?
>>
>> Thanks
>> Theo
>
> Why are you trying to run a server on a router? Don't you have an old PC
> laying around that you could use? Anything would be better than a router
> with only 32M of RAM in it.
Surely one reason is that a whole computer takes up space, but a router
is relatively small.
I imagine the novelty is part of it all. I have seen articles about
using such routers as dedicated Linux controllers, because they are
relatively inexpensive, and commonly available. They are being treated
as a new wave of single board controllers, much in the same way that
circa 1982 there was an article in Kilobaud about using a single board
computer that had an ascii keyboard built in because it was cheaper
to buy those than do development on a dedicated computer and build
them in a pretty limited number.
Michael
Subject: Swap file on USB
From: Theo Markettos
Date: 11/11/2007 4:18:58 PM
Michael Black <et472@freenet.carleton.ca> wrote:
> I imagine the novelty is part of it all. I have seen articles about
> using such routers as dedicated Linux controllers, because they are
> relatively inexpensive, and commonly available. They are being treated
> as a new wave of single board controllers, much in the same way that
> circa 1982 there was an article in Kilobaud about using a single board
> computer that had an ascii keyboard built in because it was cheaper
> to buy those than do development on a dedicated computer and build
> them in a pretty limited number.
The main reason is power. My router takes 9W, my server takes 100W. At
electricity at about 8p/KWh, that's a big difference, as well as trying to
reduce the amount of CO2 I generate.
As well as the router function I'm using it for my Asterisk telephone
exchange. This needs to be on 24/7, while my main server can go down for
periodic maintenance or when I'm on holiday. Specifically a calling card
app I want to use with Asterisk requires a database and web interface... I
normally run things like boa to keep the memory impact down, that's no
problem, but I have about 2MB free RAM at the moment so I suspect any server
isn't going to fit.
Theo
PS: I did once run X and Netscape in 4MB on a 386. Fast it wasn't :)
Subject: Swap file on USB
From: Noozer
Date: 11/11/2007 4:41:05 PM
>> Why are you trying to run a server on a router? Don't you have an old PC
>> laying around that you could use? Anything would be better than a router
>> with only 32M of RAM in it.
>
> Surely one reason is that a whole computer takes up space, but a router
> is relatively small.
Actually, this is a GREAT application where a really cheap laptop shines.
They provide a battery backup, have much more memory than a dedicated
router/firewall, are able to act as a server, and use a lot less power than
a regular PC. Adding a second ethernet port to keep your private LAN
seperate from the internet is usually as easy as adding a PCMCIA/Cardbus
card. Newer laptops also have USB and Firewire avaialable for adding
storage, etc.
The only problem is that these older laptops have questionable battery life.
To preserve your data, it would be smart to have them do a controlled
shutdown as soon as a powerloss is detected.
Subject: Swap file on USB
From: Theo Markettos
Date: 11/11/2007 10:19:35 PM
Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
> Wear leveling built into the USB drive probably means that not just
> the swap part will be affected, but everything; at least everything
> that is written after some block fails (if the wear leveling does not
> move other data around to make use of their lower wear, blocks should
> be safe if they are written at the start and then only read
> afterwards).
I'm not sure about that... I've heard that cheap sticks don't wear level the
whole medium, they just wear level the sectors where the FAT is (a fixed
location, even if you reformat it). That's a much easier proposition than
trying to wear level at sector level (block level might be a bit more
sensible). Maybe some more expensive discs wear level every block, but
manufacturers aren't good at shouting about how their wear levelling works
on the data sheet.
Theo
Subject: Swap file on USB
From: Theo Markettos
Date: 11/11/2007 10:35:05 PM
Noozer <dont.spam@me.here> wrote:
> Actually, this is a GREAT application where a really cheap laptop shines.
> They provide a battery backup, have much more memory than a dedicated
> router/firewall, are able to act as a server, and use a lot less power than
> a regular PC. Adding a second ethernet port to keep your private LAN
> seperate from the internet is usually as easy as adding a PCMCIA/Cardbus
> card. Newer laptops also have USB and Firewire avaialable for adding
> storage, etc.
That's true, though I'd need to add another network card and a wireless card
(old laptops don't have wireless) to do the router functionality, and then a
switch to provide 4 ethernet ports. And the wireless card would probably
need an external antenna fitting (those little PCMCIA-card antennas probably
won't have enough power to be access point for the whole house). At which
point I've spent a fair bit of money and have at least two units with two
power supplies, and I'm back in the same place. Yes I can run a few server
apps more easily, but it's messier at getting the frontline job done (being
a router).
Battery backup is nice but not critical - when the power goes down the
switches and the cable modem go down, so the router is fairly useless. I
make sure I sync(1) the flash on a regular cron job, so disc corruption hasn't
been a problem.
Also I like have a MIPS box as my firewall - a small figleaf against buffer
overrun attacks. I don't know how useful it is given half the router boxes
out there run some version of Linux/MIPS - but then, though numerous, with
limited CPU and no disc they're probably not great as a botnet target.
Theo
Subject: Swap file on USB
From: Theo Markettos
Date: 11/11/2007 10:40:39 PM
Jerry McBride <jmcbride@mail-on.us> wrote:
> If the support logic is already on the motherboard, this would be the best
> way to go. I've never had one of those opened, but I have seen memory chips
> piggy-backed to memory chips soldered to the motherboard. The last one of
> those hacks was an XBOX. Not pretty at all, but it worked none the less.
That's a point - I hadn't thought of that. We have a hot air desolder
station at work so it might be possible to borrow a suitable chip from a
DIMM or similar, and a piggyback arrangement would be fairly robust. Most
of the time some hack like this I've done has failed has been for mechanical
reasons, which was what I was worried about.
> I'm assumeing you will optimize the apps as much as possible? Using -Os does
> wonders and is probably supported by the cpu in the router in question.
I'm using the standard Debian packages so don't really want to mess around
building my own, but that's useful to know if it comes to it.
> Having read the posts to your query, the ones that make the best sense are;
>
> 1 - use a micro drive instead of CF. It's faster and more durable.
That probably sounds like the most sensible suggestion.
> 2 - be real careful with the apps you pick. lighthttp has a much smaller
> foot print than apache, etc...
Agreed, definitely not Apache if I can get away with it :)
Thanks
Theo
Subject: Swap file on USB
From: anton@mips.complang.tuwien.ac.at (Anton Ertl)
Date: 11/12/2007 8:55:22 AM
Theo Markettos <theom+news@chiark.greenend.org.uk> writes:
>Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
>> Wear leveling built into the USB drive probably means that not just
>> the swap part will be affected, but everything; at least everything
>> that is written after some block fails (if the wear leveling does not
>> move other data around to make use of their lower wear, blocks should
>> be safe if they are written at the start and then only read
>> afterwards).
>
>I'm not sure about that... I've heard that cheap sticks don't wear level the
>whole medium, they just wear level the sectors where the FAT is (a fixed
>location, even if you reformat it).
Yes, c't writes about special treatment for the FAT, too. Anyway,
they also write (c't 21/2007, p. 104) that they wrote various test
patterns to the same area of a USB stick 16M times (i.e., far beyond
the guaranteed number of write cycles), and read and checked them
afterwards, and did not manage to get an error. That test took days.
They did not write whether they wrote to the FAT area, though.
Anyway, I would be more worried about the stick failing for other
reasons than from writing too often. I have a dead stick that
certainly had not reached the write limit.
>That's a much easier proposition than
>trying to wear level at sector level (block level might be a bit more
>sensible).
Well, two facts make it rather natural to deal with writes in a way
that helps wear leveling: flash-internal blocks are larger than the
sectors used by the interface; and erasing is at block granularity,
while writing happens at word granularity. But of course there is no
guarantee that the designers of a particular flash controller take
this natural approach.
- anton
--
M. Anton Ertl Some things have to be seen to be believed
anton@mips.complang.tuwien.ac.at Most things have to be believed to be seen
http://www.complang.tuwien.ac.at/anton/home.html
Subject: Swap file on USB
From: Theo Markettos
Date: 11/12/2007 10:48:22 PM
Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
> Yes, c't writes about special treatment for the FAT, too. Anyway,
> they also write (c't 21/2007, p. 104) that they wrote various test
> patterns to the same area of a USB stick 16M times (i.e., far beyond
> the guaranteed number of write cycles), and read and checked them
> afterwards, and did not manage to get an error. That test took days.
> They did not write whether they wrote to the FAT area, though.
Thanks. I think the article you mean is this:
http://www.heise.de/ct/07/21/100/
(in German). Sadly the tests are off the end of the online copy.
> Anyway, I would be more worried about the stick failing for other
> reasons than from writing too often. I have a dead stick that
> certainly had not reached the write limit.
I'm guessing static electricity or mechanical stress would be prime causes
for killing sticks, which shouldn't be a problem if it's always plugged in.
Power supply glitches might, but that'd affect the whole machine.
> Well, two facts make it rather natural to deal with writes in a way
> that helps wear leveling: flash-internal blocks are larger than the
> sectors used by the interface; and erasing is at block granularity,
> while writing happens at word granularity. But of course there is no
> guarantee that the designers of a particular flash controller take
> this natural approach.
I suppose there's one way to find out. Buy two sticks. Run one as normal.
Run the other on continuous test until it fails. When it does, throw them
both out and start again.
Theo
|