PDA

View Full Version : Swap space on RSMMC card?


Hedgecore
2005-12-09, 20:01
Admittedly, I've been staying away from the finer details of software development on the 770 as it could be some time before I finally get one, but has there been any/is there any work being done to allow the device to use a swap partition on an RSMMC card? Is this even feasible? I realize that would rely on the somewhat underpowered processor, but at least it'd be some extra memory.

konttori
2005-12-09, 21:26
I think they are afraid what happens when you pull out the mmc. Mmc is now hot swappable, but it wouldn't be anymore if it could contain swap. Having said that, I think it's reasonable to assume that if you'd activate swap in some control panel, it could inform you that all bad things will happen shoud you remove the mmc while it's using the mmc as swap.

andymulhearn
2005-12-09, 22:04
The commands are all there and should allow you to do this. I followed some instructions on the maemo developers list but it failed on the swapon command.

I have a feeling it may require full root access to work :(

And of course, as konttori points out, it will all go horribly wrong when someone pulls their mmc and half the OS has been swapped out :)

Crisis
2006-01-09, 19:44
In a root shell I issued mkswap to my card, and when I tried the swapon, it rebooted the device.

Hopefully eventually a way will be determined to allow a swap partition to be setup on the mmc

andymulhearn
2006-01-09, 20:19
I put the following into a file called swapper.sh which I copied to my 770 and put in my home directory.

dd if=/dev/zero of=/media/mmc1/swap bs=1024 count=16384
/sbin/mkswap /media/mmc1/swap 16384
/sbin/swapon /media/mmc1/swap

Then I:

1. Switched to R&D mode using the OSX Flasher
2. Started xterm
3. Did a cd to move to /home/user
4. ran chmod +x swapper.sh
5. ran sudo gainroot
6. ran ./swapper.sh

And it worked fine. What version are you running?

Hedgecore
2006-01-09, 21:12
This idea will spawn two camps of people. Those who will say it's sacrelige to use up the limited internal space, and those who will remind me about the limited number of reads/writes.

Couldn't ya give it another 12 megs of swap space using the internal memory without having to worry about swapping RSMMCs?

gnuite
2006-01-09, 22:20
First of all, even if it worked, I don't think setting up swap on the internal flash is a good idea, due to the read/write lifetime. Swapping on an RS-MMC, though, seems reasonable, since they are replaceable. In fact, I'm using the included MMC for that very purpose, since it's small and I intend to replace it anyway.

Crisis: your reboot issue is likely due to trying to create a swap file that is too large. For some reason, the device reboots if you try to activate too much swap within a certain amount of time. I'm found that sixteen megabytes per fifteen seconds is close to the limit. If you want more than sixteen megs, you need to create two or more swap files and swapon them with fifteen seconds of delay between each swapon. I think twenty-four meg swap files may work, too, but I usually stick with sixteen.

philmcneal
2006-01-09, 23:20
is there anyway to setup swap without doing all that crap to become root?Because I have the file on my MMC right now, but can't tell my 770 to use it.

arivero
2006-01-10, 16:34
Hmm, with kernels 2.6... Can I swap towards a networked file via the wifi?

andymulhearn
2006-01-10, 17:37
is there anyway to setup swap without doing all that crap to become root?Because I have the file on my MMC right now, but can't tell my 770 to use it.

Not as far as I know. The swapon command needs root access.

The only other way I know is to add it to /etc/fstab and then reboot and that (editing fstab) needs you to be root as well. Sorry :(

I now run my 770 in root enabled mode all of the time. Providing you don't do sudo gainroot I'd be surprised if you even see a difference.

Mythic
2006-01-10, 18:20
Hello, I have a question how much it is dangerous to use swap on the mmc card. Some people mention that u will "fry" the card by constant access. But the Pretec card, I have got, came with life time warranty. So are these worries still valid?

Also I wonder if the whole card is destroyed or just the sectors with the swap.

dillera
2006-01-11, 06:50
2 things:

#1- firmware .51 no longer seems to work with any amount of swap (I've tried 16,32 and 128M) - i get out of memory as soon as I enable some and do something.

#2 - you want swap on a independant partition on the MMC, so that if you plug in the 770 into a desktop computer and it makes the MMC card go into USB Memory card mode the swap will be ripped out from the 770....

See the entry on my blog:
http://www.dillernet.com/apple/2005/12/27/making-swap/

it has some good info on this.

I don't use swap anymore with .51, it may not need it anyway. .48 did.

pdafan
2006-01-11, 14:37
I can confirm that the week 51 download does support swapping. 32MB would crash the machine when it started swapping, 16 and 24MB work just fine. I have my swap on a separate partition.

No worries about wearing out the card. I created a "spare" swap partition just in case! :D

Beastmaster
2006-01-13, 17:59
On the Syncing Apple's blog site, I noticed that Tommy Cheng's response to the posting of swap space gave me a somewhat killer idea.

Since I don't have SSH on my 770 (yet), I figured that I would create a simple text file to cut/paste into xterm. This is also useful if you don't have the bluetooth keyboard either.

So, here's the steps that I took to do this:

1) Obviously, your 770 has to have been modded to allow sudo gainroot. If you haven't done so, do it and continue to step 2.

2) Ensure you have xterm loaded.

3) Re-fdisk your mmc card to allow for two partitions. My second partition is only 24mb.

4) Start a web browser in your 770

5) Browse to: http://24.248.84.138/sgyee/770swap.txt

6) Select all, and copy the file contents

7) Open Xterm, sudo gainroot, and ensure you have a directory of init.d in /var/lib/install/etc . If not, make one.

8) Paste the file contents into xterm, not via the virtual keyboard applet, but from within xterm. Hit enter once.

9) Reboot. You now have it done, and you don't have to SSH or do any stupid typing to ensure that it works.

Enjoy!
-Steve

bhima
2006-01-13, 19:07
No worries about wearing out the card. I created a "spare" swap partition just in case! :D

Flash cards of all current kinds include "wear levelling", which is supposed to spread writes around - in other words, every change to a file does not equate to a single erase cycle.

Clearly, the only way you could do this is by having writes happen to un-used blocks elsewhere on the card.

I haven't found anything that talks about the actual details of this. I don't know if there are "extra" blocks for this purpose, or if you'll find that your unused flash blocks are just grabbed for this purpose somehow.

However, there's a reasonable chance that you'll find that erase cycles are happening everywhere on your flash card, not just inside this one section.

I also speculate - but I'm not so sure - that having a less filled flash card will provide better wear levelling. It depends on the algorithm they use - also, it's not clear _how_ much a less-filled card would help.

In other words, depending on algorithm, you may find that a 24MB swap file on a 32MB flash card spreads the wear out as well as a 24MB file on a 512MB card - because the algorithms are optimized for the more likely scenario, of a nearly full card, with a few files that change every now and then, rather than a nearly empty card with one single constantly changing file.

The bottom line is: Nobody I have been able to find has been able to provide any serious information about how long your flash card will last as swap, and no matter what you do, using flash as swap carries the risk of prematurely ending the life of your _entire_ card.

Go forth and try it, and enjoy it, but don't use a flash card you can't afford to replace.

thedarksavant
2006-01-15, 19:47
My swap experience http://www.nokia770tablet.com/viewtopic.php?t=30