View Single Post
Old February 16th, 2011, 06:11 PM   #2 (permalink)
akazabam
Senior Member
Thread Author (OP)
 
Join Date: Jun 2010
Location: Near Los Angeles
Posts: 4,418
 
Device(s): Samsung Galaxy Nexus
Carrier: Not Provided

Thanks: 101
Thanked 1,382 Times in 1,050 Posts
Default

IV. The System Partition

The partition mounted as /system is automatically mounted as read only. It's like this because, even with root (the unlocked ability to make changes to the partition mounted as /system) it's dangerous to make changes there if you do not know what you are doing. When you flash a ROM from recovery, it wipes that partition, and writes new contents to it. Recovery scripts, however, are smart enough to mount this partition in rw mode. If you are going to make changes to /system while booted up in Android, you must have /system mounted as rw. Otherwise, you will just get permission errors even thought you have root level permissions.

To do this, you must remount the partition under /system as rw. There are many ways of doing this. All of them are system-wide. What that means is, if you use an app to remount /system as rw, the entire system and any other app will see it such until you reboot the phone or remount it as ro. Root explorer, for example, has an option in the top right corner to mount whatever file system you are currently browsing as either rw or ro depending on what it's currently mounted as. Basically, it toggles between rw and ro. There is also an app in the marketplace called "Mount /system (rw /ro)", which will do that as well if you don't have root explorer. Let's look at it in a little more detail, though.

Should you want to remount the partition mounted under /system as rw using the command line from a terminal emulator, you would run this:

su
mount -o remount,rw -t yaffs2 /dev/block/mtdblock4 /system

The "su" command is how you get root level permissions at the command line. You cannot change how a partition is mounted without it. Let's break down the second command:
  • mount is the generic command used to view or modify currently mounted partitions or any media for that matter.
  • -o is the option used to specify certain special mount options.
  • a comma separated list following -o are the options you want to specify for mounting.
  • remount means that the file system you are mounting is already mounted, and you want to specify some other options. You would leave this out if the filesystem was not mounted yet. As /system has to be mounted by virtue of the fact that you're using the system, you must specify the option to remount.
  • rw means that you want /system to be mounted in read/write mode. By default, it is read-only, as previously explained.
  • -t yaffs2 is the filesystem type of the partition. It's not that important for this explanation. Just understand that a partition must be formatted with a particular file system, which basically means how files are stored. Each operating system has the ability to understand certain file system types. More on this later.
  • /dev/block/mtdblock4 is the logical location of the partition itself under /dev as previously explained. Should you want to mount a different partition, you would replace this line with it.
  • /system is the location under / where the files belonging to the mtdblock4 partition will be made accessible. In the case of a remount, these last two strings should not change from how it is currently mounted. For example, if /system was mounted as /asdfasdf (just an example), you should not use remount to then mount it as /system. You'd stick with /asdfasdf. Just a point to remember; it will always be /system in this case. This is not the case if you’re mounting something for your own use, but changing the mount point of /system would be detrimental.

Once the above is done, a user can then make changes to /system, but only as the root user, of course. This requires using the terminal emulator after having typed "su" OR using an app that can run as the root user and browse all partitions. An example is Root Explorer.

Once the user is done making changes, /system should be remounted in ro mode, again, to avoid making unwanted changed. It's the safe thing to do. Rebooting will take care of it, but it can be done much quicker by reverting the change manually. Root explorer has the toggle, as does the other mentioned app. To do it from the terminal emulator, type:

su
mount -o remount,ro -t yaffs2 /dev/block/mtdblock4 /system

The only difference between the two commands is that rw changed to ro. That's it.


V. Current Mounts


If you want to see how the system is currently using various partitions, you can run the mount command from the terminal emulator by itself, with no arguments or options. It will list several things including the partition itself, the mountpoint for said partition, and options used while mounting it (such as rw or ro). If you are interested in only a particular partition, run:

mount|grep /whateverpartition

where whateverpartition is the partition you want to see. For example, to see how /system is currently mounted:

mount|grep /system

You will see something like:

/dev/block/mtdblock4 /system yaffs2 ro 0 0

All of that information should look familiar now. The 0 0 at the end are other options that you don’t need to be concerned with outside or real Linux administration.

Having an understanding of how this works will help you determine ways of saving space and making the most of your available storage. The three major partitions are /data, /system, and /cache. A majority of your 1 GB of internal storage is used by these. The partitions sizes are set when the partitions are created. By default, this is how they are partitioned:

/system – 350 MB
/data – 430 MB
/cache – 160 MB

As you can see, you only have 430 MB for apps and data. That’s less than half of the advertised space. There are numerous apps on the market that will display the free space available on each partition, but it can be done from the command line as well by typing this:

df -h

That will show all mounted partitions, how big they are, and how much free space you have. You can check the same for just one partition by doing something like:

df -h /system

You can, of course, replace /system with whatever partition you want to see. You will probably notice that both /system and /cache have a lot of free space. As it turns out, most of that free space rarely gets used, and cannot be used by you for apps, at all. It’s wasted space. Cache, of course, will show mostly free space, but it’s necessary for things like OTAs, which will download to that directory. It does need to be somewhat large, but not *that* big. In any case, there are ways of having more space available than just 430 MB. The best place to start is a2sd.
akazabam is offline  
Last edited by akazabam; February 16th, 2011 at 06:17 PM.
The Following 14 Users Say Thank You to akazabam For This Useful Post:
3club (September 5th, 2011), AARONONE (June 18th, 2012), dannymur (May 21st, 2011), Granite1 (September 5th, 2011), hno3 (January 28th, 2013), Kaddoble (December 6th, 2011), Mr. Ed (February 17th, 2011), ocnbrze (May 21st, 2011), rob0t (March 31st, 2011), sdrawkcab25 (September 14th, 2012), spiderplant0 (February 12th, 2013), stevcha (February 17th, 2011), Tempusfugit (February 17th, 2011), tessler65 (January 24th, 2012)