[HOWTO] Create large files empty files ? - G1 Q&A, Help & Troubleshooting

Hi,
is it possible to tell dd to create a swap-file at a specified cluster ?
If not, did anyone know if there is an Android-tool, wich allocates Diskspace on FAT32 without actually writing data to a file ?
I`ve tried dd with the seek Option, but this wont work on FAT.
Thx in advance
Thom

TheGenesis said:
Hi,
is it possible to tell dd to create a swap-file at a specified cluster ?
If not, did anyone know if there is an Android-tool, wich allocates Diskspace on FAT32 without actually writing data to a file ?
I`ve tried dd with the seek Option, but this wont work on FAT.
Thx in advance
Thom
Click to expand...
Click to collapse
An empty file would be a file full of zeros (?)
also
has anybody tried to put a swap-file in /data partition yet? Should be way faster...

Wrong sect btw

I'm not sure if this is what you mean but
"dd if/dev/zero of=/sdcard/swapfile bs=1024 count=524288"
This command will tell dd to create output file with the size of 512MB full of zeros.
Then you run "mkswap /sdcard/swapfile" in order to create the swap file-system on the output file
Finaly you run "swapon /sdcard/swapfile" in order to make the swap avaialbe to the kernel.
This is how it goes on RH, I belive it will work the same on Android as well.
and I'm sorry if this isn't what you meant.

zrubi said:
I'm not sure if this is what you mean but
"dd if/dev/zero of=/sdcard/swapfile bs=1024 count=524288"
This command will tell dd to create output file with the size of 512MB full of zeros.
Then you run "mkswap /sdcard/swapfile" in order to create the swap file-system on the output file
Finaly you run "swapon /sdcard/swapfile" in order to make the swap avaialbe to the kernel.
This is how it goes on RH, I belive it will work the same on Android as well.
and I'm sorry if this isn't what you meant.
Click to expand...
Click to collapse
yeap, it works on Android
bs=1024k count=512 makes the maths easier
you could put it on data BUT I wouldn't advise it, its going to limit the life of the mtd, an SD card is much cheaper to replace

Thx for the replies.
No, I dont want a file full of 0x00 ... I need a way to force the physical position of the swap-file.
I have tried dd with the seek option wich allocates space without writing to the file. But it doenst work on a fat partition (resulting to a file full of zeroes).
Any Idea how to force the creation of a file starting at a specified cluster (or a near by position) ?
Thom

TheGenesis said:
Thx for the replies.
No, I dont want a file full of 0x00 ... I need a way to force the physical position of the swap-file.
I have tried dd with the seek option wich allocates space without writing to the file. But it doenst work on a fat partition (resulting to a file full of zeroes).
Any Idea how to force the creation of a file starting at a specified cluster (or a near by position) ?
Thom
Click to expand...
Click to collapse
can I ask why you want to specify the cluster?
why do you need your swapfile to be in a certain place?

I want simulate wear-leveling on the free space of my FAT32-Partition to dramaticly extend the lifetime of my sdcard.
I have done some forensics on how dd reallocates free clusters and find out, that it preferable uses the space at the begin of the partition.
Currently I build "rotating" swap-files (names) every boot/reswap until free space is completely used. Then I delete all old swap-files so the next file will be created again at the begin of the partition.
I have about 10GB space left, so I would reach about Factor 70 of the "unknown" lifetime of my sdcard.
This is working but not very handy, because I have to delete old swap files if I need free space when the "wear space" is getting "full".
If I could force the start position of the swap file (probably by allocating only the FAT entries) I wont need these temp files permanently blocking the free space.
Anyy Idea ?

TheGenesis said:
I want simulate wear-leveling on the free space of my FAT32-Partition to dramaticly extend the lifetime of my sdcard.
I have done some forensics on how dd reallocates free clusters and find out, that it preferable uses the space at the begin of the partition.
Currently I build "rotating" swap-files (names) every boot/reswap until free space is completely used. Then I delete all old swap-files so the next file will be created again at the begin of the partition.
I have about 10GB space left, so I would reach about Factor 70 of the "unknown" lifetime of my sdcard.
This is working but not very handy, because I have to delete old swap files if I need free space when the "wear space" is getting "full".
If I could force the start position of the swap file (probably by allocating only the FAT entries) I wont need these temp files permanently blocking the free space.
Anyy Idea ?
Click to expand...
Click to collapse
ahh, I see now
tbh I thought wear-leveling was handled in firmware
Edit : nope, now I think about it I'm might getting it mixed up with SSD firmware

