Save a bit of space

Search This thread

Verbato

Senior Member
Jan 1, 2007
400
190
Hallingdal
On a few of the ROMs I've tried out there is a toolbox... actually quiet a few copies of toolbox, in /system/bin. Having more than one copy of an executable file is bad. Very bad. This, I've found, takes up more than 5MB of space on quiet a few ROMs. We want to save space.

There is this thing in linux (android runs on top of a linux-kernel - fortunately!) called a "link". This is sort of the same thing as a pointer to the "real" file. For example, if you're old enough you might have seen a dictionary before. Well, in some cases they save space in the dictionaries by saying, "John Doe, see Doe, John". Well, a link does the same thing. So if you link ls to toolbox then the next time you type in "ls", the filesystem will tell linux to go to toolbox. Only, linux tells toolbox "I came from a link called ls", which makes toolbox spit out the command ls. Well, simply put (there's hard and soft links, but it doesn't really matter for now).

So how to deal with this? Well, you can either delete all the files that are a simple copy of toolbox or you can add the following to updater-script (for the lazy ones out there):

delete("/system/bin/cat");
delete("/system/bin/chmod");
delete("/system/bin/chown");
delete("/system/bin/cmp");
delete("/system/bin/ctrlaltdel");
delete("/system/bin/date");
delete("/system/bin/dd");
delete("/system/bin/df");
delete("/system/bin/dmesg");
delete("/system/bin/getevent");
delete("/system/bin/getprop");
delete("/system/bin/hd");
delete("/system/bin/id");
delete("/system/bin/ifconfig");
delete("/system/bin/iftop");
delete("/system/bin/insmod");
delete("/system/bin/ioctl");
delete("/system/bin/ionice");
delete("/system/bin/kill");
delete("/system/bin/ln");
delete("/system/bin/log");
delete("/system/bin/ls");
delete("/system/bin/lsmod");
delete("/system/bin/lsof");
delete("/system/bin/lsusb");
delete("/system/bin/mkdir");
delete("/system/bin/mount");
delete("/system/bin/mv");
delete("/system/bin/nandread");
delete("/system/bin/netstat");
delete("/system/bin/newfs_msdos");
delete("/system/bin/notify");
delete("/system/bin/printenv");
delete("/system/bin/ps");
delete("/system/bin/reboot");
delete("/system/bin/renice");
delete("/system/bin/rm");
delete("/system/bin/rmdir");
delete("/system/bin/rmmod");
delete("/system/bin/route");
delete("/system/bin/schedtop");
delete("/system/bin/sendevent");
delete("/system/bin/setconsole");
delete("/system/bin/setprop");
delete("/system/bin/sleep");
delete("/system/bin/smd");
delete("/system/bin/start");
delete("/system/bin/stop");
delete("/system/bin/sync");
delete("/system/bin/top");
delete("/system/bin/touch");
delete("/system/bin/umount");
delete("/system/bin/uptime");
delete("/system/bin/vmstat");
delete("/system/bin/watchprops");
delete("/system/bin/wipe");
delete("/system/bin/wmdsi");
symlink("toolbox", "/system/bin/ctrlaltdel");
symlink("toolbox", "/system/bin/getevent");
symlink("toolbox", "/system/bin/getprop");
symlink("toolbox", "/system/bin/iftop");
symlink("toolbox", "/system/bin/ioctl");
symlink("toolbox", "/system/bin/log");
symlink("toolbox", "/system/bin/lsof");
symlink("toolbox", "/system/bin/lsusb");
symlink("toolbox", "/system/bin/nandread");
symlink("toolbox", "/system/bin/newfs_msdos");
symlink("toolbox", "/system/bin/notify");
symlink("toolbox", "/system/bin/reboot");
symlink("toolbox", "/system/bin/schedtop");
symlink("toolbox", "/system/bin/sendevent");
symlink("toolbox", "/system/bin/setprop");
symlink("toolbox", "/system/bin/smd");
symlink("toolbox", "/system/bin/start");
symlink("toolbox", "/system/bin/stop");
symlink("toolbox", "/system/bin/vmstat");
symlink("toolbox", "/system/bin/watchprops");
symlink("toolbox", "/system/bin/wipe");
symlink("toolbox", "/system/bin/wmdsi");


Well, like I said, I prefer the busybox' toolset (ls, cat, grep, etc) over toolbox' toolset. So if you want to add busybox properly to /system/bin you do so by adding the following to the updater-script (after the above mentioned code!):
run_program("/system/xbin/busybox", "--install", "-s", "/system/bin");
This makes busybox install links to it self in /system/bin. The last line might as well be /system/xbin, depending on whatever you prefer.

I added a busybox I compiled a couple of weeks ago from the 1.22-version of busybox. It's 1.4MB in size, which is more than the 800kb one that is usually used. However, with the space saved from removing all the toolbox-copies it still amounts to space saved. You are free to use it as you wish, if you wish.
 

Attachments

  • busybox.zip
    956.8 KB · Views: 34

