|
Guys, I am posting this hoping that it might become of use for all of you. I have read a big deal on how to move applications from the root partition that only has up to 20 usable MB, to the /private/var parttition, which is soft linked as /var and has GBs of available space.
After reading a lot of posts, I understood that the easiest trick was to move the whole /Applications folder to /var and then creating a soft link to /Applications for the /var/Applications directory; however after making this tidy movement, the Installer application would become unusable because of the 'main script execution error', which is pretty much unrepairable --or not easily at least.
Not an application would complain for being in /var/Applications (and soft linked in /Applications) but Installer, which is pretty bad since I could no longer install, delete or update any application. I moved Installer and all the applications back from /var to /; however Installer wouldn't work any more. I had to restore mi iPhone in order to make the Installer work --no applications left after performing the restore though.
So, I came up with this idea: what about moving all the applications but the Installer? I created a script that would do this by moving all the applications but the installer and then, after moving the applications, it would create a soft link to /Applications for each application located in /var/Applications. This would make all the applications accessible to the OS and Springboard as if they were never moved at all.
The script has been working great, and now I have hundreds of applications and the Installer has been working flawlessly.
If you feel like you need to install all the dictionaries, games, thesaurus, utilities, development and networking tools, etc, just as I do, this script is for you. You'll need to execute it after installing some applications or after each time you install a new application, is up to you. I used to install several applications and at the end I would simply run the script once; however I ended up installing a crontab that would run the script by my once a day =')
Installing the script
You need to have previously installed System/OpenSSH using Installer, for enabling SSH connections to your iPhone/iPod touch and System/BSD Subsystem so that all the commands and utilities needed can actually work.
Connect to your phone using putty or SSH Secure Shell as root. Password for mine is default password, which is 'alpine'.
After logging in, create the bin directory
# mkdir -v bin
Note that the '-v' will give you feedback on what is created.
Using vi or nano (nano is easier), write a file inside the bin directory you just created called move-apps:
# vi bin/move-apps #then insert the content or alternatively use nano:
# nano bin/move-apps
Insert the following content in the file you just opened for writing using vi or nano
#!/bin/bash
# space saver script for iphone
# Gerardo Costilla
# version 1.01 - fixed the target of the soft links,
# that was being set to . instead of /Applications
find /Applications -maxdepth 1 -mindepth 1 ! -iname "installer.app" -exec cp -rf {} /var/Applications \; -exec rm -rf {} \; 2>&1 | grep -v "are identical"
find /var/Applications -maxdepth 1 -mindepth 1 -name "*app" -exec ln -sv {} /Applications \; 2>&1 | grep -v "File exists"
Now make the script executable
chmod +x bin/move-apps
Running the script
Now login to your iPhone via SSH using SSH Secure Shell or Putty and execute the script by typing
# move-apps #note that you might need to execute it as bin/move-apps, depending on your path configuration
Running the script without using SSH Secure Shell nor Putty
You might want to install System/Term vt1000 from Installer and issue the command as root after installing some applications. I can't switch to root using 'su -' so I log in as root using ssh from the Terminal and then I execute the move-apps script.
To log in as root from terminal, using ssh, type from the prompt the following command. The password for my configuration is 'alpine'
$ ssh root@localhost
Automating the script
In order to avoid executing the script at all, I installed a command to root's user crontab, that will execute the script everyday at 05:00 AM - I am allways sleeping at this time, so this is a great time for the iPhone to work on it. Since the script is incredibly efficient and fast, you could even configure it to run it every minute without any concerns, however since your iPhone/iPod touch runs in batteries, the most you can save will always pay back.
Note that you need it to install it as root (if you are using Term vt100 to connect, you might be logged not as root [if your prompt is '$' instead of '#', then you ARE NOT logged as root]). Enter the 'whoami' command to ask the OS your user name, if you are not sure.
# crontab -e # vi will be launched, insert the following
00 05 * * * ~/bin/move-apps &> /var/move-app.log
[CONS]
There is also a great or not so good thing (its up to you) about relocating applications: whenever you delete an application using Installer, Installer ends up removing a soft link which will make it invisible for SpringBoard; however the application will remain in the big (/private/var) partition. After removing an application using Installer, if you want to absolutely delete it from the filesystem, you'll need to remove it by hand using 'rm -r'
To delete AppFlow.app, after unstalling it using Installer, issue the following command after sshing as root to your iPhone:
# rm -rv /var/AppFlow.app
Note that the 'r' in -rv will delete a folder and the 'v' will give you beedback on what is being deleted.
Short vi tutorial cheat sheet
* press [esc] and [i] to start inserting text
* only press the right, up, left and down keys AFTER pressing [esc]
* press [esc] :wq to save the file and quit vi
* press [esc] x to delete a character
# press [esc] dd to delete a line
|