You are wasting your time. The SDCARD already does its own wear leveling.

I dont think so ... wear-levelling is integrated in the "drive"-electronic of modern usb-sticks and in solid-disk-drives (some communicating to the os at driver level).
I have not found any confirmation, that micro-sdcards own native wear-levelling. The customer support of A-Data did not respond to inquiries to this topic.
Do you have any reference, that confirms that wear-levelling is supported natively by any MICRO-sdcard ?
Regards
Thom

TheGenesis said:
I dont think so ... wear-levelling is integrated in the "drive"-electronic of modern usb-sticks and in solid-disk-drives (some communicating to the os at driver level).
I have not found any confirmation, that micro-sdcards own native wear-levelling. The customer support of A-Data did not respond to inquiries to this topic.
Do you have any reference, that confirms that wear-levelling is supported natively by any MICRO-sdcard ?
Regards
Thom
Click to expand...
Click to collapse
http://www.cs.ucr.edu/~amitra/sdcard/ProdManualSDCardv1.9.pdf

Related

SD card prepare tool[req]

hello all
just got an android and im still testing it. so please excuse my noobishness
question: is it possible to make a simple tool that runs on windows that would prepare and partition the sdcard with the three portions (fat32,ext2 and swap) and proper file system. is there something technically preventing such app of ever getting written. i know that some image burning software on widows can be used burn a cd/dvd that is not supported by the windows file system
if not, is it possible to write an android application to do all that. if so, anybody willing to write it
that would greatly simplify the process of installing the swap file enabled cooked roms. the current process is a bit messy
that is a great idea. I can do ext/2 or 3 with acronis disk director but I don't know how to do both and am nervous setting that up throught the phone although there is a really good guide on how to do that the phone.
Taken from http://forum.xda-developers.com/showthread.php?t=533731
How to partition your SD card from console (This requires the cyanogen recovery 1.3.1)
Example for my 8GB card.
Reboot and enter recovery (home+power) then go to console. Enter the below pressing "enter" after each line.
parted /dev/block/mmcblk0
print (to verfiy we know what size card we are dealing with. Mine was 8166 read below if yours is different)
rm 1 (if you had more than 1 partition you would want to rm them as well)
mkpartfs primary fat32 0 7526
mkpartfs primary ext2 7526 8038
mkpartfs primary linux-swap 8038 8166
quit
upgrade_fs
recovery
if your card isn't 8166 when you type print then you will need to modify those numbers to match your card size. You basically work back to figure out the totals. To figure it out, start with your cards total size. For example 8166 total Subtract 128 for swap (8038) minus 512 for ext (7526) the rest will go to fat32. Each partition starts where the other left off.
Click to expand...
Click to collapse
I personally have never tried this or don't know if this will help you but it was worth a shot.
xsnipuhx said:
Taken from http://forum.xda-developers.com/showthread.php?t=533731
I personally have never tried this or don't know if this will help you but it was worth a shot.
Click to expand...
Click to collapse
This is a perfect procedure.
THE GRIZZ said:
hello all
just got an android and im still testing it. so please excuse my noobishness
question: is it possible to make a simple tool that runs on windows that would prepare and partition the sdcard with the three portions (fat32,ext2 and swap) and proper file system. is there something technically preventing such app of ever getting written. i know that some image burning software on widows can be used burn a cd/dvd that is not supported by the windows file system
if not, is it possible to write an android application to do all that. if so, anybody willing to write it
that would greatly simplify the process of installing the swap file enabled cooked roms. the current process is a bit messy
Click to expand...
Click to collapse
http://forum.xda-developers.com/showthread.php?t=534043
Keep an eye on that tool. If you look at this to-do list, it looks like automatically partitioning your sdcard is next up. But the procedure above is simple, and it works now if you don't wanna wait.
xsnipuhx said:
Taken from http://forum.xda-developers.com/showthread.php?t=533731
I personally have never tried this or don't know if this will help you but it was worth a shot.
Click to expand...
Click to collapse
It's a good way but you should subtract 32 for linux-swap. 128 for linux-swap is WAY to big.
h.nocturna said:
http://forum.xda-developers.com/showthread.php?t=534043
Keep an eye on that tool. If you look at this to-do list, it looks like automatically partitioning your sdcard is next up. But the procedure above is simple, and it works now if you don't wanna wait.
Click to expand...
Click to collapse
thanks thats exactly what i was talking about. i already partioned it using one of the guides. a simpler method cant hurt though
It is a great idea, the problem is that none of the tools for partitioning on windows are free. Maybe it would be possible to make a GUI that feeds commands to parted on the phone using adb? I don't know, I don't see what's wrong with booting in to gparted, seems like less troube and it's has a GUI.
Eh, 3-4 commands in Terminal isn't gonna kill anyone, but it might intimidate the noobs here and prevent them from fully enjoying their phone cuz they stop as soon as they see a wall of text.
h.nocturna said:
Eh, 3-4 commands in Terminal isn't gonna kill anyone, but it might intimidate the noobs here and prevent them from fully enjoying their phone cuz they stop as soon as they see a wall of text.
Click to expand...
Click to collapse
You're completely right, if people never use it they will always be scared of the terminal =P
Bah, if everyone used linux they could just use gparted, another easy way.
I used the cmd line I quoted early to ready a 8gb sd card for apps2sd and I just left out the linux swap part and it worked MINT. But if your scared of the terminal, try using the apps2sd app on the market and that will get your sd card ready.