Top Liked Posts

  • There are no posts matching your filters.
  • 4
    On a few of the ROMs I've tried out there is a toolbox... actually quiet a few copies of toolbox, in /system/bin. Having more than one copy of an executable file is bad. Very bad. This, I've found, takes up more than 5MB of space on quiet a few ROMs. We want to save space.

    There is this thing in linux (android runs on top of a linux-kernel - fortunately!) called a "link". This is sort of the same thing as a pointer to the "real" file. For example, if you're old enough you might have seen a dictionary before. Well, in some cases they save space in the dictionaries by saying, "John Doe, see Doe, John". Well, a link does the same thing. So if you link ls to toolbox then the next time you type in "ls", the filesystem will tell linux to go to toolbox. Only, linux tells toolbox "I came from a link called ls", which makes toolbox spit out the command ls. Well, simply put (there's hard and soft links, but it doesn't really matter for now).

    So how to deal with this? Well, you can either delete all the files that are a simple copy of toolbox or you can add the following to updater-script (for the lazy ones out there):

    delete("/system/bin/cat");
    delete("/system/bin/chmod");
    delete("/system/bin/chown");
    delete("/system/bin/cmp");
    delete("/system/bin/ctrlaltdel");
    delete("/system/bin/date");
    delete("/system/bin/dd");
    delete("/system/bin/df");
    delete("/system/bin/dmesg");
    delete("/system/bin/getevent");
    delete("/system/bin/getprop");
    delete("/system/bin/hd");
    delete("/system/bin/id");
    delete("/system/bin/ifconfig");
    delete("/system/bin/iftop");
    delete("/system/bin/insmod");
    delete("/system/bin/ioctl");
    delete("/system/bin/ionice");
    delete("/system/bin/kill");
    delete("/system/bin/ln");
    delete("/system/bin/log");
    delete("/system/bin/ls");
    delete("/system/bin/lsmod");
    delete("/system/bin/lsof");
    delete("/system/bin/lsusb");
    delete("/system/bin/mkdir");
    delete("/system/bin/mount");
    delete("/system/bin/mv");
    delete("/system/bin/nandread");
    delete("/system/bin/netstat");
    delete("/system/bin/newfs_msdos");
    delete("/system/bin/notify");
    delete("/system/bin/printenv");
    delete("/system/bin/ps");
    delete("/system/bin/reboot");
    delete("/system/bin/renice");
    delete("/system/bin/rm");
    delete("/system/bin/rmdir");
    delete("/system/bin/rmmod");
    delete("/system/bin/route");
    delete("/system/bin/schedtop");
    delete("/system/bin/sendevent");
    delete("/system/bin/setconsole");
    delete("/system/bin/setprop");
    delete("/system/bin/sleep");
    delete("/system/bin/smd");
    delete("/system/bin/start");
    delete("/system/bin/stop");
    delete("/system/bin/sync");
    delete("/system/bin/top");
    delete("/system/bin/touch");
    delete("/system/bin/umount");
    delete("/system/bin/uptime");
    delete("/system/bin/vmstat");
    delete("/system/bin/watchprops");
    delete("/system/bin/wipe");
    delete("/system/bin/wmdsi");
    symlink("toolbox", "/system/bin/ctrlaltdel");
    symlink("toolbox", "/system/bin/getevent");
    symlink("toolbox", "/system/bin/getprop");
    symlink("toolbox", "/system/bin/iftop");
    symlink("toolbox", "/system/bin/ioctl");
    symlink("toolbox", "/system/bin/log");
    symlink("toolbox", "/system/bin/lsof");
    symlink("toolbox", "/system/bin/lsusb");
    symlink("toolbox", "/system/bin/nandread");
    symlink("toolbox", "/system/bin/newfs_msdos");
    symlink("toolbox", "/system/bin/notify");
    symlink("toolbox", "/system/bin/reboot");
    symlink("toolbox", "/system/bin/schedtop");
    symlink("toolbox", "/system/bin/sendevent");
    symlink("toolbox", "/system/bin/setprop");
    symlink("toolbox", "/system/bin/smd");
    symlink("toolbox", "/system/bin/start");
    symlink("toolbox", "/system/bin/stop");
    symlink("toolbox", "/system/bin/vmstat");
    symlink("toolbox", "/system/bin/watchprops");
    symlink("toolbox", "/system/bin/wipe");
    symlink("toolbox", "/system/bin/wmdsi");


    Well, like I said, I prefer the busybox' toolset (ls, cat, grep, etc) over toolbox' toolset. So if you want to add busybox properly to /system/bin you do so by adding the following to the updater-script (after the above mentioned code!):
    run_program("/system/xbin/busybox", "--install", "-s", "/system/bin");
    This makes busybox install links to it self in /system/bin. The last line might as well be /system/xbin, depending on whatever you prefer.

    I added a busybox I compiled a couple of weeks ago from the 1.22-version of busybox. It's 1.4MB in size, which is more than the 800kb one that is usually used. However, with the space saved from removing all the toolbox-copies it still amounts to space saved. You are free to use it as you wish, if you wish.