View Full Version : Swapping to a file in free space of rootfs, possible?
gostyuk
06-03-2012, 03:12 PM
Is it possible to swap to rootfs file? i tryed
dd if=/dev/zero of=/usr/share/swap1.img bs=1024 count=40960
mkswap /usr/share/swap1.img
swapon /usr/share/swap1.img
and my phone restarted...
Any help
qwazix
06-03-2012, 04:38 PM
I don't know why it restarted but the priority of your new swap will be lower than the default swap and thus it will get used only when the 768 emmc swap fills. To enable it with higher priority you either need to use swapon from easydebian or swapon /dev/swap1.img
swapoff /dev/mmcblk0p3; swapon /dev/mmcblk0p3
misterc
06-03-2012, 04:44 PM
Is it possible to swap to rootfs file? i tryed
and my phone restarted...
Any help
you better keep as much as possible of "/" free
when the "/" aka root of a *nix system is filled, it simply stops, indeed.
gostyuk
06-03-2012, 06:58 PM
I don't know why it restarted but the priority of your new swap will be lower than the default swap and thus it will get used only when the 768 emmc swap fills. To enable it with higher priority you either need to use swapon from easydebian or swapon /dev/swap1.img
swapoff /dev/mmcblk0p3; swapon /dev/mmcblk0p3
did you try that on your n900? after i write
swapon /dev/swap1.img
it restarts my phone...
gostyuk
06-03-2012, 07:01 PM
you better keep as much as possible of "/" free
when the "/" aka root of a *nix system is filled, it simply stops, indeed.
i left 35 MB free from rootfs. anyway why is it restarting....
pablocrossa
06-03-2012, 07:14 PM
i left 35 MB free from rootfs. anyway why is it restarting....
Without any kind of log it is hard to say... Does it happen if you place that file in, lets say, MyDocs?? If so then it is something with enabling that image as swap, either not formatted so the phone crashes or it does not support from files (I imagine it would but, then again, I have never done this on an N900, 768MB swap enough :D )
gostyuk
06-03-2012, 08:00 PM
mydocs is not rootfs... its emmc :)... rootfs is formated not as ext3 ?! or ext2? can i format let say 50 MB as ext3? if yes then how :D?
pablocrossa
06-03-2012, 10:05 PM
mydocs is not rootfs... its emmc :)... rootfs is formated not as ext3 ?! or ext2? can i format let say 50 MB as ext3? if yes then how :D?
First apply the following command on your file (as root):
mkswap ./swapfile1
That should setup the 'filesystem' if you will for swap :) once that is done if it still reboots try moving the file to MyDocs and activating swap from it. It is to rule out several possibilities i.e. high use of rootfs so it flips out, do not know, just to be sure :) if it still crashes from MyDocs then maybe file swap is not supported on maemo (for some random reason) and an expert should help you on that :)
gostyuk
06-04-2012, 03:20 AM
i already have a swap on microsd... so it is supported. Mydocs isn't located on nvram(rootfs) chip.It would be pointless i already have 768 MB by default from emmc...
Anyone , is it possible to have let say 40MB of swap on rootfs,nvram chip?
pablocrossa
06-04-2012, 10:29 AM
i already have a swap on microsd... so it is supported. Mydocs isn't located on nvram(rootfs) chip.It would be pointless i already have 768 MB by default from emmc...
Anyone , is it possible to have let say 40MB of swap on rootfs,nvram chip?
I just wanted to test that to see if it restarted from MyDocs too. You say you have it from the microsd so it is clearly a problem with the rootfs, that is what I wanted to know by running it from MyDocs, I was not proposing to keep it on MyDocs but just do a test run to see if it would work from MyDocs and let us know it was a problem when running from rootfs. Did you run the command I posted before to 'format' the file? :) Good luck, if you have I cannot help you any further
The rootfs uses a compressed filesystem (ubifs), so while a swap file filled with zeros might fit, it might run out of space when real data goes into it. It's also possible ubifs wants to allocate memory during writes, in which case swapping to it would be unsafe.
pablocrossa
06-04-2012, 12:17 PM
The rootfs uses a compressed filesystem (ubifs), so while a swap file filled with zeros might fit, it might run out of space when real data goes into it. It's also possible ubifs wants to allocate memory during writes, in which case swapping to it would be unsafe.
Ah, the UBIFS makes total sense, thank you for the tip! :) When rootfs filled Unix halts and hence the phone reboots :) Thank you.
reinob
06-04-2012, 05:05 PM
I think the kernel (maybe not the one in the N900) has a mtdswap module that allows you to put swap on an mtd device (rootfs).
The idea is really good. Imagine using a chunk of your rootfs (say, 32MB) as compressed swap.
mrsellout
06-04-2012, 06:51 PM
I think the kernel (maybe not the one in the N900) has a mtdswap module that allows you to put swap on an mtd device (rootfs).
The idea is really good. Imagine using a chunk of your rootfs (say, 32MB) as compressed swap.
On the n9/n950 the nand chip contains the swap, while they've also used ramswap (or compcache I think) to inflate the size of ram.
With hindsight, Konttori mentioned that they should've done the same (ie stuck the swap on the nand and the rootfs on the emmc) for the n900.
I wonder if that could be an avenue for people to explore with the n900.
Read his posts from here on:
http://mg.pov.lt/maemo-irclog/%23maemo.2011-06-20.log.html#t2011-06-20T23:01:52
Hurrian
06-05-2012, 06:00 AM
I think the kernel (maybe not the one in the N900) has a mtdswap module that allows you to put swap on an mtd device (rootfs).
The idea is really good. Imagine using a chunk of your rootfs (say, 32MB) as compressed swap.
Not our kernel, a way newer (http://lxr.free-electrons.com/source/drivers/mtd/mtdswap.c?v=2.6.39;a=arm) one in mainline (and the Nokia kernel on the N9/50, 2.6.32)
The Mer kernel doesn't have it, the Mer-3.x kernel probably does.
Either way, it'll need to be backported to be used, and Maemo moved off the rootfs to do so.
(Side note: I actually tried booting Harmattan on the N900 using the MeeGo CE kernel. When booting back to Maemo, I noticed that everything was crashing randomly. #maemo said that it probably tried to swap on mtd5. Lucky that Nokia didn't use any other partition as swap, as that could've been nasty for my phone.)
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.