tutorial link please

FINALLY got cyanogen rom working. i've almost pulled my hair out over buying this phone(att user so i had to unlock and learn root, etc.)
anyways, got .999 installed and saw the * Apps2SD is automatic! All you need is a second partition (ext).
can someone point me in the right direction on how to do the partition part? i have full version of paragon and know how to use it but just don't want to fubar anything up.
i apologize for the noob question but i just need to know what to set my 2gb(although i have a 4gb class 6 in the mail now) sd card to what size partitions so i can run the add2sd.
thanks guys and love the site.
There is a sticky post in this section. I found it in less than 2 seconds. without searching.
blackinches said:
FINALLY got cyanogen rom working. i've almost pulled my hair out over buying this phone(att user so i had to unlock and learn root, etc.)
anyways, got .999 installed and saw the * Apps2SD is automatic! All you need is a second partition (ext).
can someone point me in the right direction on how to do the partition part? i have full version of paragon and know how to use it but just don't want to fubar anything up.
i apologize for the noob question but i just need to know what to set my 2gb(although i have a 4gb class 6 in the mail now) sd card to what size partitions so i can run the add2sd.
thanks guys and love the site.
Click to expand...
Click to collapse
Example for 8GB card.
Reboot and enter recovery (home+power) then go to console. Enter the below pressing "enter" after each line.
Code:
parted /dev/block/mmcblk0
print (to verfiy we know what size card we are dealing with. Mine was 8166 read below if yours is different)
rm 1 (if you had more than 1 partition you would want to rm them as well)
mkpartfs primary fat32 0 7622
mkpartfs primary ext2 7622 8134
mkpartfs primary linux-swap 8134 8166
quit
upgrade_fs
recovery
NOTE: this will reformat your entire card, so i suggest you back up your files.
and btw tell me the size of your sd card and i will type up the code for you...
use this method to tell me your exact size
go into recovery via home+power
go to console
pres enter
type:
parted /dev/block/mmcblk0
print
i am pretty sure you can see what number represent your total card size.
Easier Way!!!
OK,so I also have Paragon Partition Manager 9.0 Special Edition.
1.Go into your Paragon Partition Manager Software
2.Click on Partition Manager at the first screen
3.Click on your SD Card drive (ie. F:/)
4.Click on create partition in the left hand side of your screen.
5.It will ask you how big you would like your partition to be,then what type of partition. Paragon only supports EXT2 and EXT3 if your looking for an EXT partition. Paragon also only supports Linux-Swap2 and not Linux-Swap3.
If you need any more help man let me know.
Follow me on Twitter: http://twitter.com/andy_lowe02
andy_lowe02 said:
OK,so I also have Paragon Partition Manager 9.0 Special Edition.
1.Go into your Paragon Partition Manager Software
2.Click on Partition Manager at the first screen
3.Click on your SD Card drive (ie. F:/)
4.Click on create partition in the left hand side of your screen.
5.It will ask you how big you would like your partition to be,then what type of partition. Paragon only supports EXT2 and EXT3 if your looking for an EXT partition. Paragon also only supports Linux-Swap2 and not Linux-Swap3.
If you need any more help man let me know.
Follow me on Twitter: http://twitter.com/andy_lowe02
Click to expand...
Click to collapse
well i wouldnt say ur way is easier... it does require using a computer, mine uses the phone.. and mine is simply typing what u see.
Also im pretty sure you need to use linux-swap and not linux-swap2
(i think 2 works but im not sure that its recommendable sicne the rom cookers themeselves use 1)
I would also use the method brian posted. its much more effective
thanks guys, i got adds2sd working and everything. on a 1gb right now until my new 4gb class 6 comes in this week.
i haven't done the swap things yet as i'm not sure of them just yet. i've learned quite a bit over the last week without trying to bug too many people on the forum. your replies are MUCH appreciated.
what is the different between ext 2/3 and linux-swap? i'm running my current 1gb 514mb fat32 and 445mb ext3.
ext3 has journaling which reduces corruption a lot. linux-swap is used as virtual memory.
thanks for the reply so in turn the swap will make the phone run faster right?
also, since no one answered my question in another thread:
although i'm running .999 when i press the camera button it open a box with a 'To:' entry and 3 button 'open', 'call', and 'send'.
i've looked in the settings to see if i can change what the camera button does(want it to open the camera like before obviously) without any luck..
any idea?
Click to expand...
Click to collapse
any ideas?
thanks again
blackinches said:
thanks for the reply so in turn the swap will make the phone run faster right?
also, since no one answered my question in another thread:
Click to expand...
Click to collapse
In theory swap should make it faster as it has more memory to play with.
For your other question, a file on the ROM containing the keymaps has been changed. The only way to change what the camera button does is pull it, edit it, and push it back.
AdrianK said:
In theory swap should make it faster as it has more memory to play with.
For your other question, a file on the ROM containing the keymaps has been changed. The only way to change what the camera button does is pull it, edit it, and push it back.
Click to expand...
Click to collapse
oh boy, i tried to avoid the adb stuff as i had a few problems with it. wonder how it got 'changed'.
i'll give it a try sometime.

