How to make and use a swap partition on SD-card (HD2)

How to make and use a swap partition on SD-card (HD2)

Postby yank555 » 13 Mar 2013, 19:01

REMEMBER

FIRST OF ALL, do a Nandroid backup, as well as a backup of your sd-card content !

You're doing this at your very own risk, I'm not to be held responsible if something goes wrong :cool:


There's another little warning I need to add to this, using part of your sd-card as swap space will cause that part of your card to undergo lots of read/writes, thus shortening the life of that part of the card...

I've been using hard swap for quite a long time now, no issues to report, but don't tell me I didn't warn you :cool:

Now that said, let's get going ;)


Initially this was a script and a guide that explained how to format and use a swap partition, but I've gone further in the meantime, since this now is a flashable MOD that will, if you have a swap partition on your SD-card, format that partition and install a swap activation script in system startup for you.

Here is how to use this mod :

1) Have I mentiond to backup your system (Nandroid) and SD-card ?! Cause now would be a real good time to do so :D

2) Partition your SD-card (Minitool Partition Wizard, 4ext, CWM...) - for a step by step documentation have a look here.
You can create as many partitions as you like/can, as long as all are primary partitions. This MOD will look for the swap partiton and find it even if it's not the last, though it's common practice for swap to be the last partition.

Just please don't create more than one swap partition, I don't know how the script would react if there were more than one ! You've been warned !


3) Download "Hard-Swap-Yank555.lu_Flasher-v1.0.zip" and put it onto your SD-card

4) Boot into recovery

5) Flash "Hard-Swap-Yank555.lu_Flasher-v1.0.zip" from your SD-card (like a ROM or kernel)

6) Reboot and enjoy !!

To check if all went fine, start a terminal and type "free", you'll need to see something different than 0 in your swap line, look at the attached print-screen ;)

Enjoy and please let me know how it worked for you !

BTW, I've successfully tested this on HyperDroid 6.6.0 CM7 extreme and NexusHD2-ICS-CM9-HWA V2.0.

JP.
Nexus 5 (aka. Hammerhead) 32Gb
Note 3 SM-N9005 32Gb Proudly eFused
SGS3 GT-I9300 32Gb
HTC Sensation XE
HTC HD2
TF300TG 32Gb

Image
Credits FAdrums !
User avatar
yank555
-----------
 
Posts: 3520
Joined: 11 Mar 2013, 20:51
Has thanked: 924 times
Been thanked: 4608 times

Re: How to make and use a swap partition on the SD-card

Postby yank555 » 13 Mar 2013, 19:01

------------------------------- Prior version (kept for reference only) -------------------------------

In case somebody wants to check it out, here is the swap activation script I wrote (attached) as well as explanations on how to make it all work :

1) Partition your sd-card (Minitool Partition Wizard, 4ext, CWM...)
Backup your DATA first !! I won't be responsible for your lost data :cool:

I created a 256Mb partition... but size is up to you !


2) Boot your system with the partitionned sd-card
I suppose in this scenario that you have a FAT, an sd-ext and a swap partition on the sd-card (3 partitions in total)

This means "/dev/block/mmcblk0p3" is the third partition on your sd-card and is the swap partition you've created in step 1.

NB: If you don't have an sd-ext, you need to change the "swap_partition" variable in the beginning of the script accordingly to "/dev/block/mmcblk0p2", pointing to wherever your swap partition is !


3) If necessary customize the 99swap script (attached to this post) and then put it onto your sd-card's root folder, you'll need it while executing the commands in step 4.

4) Open a terminal and type the following

NB: Change "mkswap /dev/block/mmcblk0p3" accordingly to point to the swap partition you've created in step 1.
su
mount -o remount,rw /system
cp /mnt/sdcard/99swap /system/etc/init.d
chmod 755 /system/etc/init.d/99swap
chown 0:2000 /system/etc/init.d/99swap
mkswap /dev/block/mmcblk0p3
mount -o remount,ro /system
exit


5) Reboot your phone, start a terminal again and type free, you'll need to see something different than 0 in your swap line, look at the attached print-screen ;)

Swappiness will be set to 50 by the script, which is a rather conservative swap use, made sense to me since SD-swap is slower than ram, better not to use it too agressively. Feel free to experiment with the swappiness variable in the script ;) (values between 0 and 100, 0 meaning "try not to swap", 100 meaning "try to swap all the time")

If you want to try and have a question, just let me know !

JP.
Nexus 5 (aka. Hammerhead) 32Gb
Note 3 SM-N9005 32Gb Proudly eFused
SGS3 GT-I9300 32Gb
HTC Sensation XE
HTC HD2
TF300TG 32Gb

Image
Credits FAdrums !
User avatar
yank555
-----------
 
Posts: 3520
Joined: 11 Mar 2013, 20:51
Has thanked: 924 times
Been thanked: 4608 times


Return to Mods

Who is online

Users browsing this forum: No registered users and 1 guest

cron