Howto Enable Swap - G1 Q&A, Help & Troubleshooting

I used the method to enable swap in Linux and it works like designed.
I used Amon_RA Recovery 1.52 to partition my SDCARD and the new recovery lets you choose the size of your partitions.
So I created a 256MB Swap.
From a console/terminal do the following after creating your swap partition the size you want it:
Type each line below in order and hit enter after each in the terminal.
mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
mkswap /dev/block/mmcblk0p3
echo "swapon -a" >> /system/etc/init.d/05userinit
echo "/dev/block/mmcblk0p3 swap swap" >> /system/etc/fstab
reboot
This works on all roms i have run into. It does help the performance on the memory hobbled G1.
Once you have rebooted go back into a terminal and run the "free" command. You should see that you have a working swap partition.
TGA_Gunnman
The UNIX Dude

Related

[SOLVED]help creating persistent swap partition.

I am using CyanogenMod v3.6.8.1 and I decided I wanted a swap partition.
I partitioned my 2GB SD with a 32MB swap partition and formatted using gparted.
From the shell (using adb) I remounted /dev/block/mtdblock3 with rw and edited /system/etc/fstab and added a line for the swap. Here is what the entire file looks like now:
Code:
/dev/block/mtdblock3 /system yaffs2 rw
/dev/block/mtdblock4 /cache yaffs2 rw
/dev/block/mtdblock5 /data yaffs2 rw
/dev/block/mmcblk0p1 /sdcard vfat rw
/dev/block/mmcblk0p2 /system/sd auto rw
/dev/block/mmcblk0p3 none swap sw
/system/modules/modules.sqf /system/modules squashfs ro,loop
/system/xbin/xbin.sqf /system/xbin squashfs ro,loop
I can turn on the swap with 'swapon -a' which works and shows up in /proc/swaps and with the 'free' command, but upon boot, swap isn't activating.
I'm not really familiar with the android init scripts, so I'm not sure how I can enable the swap automatically upon boot. Any advice would be appreciated.
Okay I fixed it.
I downloaded one of Drizzy's roms that I know use swap, extracted, and searched for 'swap' in all the files. I found it in /system/bin/a2sd at the end. Here is what's there:
Code:
if [ -n /dev/block/mmcblk0p3 ];
then
mkswap /dev/block/mmcblk0p3;
fi;
if [ -e /dev/block/mmcblk0p3 ];
then
echo 30 > /proc/sys/vm/swappiness;
swapon /dev/block/mmcblk0p3;
fi;
The first if doesn't make sense to me as it's a string test which will always be true, so I got rid of it and just kept the test for the file existing, but I changed it to -b to be a little more specific (to see if it's a block device), and I commented out the swappiness change to leave it at default.
Im using same rom and i woild love to do this but is there any other way as im totally unfamiliar with adb
turboyo said:
Im using same rom and i woild love to do this but is there any other way as im totally unfamiliar with adb
Click to expand...
Click to collapse
I just used adb because I can use the copy/paste function of my gnome terminal and it's easier than using the shell on the phone itself.
Here is what is needed:
Get into a root shell, either on the phone or using adb.
Code:
mount -t yaffs2 -o rw,remount /dev/block/mtdblock3 /system
vi /system/bin/a2sd
press capital G which will take you to the bottom of the file
press lower case o which will open a line below your cursor for editing.
type in the following:
Code:
if [ -b /dev/block/mmcblk0p3 ];
then
echo 30 > /proc/sys/vm/swappiness;
swapon /dev/block/mmcblk0p3;
fi;
press escape to exit insert mode (I read that in the terminal emulator you have to hold the trackball and press 1 for esc)
type :wq and press enter.
exit terminal and reboot. To see if it's working, get back into a terminal and use the command 'free'
you can also do 'swapon -a' instead of specifying the swap partition itself. Note that the above example uses the third partition of the SD card as the swap.
This also assumes you have already created the swap partition and formatted it as swap.
You can omit the swappiness line to leave it at the linux default of 60.

is there a way to format ext3 partition (app2sd) from g1 phone or from recovery mode

help please .. paragon partitiion is not working
wc326 said:
help please .. paragon partitiion is not working
Click to expand...
Click to collapse
-repeatedly bangs head against wall-
follow this guide but in the beginning where it says use adb and type adb shell
just be in recovery console and hit enter then from there out all the commands should be the same.
if you need more help pm me and i will walk you through the steps
cant; do itr without adb ??
wc326 said:
help please .. paragon partitiion is not working
Click to expand...
Click to collapse
turn phone off and boot into recovery via home+red key
go to console and type in
# mount -o rw /dev/block/mmcblk0p2 /system/sd
# cd /system/sd
# rm -rf /system/sd/*
# reboot recovery
this has been covered many times in many other threads
NOTE:dont type in the # signs. but do however type in the * sign.
go to recovery console hit enter
parted /dev/block/mmcblk0
print
the fourth line in the 'print' command output shows you the total size of sdcard in MB(or GB if you card is large)..mine says: Disk /dev/block/mmcblk0: 7969MB
use this number(XXXXMB) and do some simple math to get the size of your partitions.
7969MB - 32MB linux-swap = 7937MB
7937MB - 500MB ext2 = 7437MB fat32
32MB seems to be alright size for swap, though it can be lower depending on your sdcard size.
500 MB is a good round number for the ext2 partition...no need for more.
that leaves us with 7437MB for fat32 storage.
Click to expand...
Click to collapse
if you do not want linux-swap then do not figure it in
after figuring out the size of your partitions from using the above method type rm 1 (if you only have one partition skip next part) then rm2
then to make the partitions type (numbers are from above example substitute your own in)
mkpartfs primary fat32 0 7437
mkpartfs primary ext2 7437 7937
mkpartfs primary linux-swap 7937 7969 (only if you want linux-swap)
then type print again to see if it worked. if it did you will have 1 and 2 (and 3 if you want linux-swap) come up under all the other info.
then type quit
then to upgrade to ext3 type upgrade_fs
then if apps2sd is automatic in your rom of choice reflash it and you are set. i am too nice tonight.
brian_v3ntura said:
turn phone off and boot into recovery via home+red key
go to console and type in
# mount -o rw /dev/block/mmcblk0p2 /system/sd
# cd /system/sd
# rm -rf /system/sd/*
# reboot recovery
this has been covered many times in many other threads
NOTE:dont type in the # signs. but do however type in the * sign.
Click to expand...
Click to collapse
too bad its not that simple. i think he means partitioning since he references not having adb to do the partitioning in the guide i linked him to. (sorry for assuming your gender OP)
i just want to format my ext3 app2sd partition....
it already has fat32 , ext 3 , and linus swap
really only want to format ext3 partition so i can install my new rom
just wondering can you format ext3 partition without havn'ing to erase fat32 and linus swap
david1171 said:
too bad its not that simple. i think he means partitioning since he references not having adb to do the partitioning in the guide i linked him to. (sorry for assuming your gender OP)
Click to expand...
Click to collapse
actually its clear as day that he means he JUST wants to format his ext.
wc326 said:
is there a way to format ext3 partition (app2sd) from g1 phone or from recovery mode
help please .. paragon partitiion is not working
Click to expand...
Click to collapse
paragon partition is aprogram that will enable you to partition your card on your computer and format.
wc326 said:
i just want to format my ext3 app2sd partition....
it already has fat32 , ext 3 , and linus swap
really only want to format ext3 partition so i can install my new rom
just wondering can you format ext3 partition without havn'ing to erase fat32 and linus swap
Click to expand...
Click to collapse
THIS IS WHAT YOU NEED TO DO to format ext. the other guy must've confused u
turn phone off and boot into recovery via home+red key
go to console and type in
# mount -o rw /dev/block/mmcblk0p2 /system/sd
# cd /system/sd
# rm -rf /system/sd/*
# reboot recovery
NOTE:dont type in the # signs. just push enter when done typing each line. and be sure to type everything exact and carefully.but do however type in the * sign.
errr wrong post

Clear a partition

I'm looking to delete all the data and subfolders in my partitions ext3 and linux-swap, start fresh.. i dont feel like going through that long procedure of removing the actual partitions and then re-adding and allocating the blocks.
I don't use adb, i just use the console from cyanogen's recovery page. i just starting learning all of this fun linux stuff when i got my dream a few months back =P
So what's the commands to mount, then clear the info on the partitions including all sub folders?
TIA!
Boot into recovery home+power
Go to console ALT+X
type:
(press enter)
#
# mount -o rw /dev/block/mmcblk0p2 /system/sd
# rm -rf /system/sd/*
# reboot recovery
Much thanks! worked great.

Question about first time Swap setup....

i am interested in creating a SWAP partition on my sd card to increase rom speed, even tho CMs roms are preety fast already. I hav e 8gb CD with about 500mb ext2. now if i use this method to create Swap partition:
Reboot and enter recovery
Enter console
#parted /dev/block/mmcblk0
#print (to verfiy we know what size card we are dealing with, the details should be straight forward)
rm 1
rm 2
mkpartfs primary fat32 0 7200
mkpartfs primary ext2 7200 7700
mkpartfs primary linux-swap 7700 7732
#print (to verify we have the 3 partitions)
i know how to backup music and everything on fat32 to my PC(to later restore) because doing the above will reformat entire card.
my question is do i need to back up my ext2 with all my apps and data on it, and if so how? or will it do everything itself when i reboot my CM rom? i am trying to create this swap partition without really changing everything and without wiping
There are quite a few threads on this, but granted they aren't that easy to find (I'm looking at you, people who name their threads "PLZ HELPPPPP!!")
boot in to recovery and go to the console:
cd sdcard
mkdir app
mkdir app-private
cp /system/sd/app/* /sdcard/app/
cp /system/sd/app-private/* /sdcard/app-private/
All your apk's are now on your Fat partition, copy those two folders to your computer
after you have remade the partitions go back to the recovery console (don't do this in terminal, but you can use adb shell when the phone is in recovery mode). This time we have to mount your new ext partition as rw.
mount -o rw /dev/block/mmcblk0p2 /system/sd
cd /system/sd
mkdir app
mkdir app-private
cp /sdcard/app/* /system/sd/app/
cp /sdcard/app-private/* /system/sd/app-private/
You're done. expect your phone to take a few minutes to boot up as it re-creates the dalvik-cache.

[Q] Moving Linuxswap to NAND

Hello. i wanted to know if anybody has tried moving your swap to your data or cache partition on your phone since it's faster then sd. I found this and i'm guessing you could remount your your cache as swap instead of sdcard.
i'm new to the android/linux thing and this site, but this has really helped alot!
There's some smart mofo's and TONS of info on here.
i found this more or less. This is a mixture of threads
Enable swap:
mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
mkswap /dev/block/mmcblk0p3
echo "swapon -a" >> /system/etc/init.d/05userinit (on my phone it was 20userinit)
echo "/dev/block/mmcblk0p3 swap swap" >> /system/etc/fstab (i didnt have fstab, use > instead)
reboot
Move swap to data:
mkdir /data/swap
echo "ln -s /data/swap mtdblk0p3" >> /system/etc/init.d/??userinit (whatever it is on your phone)
so i guess this thread can be deleted. sorry
Please Read Carefully!
Do NOT, I repeat DO NOT put swap on the phone's nand. Swap is accessed very often and causes further wearing of the NAND chips.This is why it was never implemented before, it can end up killing the chip completely, you're better off leaving it on the SD card. And the phone is about 2-3yrs of age now, so the NAND is probably worn something bad...
rdhoggattjr said:
i found this more or less. This is a mixture of threads
Enable swap:
mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
mkswap /dev/block/mmcblk0p3
echo "swapon -a" >> /system/etc/init.d/05userinit (on my phone it was 20userinit)
echo "/dev/block/mmcblk0p3 swap swap" >> /system/etc/fstab (i didnt have fstab, use > instead)
reboot
Move swap to data:
mkdir /data/swap
echo "ln -s /data/swap mtdblk0p3" >> /system/etc/init.d/??userinit (whatever it is on your phone)
so i guess this thread can be deleted. sorry
Click to expand...
Click to collapse
Uh, this doesn't do what you might think it does. The swap remains on the sd card (mmcblk0p3), assuming you typo'ed on the ln command...
Jeff
Ditto what they said about wearing out the internal flash...
SDcard is replacable, plus if your builtin is faster, you need a new card.
Class 10 cards are much faster, and far cheaper than killing your phone by wearing out the flash.

Categories

Resources