Linux-swap Cynanogen?

ok so i made a linux-swap partion on my sd card that is 64mb. Now do i need to activate it somehow? or does cynogen do it for me? i tried to search but couldnt find. also do i need update my radio? it is 2.22.19.26I
You need user.conf and userinit.sh files on your ext partition. There's a guide on how to set that up here.
ok and can i have compcache and linux-swap at the same time? or do they do the same thing? also do i need to make a partion for compcache? and i cant find the htc keyboard in 4.2.3.1, does it come with it?
i thought if you have 4.2.3.1 you didnt have to add the files as it does everything for you? am I missing something.
is compcache and linux swap the same thing? and do we need both?
nahanee20 said:
is compcache and linux swap the same thing? and do we need both?
Click to expand...
Click to collapse
lol, no.
Swap is virtual memory. It uses a seperate partition to act as extra RAM, but it's nowhere near comparable to real RAM.
Compcache compresses what's in the RAM, so there's more space to cram files in. The problem is constantly compressing and decompressing files in RAM puts a heavy strain on the CPU.
so do i need to put the usernit files on or did this rom already do it?
does anyone know how to use the user.config app to do this?
nahanee20 said:
does anyone know how to use the user.config app to do this?
Click to expand...
Click to collapse
You DO NOT have to add any user int files to your sd for swap to work.
Its already rolling if you installed correctly.
go to terminal and use the print command to view your allocated spaces for each ext
Better yet, use the "free" command to see if it is really being used. I am pretty sure Cynanogen does not use a swap partition by default. It needs to be enabled. A easy way to check and setup your swap it to download swapper.
When I type free in the terminal I see 0 for total, used and free swap. I made an ext4 and a 32mb swap partition on my sd card. How do I enable swap on Cyanogen 4.2.5?
beav_35 said:
When I type free in the terminal I see 0 for total, used and free swap. I made an ext4 and a 32mb swap partition on my sd card. How do I enable swap on Cyanogen 4.2.5?
Click to expand...
Click to collapse
search user.conf app on market

[Q] [Webtop] Next steps: More space or newer Ubuntu? (Poll effectively closed)

----- Announcements -----
The poll is now being treated as closed. As such, since I would be unlikely to look back after moving to a newer Ubuntu, and since the two efforts are effectively incompatible (unless I wanted to try my hand at flashing a new /osh which... no), I'm concluding that there are enough users who are happy enough staying on Ubuntu 9.04 that I'll work on the union filesystem first before moving on to newer versions of Ubuntu.
----- Your regularly scheduled post below. -----
I believe I'm getting close to having a reasonable "first pass" of having a working Ubuntu on the Atrix. The interesting question becomes: what next? There are two steps I can see right now:
Get a FUSE kernel module working so that we can get a union mount for our modified Linux so that we can have more effective space. Note: this process is almost guaranteed not to work with the next option.
Now that source code is available for the Ubuntu files (I need to find out if we have everything we need, mind you), port newer releases of Ubuntu (starting with either 9.10 or 10.04).
Users, what would you like to see? The numbers at "closing" were 48/47/3.
i think it would be cool to see a 10.04 ubuntu - but what can be done with that without very much effective space? if you could find a way to expand the storage with an ubuntu port (even if it's after you port ubuntu, then find a way to increase storage) i think that makes more sense than trying to improve the inherently crippled current webtop setup
It would be great to see more storage! That is the biggest limitation at this point..
im all for 10.04 or 10.10
Wouldn't you require more space for this though?
seven2099 said:
Wouldn't you require more space for this though?
Click to expand...
Click to collapse
Not really. Remember that the 1 GB filesystem file is a copy of the partition that Motorola ships. Upgrading would be swapping out Ubuntu 9.04 packages for Ubuntu x.yy packages, so it would be a matter of trading space, not strictly losing it.
Sogarth said:
Not really. Remember that the 1 GB filesystem file is a copy of the partition that Motorola ships. Upgrading would be swapping out Ubuntu 9.04 packages for Ubuntu x.yy packages, so it would be a matter of trading space, not strictly losing it.
Click to expand...
Click to collapse
Forgive my stupidity but... you are reffering to the 1gb file called Ubuntu.disk right?
Meaning, I can move that to SD to leave more space internally?
seven2099 said:
Forgive my stupidity but... you are reffering to the 1gb file called Ubuntu.disk right?
Meaning, I can move that to SD to leave more space internally?
Click to expand...
Click to collapse
I'm pointing out that ubuntu.disk is 1 GB, but once it's created, it has no reliance on /osh. So as long as the Ubuntu x.yy installation is < 1 GB like the current 9.04 installation is, the space issue won't get any worse. No better, though.
And, no, moving ubuntu.disk to /mnt/sdcard won't work. If it did, I would have created a partition on the SD card to start with.
NUKE webtop and make it run ubuntu Pure ubuntu with the option to show it on the atrix screen too HEHE !
union mount! Also I bet this has non-ubuntu implications (internal and sd card as 1 mount point would be hot). Also why do we need a newer version other than to say "i have ubuntu x now which version number is greater than y was". What features are there in 10 over 9?
tical2k said:
Also why do we need a newer version other than to say "i have ubuntu x now which version number is greater than y was". What features are there in 10 over 9?
Click to expand...
Click to collapse
I dunno. Minor things like Firefox 4, chromium browser, stuff like that.
once again... what was wrong with firefox 3 other than 4 > 3? just being the devil's advocate here.
tical2k said:
once again... what was wrong with firefox 3 other than 4 > 3? just being the devil's advocate here.
Click to expand...
Click to collapse
You're asking somebody who's typing this from IE9, so I can't help you there. But, interest seems high, and it is true that newer software isn't available as easily for older versions of the operating system.
Would it be possible to move it to SD card if there was an ext2 partition there? For example, on my 16gb SD card, have a 14gb fat32 partition, then a 2gb ext2 partition, with your mod mounting the latter instead of a file on /data.
I started playing with this idea yesterday, but ran out of time before I got it to mount properly in Android... Do you think it's feasible?
Sent from my MB860 using XDA App
lindsaytheflint said:
Would it be possible to move it to SD card if there was an ext2 partition there? For example, on my 16gb SD card, have a 14gb fat32 partition, then a 2gb ext2 partition, with your mod mounting the latter instead of a file on /data.
I started playing with this idea yesterday, but ran out of time before I got it to mount properly in Android... Do you think it's feasible?
Click to expand...
Click to collapse
From the been there, done that file, no, it's not feasible at this point in time. Sorry.
..................
Sogarth said:
From the been there, done that file, no, it's not feasible at this point in time. Sorry.
Click to expand...
Click to collapse
Ah I see... What about symlinking a whole lot of stuff over to /cache, since it's a 600mb partition doing not much? I'm guessing you've probably tried that avenue too?
Sent from my MB860 using XDA App
molotof said:
NUKE webtop and make it run ubuntu Pure ubuntu with the option to show it on the atrix screen too HEHE !
Click to expand...
Click to collapse
Actually, here's a question: based upon a link another user pointed out, the other Linux loaders use VNC to display the Linux desktop on their Android screen. That's not enough?
lindsaytheflint said:
Ah I see... What about symlinking a whole lot of stuff over to /cache, since it's a 600mb partition doing not much? I'm guessing you've probably tried that avenue too?
Click to expand...
Click to collapse
No, actually, since the initial idea didn't involve use FUSE to be able to do crazy filesystem tricks. I thought /cache was needed, though? If we can find space here and there, it might be possible to decrease the footprint in /data a bit so that people aren't squeezed so tightly on space.
Sogarth said:
No, actually, since the initial idea didn't involve use FUSE to be able to do crazy filesystem tricks. I thought /cache was needed, though? If we can find space here and there, it might be possible to decrease the footprint in /data a bit so that people aren't squeezed so tightly on space.
Click to expand...
Click to collapse
/cache is only used for temp downloads (market apk installs, email attachment previews, etc) and OTA updates. The temp downloads don't take up much space - less than 50mb usually, but the OTA updates would probably be a a bit bigger. But who uses those right?
I'm one of those greedy people who have over 1gb of junk on their /data partition

[DEV-HINT] Implementing a swap partition or swap file for new and old bootloader

[DEV-HINT] Implementing a swap partition or swap file for new and old bootloader
Wikipedia defines swap file (or paging) as: "[..] use disk storage for data that does not fit into physical random-access memory (RAM)."
With CM10 or CM10.1 around, the 'about phone' screen usually shows 343 MB of usable RAM on the LG-P990, so one gets ideas. With CM9 it was a bit better, but still.... Take Chrome for example: nice to the eye, but not so nice to the RAM of devices that have been around a lot longer than the Nexus 4 with its whopping two Gigabytes. So what's the catch with swap? For example, a HDD swap partition on a PC offers some sort of relief when RAM is scarce by moving some parts of the RAM (pages) to the HDD and moving them back when it needs it. Of course, it comes for a price: performance! But it works. So why not using it on Android too? To hell with the fact that virtual RAM on the internal memory card is a lot slower than physical RAM, there are times when it would be just nice to have the extra megabytes at hand.
Were you a bit envious too when you saw that the 'new' partition layout that came with the ICS bootloader on our beloved LG-P990 had a swap partition included? Well, I was. I even changed to a customized layout to get one for a little while too... But that is not really necessary. Never was, actually. I came back to the original layout and old bootloader weeks ago. What still bugged me was the missing swap partition. CM10.1, CM10 or even CM9 could really use swap from time to time but commonly don't use it.
So, is there really a big difference between the two partition layouts? Yes, but regarding the swap it doesn't count. In fact, the situation for both user groups is pretty much the same: both do not use any kind of swap space whatsoever. First, there are the users with the new bootloader. They have the swap partition but actually don't make use of it. As compared with users with the old bootloader: they may not have the swap partition on their partition table but even they can easily implement a solution very similar to a standard swap partition: a swap file. Then they can benefit as well from some extra Megabytes in certain low memory situations. You don't have a swap partition/file in use yourself yet? In just a few minutes you can change that no matter what bootloader you have.
First you have to find out which bootloader/partition layout is on your LG-P990:
here is how you determine your bootloader/partition layout: reboot!
If you see a pink LG logo when the phone boots then you have the new bootloader/new partition layout (ICS)
If you see a white LG logo when the phone boots then you have the old bootloader / old partition layout(GB)
All commands used in the terminal are shown with a '$'-sign or '#'-sign (root). Copy just the commands without the signs to the terminal, unless stated otherwise.
New bootloader/partition layout (ICS) - Pink LG logo as splash screen - You have the old bootloader/partition layout? Skip to the second part below.
If you are using the new partition layout, then it is easy to use the swap mechanism. The 350MB swap partition is just waiting for you to be switched on.
Use 'adb shell' or the terminal:
check the situation with
Code:
$ free
Does it show 0 0 0 in the swap line? Then swap is not working at the moment and has to be switched on.
Use
Code:
$ su
to get superuser rights
Make the swap partition usable (Be extra careful! Triple-check the command!)
Code:
# mkswap /dev/block/mmcblk0p4
Switch it on
Code:
# swapon /dev/block/mmcblk0p4
Change swappiness to zero at runtime
Code:
# sysctl -w vm.swappiness=0
To keep the swap partition switched on, after reboot and even after flashing ROM updates
create the file /data/local/userinit.sh
Put these lines inside (with the '#' sign)
Code:
#!/system/bin/sh
swapon /dev/block/mmcblk0p4
sysctl -w vm.swappiness=0
swappiness=0 lets the kernel use the swap partition only when there is no more physical RAM left.
Save the file.
Now reboot.
Check it via adb shell or terminal if it is working.
Code:
$ free
The swap line should show that 350 MB are available (total/free).
Check the swappiness with
Code:
$ cat /proc/sys/vm/swappiness
It should show 0 now.
Testdrive your work. Start Chrome or a game or whatever uses a lot of RAM on your system. Use it heavily and then check the swap usage of your kernel again with a final
Code:
$ free
Just try it!
Old bootloader/partition layout (GB) - White LG logo as splash-screen
The task is to create a 128 MB Swap-File on the data partition. 128 MB seems enough since it is just for memory emergencies. And it's best to create it on the data partition and not on the sdcard because of the USB mass-storage support that would interfere with any swap file on sdcards. By the way, it doesn't format your data partition. It just makes your usable space of the data partition 128 MB smaller than it is right now. Basically, it creates an empty file with the fixed size of 128 MB and makes it usable as a swap 'partition'. It has the same functionality as a swap partition. And the same speed. And everything else. It just doesn't reside in its own partition. It is even better: when you don't want it anymore or change the size of it, just stop the swap-file with 'swapoff' and delete the file 'swapfile' in your data partition and it's gone for good. Immediately you can use the freed-up space for something else.
Use 'adb shell' or the terminal:
check the situation with
Code:
$ free
Does it show 0 0 0 in the swap line? Then it is not working at the moment and has to be switched on.
See with
Code:
$ df
whether there is enough free space left on /data. 200 MB or more should be free on /data. 128 MB will be used.
Get superuser rights
Code:
$ su
Optional: To see more interesting memory stats you can use
Code:
# cat /proc/meminfo
Now create the file named 'swapfile' with the size of 128 MB
Code:
# dd if=/dev/zero of=/data/swapfile bs=1024 count=128000
This can take a moment.
Limit the rights of the swapfile
Code:
# chmod 600 /data/swapfile
now set up the swapfile for swap usage
Code:
# mkswap /data/swapfile
Switch it on
Code:
# swapon /data/swapfile
Hint: switch off would be swapoff /data/swapfile
Now it is already working!
Tune it to your needs: we just want the swap file to be used in emergencies when there is no RAM left anymore and Android would turn Project Butter in Project Stutter.
Check the status of swappiness
Code:
# cat /proc/sys/vm/swappiness
Default is 60. That is much too high. swappiness=0 lets the kernel use the swap file only when there is no more physical RAM left.
Change it to zero
Code:
# sysctl -w vm.swappiness=0
With this sysctl command you can change the swappiness setting (0-100) on runtime.
If you want to make these settings permanent no matter if you reboot or even flash a ROM update without wiping data then
create the file /data/local/userinit.sh
Put these lines inside (with the '#' sign)
Code:
#!/system/bin/sh
swapon /data/swapfile
sysctl -w vm.swappiness=0
Save it.
Reboot and check it with a last
Code:
# free
in terminal. Now testdrive your swap file with two browsers and a game simultanously or whatever suits your needs to stress your P990.
Just try it yourself!
Have fun!
and another awesome dev thread by Raum1807 :good:
Interested in making a flashable zip out of it? If not I could do it next week.
Just adding everything into one sh-file which gets called by the updater-script - or just via the Terminal.
tonyp said:
and another awesome dev thread by Raum1807 :good:
Interested in making a flashable zip out of it? If not I could do it next week.
Just adding everything into one sh-file which gets called by the updater-script - or just via the Terminal.
Click to expand...
Click to collapse
Thanks for the offer. Thought about that, too. But I think it is more interesting to understand what we are doing here by following it step-by-step. A script makes it too easy... Maybe later, we will see.
sorry for this dumb question.
what's the difference between using this method and using roehsoft ram expander?
both of them have the option to change swappiness and to enable/disable swap from sdcard (roehsoft ram expander can even choose ext sd as swap location)
i don't get it :silly:
old bootloader:
/data/swapfile # that's internal sd right?
wouldn't it be better to use external sd for swapping as swapping heavily might in the long run kill a flash drive?
derEremit said:
old bootloader:
/data/swapfile # that's internal sd right?
wouldn't it be better to use external sd for swapping as swapping heavily might in the long run kill a flash drive?
Click to expand...
Click to collapse
i don't think so, AFAIK the max reading speed for ext sd is 10 MBps, which is lower than reading speed in our int sd (about 13 MBps). that's why using int one for swapping would be a better choice
please CMIIW, i'm still noobs in this kind of stuff. though, i just want to share what i know
I have one point to this.
You write "swappiness=0 lets the kernel use the swap partition only when there is no more physical RAM left."
But there is every time some free space on RAM, because android never let decrease memory to zero.
babi_perang said:
sorry for this dumb question.
what's the difference between using this method and using roehsoft ram expander?
both of them have the option to change swappiness and to enable/disable swap from sdcard (roehsoft ram expander can even choose ext sd as swap location)
i don't get it :silly:
Click to expand...
Click to collapse
- Doesn't use the external sdcard
- Doesn't cost 7 Euro
- gives you an idea how things work
Sent from my LG-P990 using xda app-developers app
derEremit said:
old bootloader:
/data/swapfile # that's internal sd right?
wouldn't it be better to use external sd for swapping as swapping heavily might in the long run kill a flash drive?
Click to expand...
Click to collapse
Swapping is only happening when the RAM is critically low. Btw, the swap partition of the ICS partition layout is also located on the internal memory. No difference so to speak. Using this method shouldn't harm the internal memory at all.
Sent from my LG-P990 using xda app-developers app
tomsi91 said:
I have one point to this.
You write "swappiness=0 lets the kernel use the swap partition only when there is no more physical RAM left."
But there is every time some free space on RAM, because android never let decrease memory to zero.
Click to expand...
Click to collapse
Yes, the memory management of Android tries to keep the RAM clean while keeping the last few opened apps in the RAM. Four or five running CM10.x on the P990. But the less RAM you have on your phone the harder this balance gets. Imagine memory eating apps like Gallery/Camera or Chrome. They benefit from more memory being available.
Sent from my LG-P990 using xda app-developers app
Thank you for this helpful guide! It is so easy to make it. And now I know a bit much more about Android and RAM.
Gesendet von meinem LGP990 mit CM10.
Hey! This seems interesting but i have a question , before doing this we have 343 RAM available and after all this trouble only 350 ? so thats 7more RAM or am i missing something ?
Soare23 said:
Hey! This seems interesting but i have a question , before doing this we have 343 RAM available and after all this trouble only 350 ? so thats 7more RAM or am i missing something ?
Click to expand...
Click to collapse
Yes, you forgot to read the original post that explains what exactly swap is:
So what's the catch with swap? For example, a HDD swap partition on a PC offers some sort of relief when RAM is scarce by moving some parts of the RAM (pages) to the HDD and moving them back when it needs it. Of course, it comes for a price: performance! But it works. So why not using it on Android too? To hell with the fact that virtual RAM on the internal memory card is a lot slower than physical RAM, there are times when it would be just nice to have the extra megabytes at hand.
Click to expand...
Click to collapse
The reported RAM will remail the same because you aren't increasing your physical RAM.
When i try to creat a swap file, this Error appears:
/def/zero/: canot open for read: Not directory
I'm a superuser
---------- Post added at 09:20 PM ---------- Previous post was at 09:13 PM ----------
After disconnecting from computer it worked!
Swappiness=0 doesn't stick for me after reboot It returns to 60 everytime.
@Raum1807
Awesome thread. Thanks for kindly explaining everything. I learned a lot here!
Ajsh said:
Swappiness=0 doesn't stick for me after reboot It returns to 60 everytime.
Click to expand...
Click to collapse
just put:
echo "0" > /proc/sys/vm/swappiness
at the end of a .sh file in init.d
As we´re talking about using the wasted Swap-Partition:
Is it possible to use it as a "new" kind of Ramhack?
As for now we cut off some shared Ram of GPU to use it as normal RAM. What if we let the GPU use the Swap-Partition as its Memory and get all physical RAM available?
GPU will not perform as good as now, but some People don´t need a Phone to play Games...
Is this possible or restricted to some Nvidia-Libs that are Closed-Source??
zerocoolriddler said:
As we´re talking about using the wasted Swap-Partition:
Is it possible to use it as a "new" kind of Ramhack?
As for now we cut off some shared Ram of GPU to use it as normal RAM. What if we let the GPU use the Swap-Partition as its Memory and get all physical RAM available?
GPU will not perform as good as now, but some People don´t need a Phone to play Games...
Is this possible or restricted to some Nvidia-Libs that are Closed-Source??
Click to expand...
Click to collapse
This is interesting... it could really make a difference , only if it works tho heh.
Sent from my LG-P990 using xda app-developers app
Can we have both Swap and Zram on in CM 10 ? Any possible side effects

Categories

Resources