CIFS / Windows file share module - Hero CDMA General

Through sheer geekitude, I've compiled a custom cifs / windows file sharing kernel module which I'll make available here. This is specifically geared toward rooted CDMA Heros using stock HTC software or the MoDaCo ROM.
First let me lay this out there:
This is not for the feint of heart, does not currently have any automated methods, is not really all that useful in it's current state, and requires your phone to be rooted.
One of the beautiful things about open source, however, is once the tools are available, someone will (hopefully) make it useful. Right now, it's very 'command line' oriented.
What this allows you to do:
Mount Windows / SMB / CIFS fileshares on your Hero, which can be accessed via a file browser such as Astro or Linda file managers.
Copy files to/from your Hero to your PC via these shares.
What this does not allow you to do (currently):
Allow you to stream music / video / images from your PC through the default music player.
The Guide:
Download the attached cifs-module.zip file, extract it somewhere on your PC.
Connect your phone via USB. Run:
Code:
./adb shell
$ su (if you're not already root)
#
If your /system partition isn't already mounted read/write, you'll need to remount it inside the shell:
Code:
# mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
Change the permissions of the modules folder to allow you to push in the module (again, you should be in the adb shell):
Code:
# chmod 777 /system
# chmod 777 /system/lib
# chmod 777 /system/lib/modules
# exit
$ exit
Now, back at your command prompt, push the kernel module you just downloaded and extracted:
Code:
./adb push cifs.ko /system/lib/modules/cifs.ko
Back into the shell to load it in, reset the permissions, and mount your fileshare.
First, load the module (and fix the /system permissions):
Code:
./adb shell
$ su
# insmod /system/lib/modules/cifs.ko
# chmod 775 /system
# chmod 775 /system/lib
# chmod 775 /system/lib/modules
Congrats so far! You've just loaded in a kernel module! Now to actually use it. You'll want to be connected to your network via WiFi, and have an accessible file share to mount.
Make a folder where you'll mount the share:
Code:
# mkdir /system/remote
Next, mount the share. The username, password, and share name will of course be the info for your local fileshare. The IP I'm using here is just an example, you'll want to use the IP of the PC where your fileshare is located:
Code:
# mount -t cifs -o username=yourusername,password=yourpassword //192.168.1.20/sharename /system/remote
If that goes off without a hitch, you're done! You've successfully mounted a fileshare from your PC to your phone. You can verify by taking a look at the contents:
Code:
# cd /system/remote
# ls
<you should see your list of shared files>
You can also at this point use an app on your phone like Asrto or Linda file manager to browse to this /system/remote folder and copy files to/from your PC!
Again, this is very raw, only tested on my own phone so far, and will really only allow you to copy files to/from your PC. I was able to play a couple of MP3s via Astro, but unfortunately the stock music player can't access the /system or /data folders on your phone, and because your /sdcard is a fat32 filesystem, you cannot mount other filesystems there unfortunately.
If someone knows a good way to get the stock apps reading from the share, please share.
The module is rather large as well, ~ 2.9mb. If anyone can give me some tips on optimizing the module for size, that'd be great - This is the first ARM modules I've ever built, and did so using a cross-compiler, I'm not sure of all the little tricks of the trade yet.
Enjoy!

You might have more luck if you run an ext3/4 fs on the sd card, although I am not sure if that would work.
I tried the above steps on a nexus one running cyanogen mod 5.0.6 and the insmod command failed with a execute error.
Im guessing the model is not build for an ARM v7 chip?!
What were you steps in building the module? I would be keen on trying it myself.

I dropped development on this ages ago as there are far better options available for CIFS/Samba sharing.
Try out EStrong's File Explorer from the market, has a much more usable implementation of LAN file sharing built right in.

I followed these step in order to copy my cifs.ko to modules dir but I get an "out of memory" error when trying to copy the file to the modules dir
any hint?

Related

[Q] Unable to install/copy files in Emulator ???

Hello,
I am a newbie on this site and android development. I want to installa nd run openvpn to my emulator. I am using these 2 sites for reference :
1)
chengdu110.wordpress com
2010/08/14
want-openvpn-work-on-android-device
2)
android.modaco
content
software
291919
openvpn-on-android/
I am facing couple of problems. From 1st site, I can't copy busybox to system/xbin folder. I get no access, permission failure, etc such messages. Am stuck at this point and thus can't proceed ahead. In Part 2 also need to access /system/lib/ where again problem comes.
In site 2, same cannot access /system/lib or /system/bin folder. Even I can't mount like this : ADB shell mount /system
Command mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system from site 1 was successful.
Even I face problems with cp cmd. Just cp libcrypto.so libcrypto-orig.so doesn't work. I got to give "/system/lib/libcrypto.so cp libcrypto.so libcrypto-orig.so" this format only it copies. Though in the above case "Permission denoed" occured for system/lib. But this foramt worked while copying busybox file.
Can anyone help me with the permission to system folders /xbin, /lib, /bin. Why is mounting required ? Why I am not able to mount directly as mount /system; I need to give full command mount -o rw, .... -t .... /system. I am not sure what all to give in the "..." place - had just copied it from site 1.
Any help, guidance is highly appreciated. I use Eclipse DDMS and Android emulator 2.3.3. Please try to help me.

[TUT] Linux in chroot on your iconia

So, many of you want to run a full-size linux on your iconia. Unfortunately due to the fact that acer are a bunch of stupid mofos not releasing kernel source code and do not allow to flash unsigned ROMs we'll have to run it in chroot within android.
First thing to do is to get yourself a rootfs of linux. You can use angstrom, ubuntu.. I'm building debian using multistrap, the config is below. You'd better use pre-built ubuntu/backtrack and skip up to somewhere between steps 4 and 5, unless you have experience with dpkg and apt-get.
Code:
[General]
arch=armel
directory=/home/alexander/builds/multistrap
cleanup=false
retainsources=true
allowrecommends=false
noauth=true
unpack=true
aptsources=Grip
debootstrap=Debian
[Debian]
packages=screen openssh-server alsa-utils wireless-tools wpasupplicant nmap netcat
source=http://ftp.uk.debian.org/debian
keyring=debian-archive-keyring
suite=sid
[Grip]
packages=locales
keyring=emdebian-archive-keyring
source=http://www.emdebian.org/grip
suite=sid
Now we need to get it to iconia somehow. Running it from microsd would be incredibly slow and internal ssd is formatted to vfat. So let's loop mount it.
1. Create the loopback image
Code:
#700 mb
dd if=/dev/zero of=debian.img bs=10M count=70
mkfs.ext2 -f debian.img
2. Mount it as you always do.. on your desktop yet
Code:
mkdir /mnt/debian
mount -o loop -t ext2 debian.img /mnt/debian
3. Copy the desired files.. As a root user, you can cd to the rootfs (generated by multistrap) and
Code:
tar cvp . | tar xvp -C /mnt/debian
4. unmount the image.. (umount /mnt/debian) and copy to the /sdcard. I copy to the /sdcard/linux/debian.img. Also, I use the /sdcard/linux/uroot directory to mount the image on the tablet.
5. now, you need adb or terminal emulator and superuser permissions ('teh rewt')
Now let's make some script, name it android_sh and put it to /bin in /sdcard/linux/uroot. And make it executable (chmod +x /bin/android_sh)
Code:
#!/bin/bash
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
export USER=root
export HOME=/root
export TERM=linux
if [ -z "`pidof Xtightvnc`" ] ; then
vncserver -geometry 1280x740 -depth 8
else
kill -9 `pidof Xtightvnc`
rm /tmp/.X11-unix/X*
rm /tmp/.X*lock
fi
/bin/bash -
Ok. now make another script, in /sdcard/linux
Code:
#!/bin/sh
LOOPBASE=/sdcard/linux
LOOPFILE=debian.img
LOOPTARGET=uroot
cd $LOOPBASE
if [ -z "`grep $LOOPBASE/$LOOPTARGET /proc/mounts`" ]; then
echo "mounting $LOOPFILE"
mount -o loop -t ext2 $LOOPBASE/$LOOPFILE $LOOPBASE/$LOOPTARGET
else
echo "$LOOPFILE already mounted"
fi
for i in dev proc sys
do
echo "processing $i"
if [ -z "`grep $LOOPBASE/$LOOPTARGET/$i /proc/mounts`" ]
then
echo "mounting $i"
mount -o bind /$i $LOOPBASE/$LOOPTARGET/$i
else
echo "$i already mounted"
fi
done
if [ -z "`grep $LOOPBASE/$LOOPTARGET/dev/pts /proc/mounts`" ]
then
mount -t tmpfs none $LOOPBASE/$LOOPTARGET/dev/pts
fi
echo "chroot into $LOOPBASE/$LOOPTARGET"
chroot $LOOPBASE/$LOOPTARGET /bin/android_sh
now, execute it (sh /sdcard/linux/chroot.sh). You should be in root shell now. If you're building debian using multistrap, configure the packages (dpkg-configure -a). Remember I told you to keep out of debian? Dash package is somewhat broken so you may need to lurk through mailing lists to make it install.. And you need to manually add your sid/testing mirrors to the aptitude config.
So what now? Install tightvnc server (in debian/ubuntu, use apt-get update; apt-get install tightvncserver), exit the shell and launch chroot.sh again.
If you're building rootfs yourself, don't forget to install some x desktop environment. I use lxde on debian, it is lightweight and starts automatically with tightvnc
Now, you can use the vnc client on android to connect to your X11. When chrooting, tightvnc wil tell you the number of x session, so use it as the last digit of the port (5901, 5902 etc). I welcome suggestions on how to improve the android_sh to cleanly kill all tightvnc servers and remove temporary files so that the port number is always the same
In the end you may or may not get something similiar to this:
http://img820.imageshack.us/img820/9076/img3159qm.jpg
P.S.
I recommend you to install Hacker's Keyboard which will give you the tab key, esc and arrows simultaneously and allow to use cool software like vim and emacs without pain
https://market.android.com/details?id=app-org.pocketworkstation.pckeyboard
U.B.D.Man...
Cool...But I got stucked at the first step. Where can I get debian.img?
you create a new file named debian.img using dd, then you format it to ext2 using mkfs.. well. you can just take backtrack image from xoom. essentially it's just ubuntu with some software added
I'm just curious why you chose ext2 as opposed to ext4? Given that the filesystem is actually a file on a filesystem, I sort of understand ext2, especially considering you can mount it with the ext4 driver now.
This probably sounds like a stupid question, but for some reason I cannot use bash?
It may be that my paths are not configured properly, but i dont have a bin at the "/" level. I have looked in /system/bin and /system/xbin, but have not found bash there either.
I installed busybox and have been able to perform root tasks, so I am not sure what I missed.
because.. you don't have bash.. you should have it in your chroot. if you need it in android, just install it (like http://forum.xda-developers.com/showthread.php?t=537827)
I installed bash according to the link you posted, but I still don't have a /bin outside of /system. I did change the above scripts to reflect this by saying:
#!/system/bin (but then I get the error 'event not found')
My prompt reads: "sh-3.2#" after reboot, which I understand is bash replacing the stock terminal.
I tried creating the /bin directory in the root, but even with root terminal, it said it was read only. Do I have to remount the root and then create a /bin directory?
When I rooted, I don't remember their being a lengthy discussion about bash installation, or the creation of a /bin directory.
I welcome all suggestions, as I am trying to learn more about the inner workings of the tablet, but still have little experience.
you need bash only in the linux in chroot and therefore do not need to modify scripts.
anyway,
mount -o remount,rw /system
cp bash /system/bin
chmod 755 /system/bin/bash
mount -o remount,ro /system
then you can start bash by typing 'bash' in shell
Hello,
I have tried and I still can't get it run. I am not used to Linux stuffs and scared that I may screwed up my tab. Can you please pack the required files and upload it so that we can follow easier? something like this http://www.secmaniac.com/may-2011/backtrack-5-on-motorola-xoom-in-10-minutes-or-less/ would be great.
Thank you.
PS: I sincerely want to get BackTrack on my tab so that I can run R on this
moved to http://forum.xda-developers.com/showthread.php?t=1094237
sp3dev said:
because.. you don't have bash.. you should have it in your chroot. if you need it in android, just install it (like http://forum.xda-developers.com/showthread.php?t=537827)
Click to expand...
Click to collapse
I ended up installing bash, but I still had problems with chroot and getting the scripts to run, so I decided to reverse what I was doing. In the process of trying to remove the bash shell and replace with the stock sh, I must have messed something up.
I tried a factory reset, and when I loaded back up again, I can't get wifi to connect. My suspicion is that there is at least two separate things wrong:
-My shell is somewhere in permission limbo or non-existant
I try running >adb shell and I get:
"- exec '/system/bin/sh' failed: No such file or directory (2) -"​
-The permissions on my wpa_supplicant are probably messed up, hence I can't connect to wifi
Any suggestions?
Well I tried a few more things:
-Tried copying over bash to /system/bin, got an error that it is a read-only file system. Funny, because I need shell (chmod?) in order to repair the shell, those bastards.
-Tried installing apk using adb, got same message about 'sh' missing. I think I will have to reflash a system.img, but I can't seem to find the Wifi-US with a working link.
Any help would be much appreciated.
Hey guys, could you upload and send me the link of a video of this working? Cause I love the idea of it but I'm not sure if its really practical
Sent from my A500 using XDA Premium App

[HOWTO] Loop mount

OK, I spent a couple of hours figuring out how loop mounting works. The problem is that the mount command in both toolbox and busybox supports only one loop device. I modified the toolbox version to allow the specification of a new loop device.
Here is how to make a 500mb loop-mounted ext2 system at /mnt/myloop , with the system being stored in /storage/sdcard/myext2system.img
Step 1. Make sure you have root. Download bettermount*.zip to your PC from here. Copy the "bettermount" file from the zip file to /data/local/ (or some other location). One way of doing that is with:
Code:
adb push bettermount /data/local
on the PC. Or you can mount your device to USB, copy bettermount to storage, and then in a root shell copy it to /data/local. Or if you have RW root, you can install bettermount in /bin or some other convenient location.
Start a shell on the device, either via adb or an on-device terminal (not recommended unless you have an external keyboard). Switch to root:
Code:
su
Then make bettermount executable:
Code:
chmod 755 /data/local/bettermount
The following steps assume you're still in your root shell.
Step 2. Create ext2 file system in a file. (Skip this if you already have one.)
Code:
dd if=/dev/zero of=/storage/sdcard/myext2system.img bs=1M count=500
mke2fs /storage/sdcard/myext2system.img
mke2fs will give you a warning that this isn't a block special device, but just press "y" and "enter".
Step 3. Create a loop device node for the ext2 file system. The problem here is that the OS uses loop device nodes for apps moved to external storage and one for the system squashfs, and it only has enough loop device nodes for those purposes--any loop device nodes in /dev/block are already in use. On the assumption that you aren't going to have more than 253 apps moved to storage, we're going to create a loop device node numbered 255. If you like, you can check that there isn't already one with that number with
Code:
ls /dev/block/loop*
So, let's create the loop device node:
Code:
mknod -m640 /dev/block/loop255 b 7 255
Step 4. Create a mount point:
Code:
mkdir /mnt/myloop
Step 5. Mount myext2filesystem.img:
Code:
/data/local/bettermount -t ext2 -orw,exec,noatime,nodiratime,sync,loop=/dev/block/loop255 /storage/sdcard/myext2system.img /mnt/myloop
Enjoy your new file system at /mnt/myloop !
You will have to repeat Steps 3-5 after every boot, or else you can make a script that runs every time you boot. You could simply put the commands for 3-5 into a Script Manager script set to run on boot, or there may be some better, more unixy way (but I haven't had any luck editing startup scripts).
What to do with your shiny new filesystem? Well, you could move not just apps but also their libraries to external storage (you can also do that by remounting your external storage in exec mode).
arpruss said:
OK, I spent a couple of hours figuring out how loop mounting works. The problem is that the mount command in both toolbox and busybox supports only one loop device. I modified the toolbox version to allow the specification of a new loop device.
Here is how to make a 500mb loop-mounted ext2 system at /mnt/myloop , with the system being stored in /storage/sdcard/myext2system.img
Step 1. Make sure you have root. Download bettermount*.zip to your PC from here. Copy the "bettermount" file from the zip file to /data/local/ (or some other location). One way of doing that is with:
Code:
adb push bettermount /data/local
on the PC. Or you can mount your device to USB, copy bettermount to storage, and then in a root shell copy it to /data/local. Or if you have RW root, you can install bettermount in /bin or some other convenient location.
Start a shell on the device, either via adb or an on-device terminal (not recommended unless you have an external keyboard). Switch to root:
Code:
su
Then make bettermount executable:
Code:
chmod 755 /data/local/bettermount
The following steps assume you're still in your root shell.
Step 2. Create ext2 file system in a file. (Skip this if you already have one.)
Code:
dd if=/dev/zero of=/storage/sdcard/myext2system.img bs=1M count=500
mke2fs /storage/sdcard/myext2system.img
mke2fs will give you a warning that this isn't a block special device, but just press "y" and "enter".
Step 3. Create a loop device node for the ext2 file system. The problem here is that the OS uses loop device nodes for apps moved to external storage and one for the system squashfs, and it only has enough loop device nodes for those purposes--any loop device nodes in /dev/block are already in use. On the assumption that you aren't going to have more than 253 apps moved to storage, we're going to create a loop device node numbered 255. If you like, you can check that there isn't already one with that number with
Code:
ls /dev/block/loop*
So, let's create the loop device node:
Code:
mknod -m640 /dev/block/loop255 b 7 255
Step 4. Create a mount point:
Code:
mkdir /mnt/myloop
Step 5. Mount myext2filesystem.img:
Code:
/data/local/bettermount -t ext2 -orw,exec,noatime,nodiratime,sync,loop=/dev/block/loop255 /storage/sdcard/myext2filesystem.img /mnt/myloop
Enjoy your new file system at /mnt/myloop !
You will have to repeat Steps 3-5 after every boot, or else you can make a script that runs every time you boot. You could simply put the commands for 3-5 into a Script Manager script set to run on boot, or there may be some better, more unixy way (but I haven't had any luck editing startup scripts).
What to do with your shiny new filesystem? Well, you could move not just apps but also their libraries to external storage (you can also do that by remounting your external storage in exec mode).
Click to expand...
Click to collapse
Which version of busybox were you testing with? I haven't had a problem with multiple loop devices...
I've been using the stock busybox: 1.7.2.
Do you use -oloop=/dev/block/loopNN to specify the device?
I just tried 1.16.0 from the Titanium Backup website. No luck. I created /dev/block/loop222. Then:
Code:
# /tmp/busybox mount -t ext2 -oloop=/dev/block/loop222 /storage/10.img /mnt/myloop
mount: can't setup loop device: No such file or directory
# bettermount -t ext2 -oloop=/dev/block/loop222 /storage/10.img /mnt/myloop
# (works!)
I also tried just plain -oloop, without the =/dev/block/loop222, and it didn't work.
arpruss said:
I've been using the stock busybox: 1.7.2.
Do you use -oloop=/dev/block/loopNN to specify the device?
I just tried 1.16.0 from the Titanium Backup website. No luck. I created /dev/block/loop222. Then:
Code:
# /tmp/busybox mount -t ext2 -oloop=/dev/block/loop222 /storage/10.img /mnt/myloop
mount: can't setup loop device: No such file or directory
# bettermount -t ext2 -oloop=/dev/block/loop222 /storage/10.img /mnt/myloop
# (works!)
I also tried just plain -oloop, without the =/dev/block/loop222, and it didn't work.
Click to expand...
Click to collapse
I can't remember if mount was symlinked to busybox at the time, but I just used the standard "mount -o loop disk1.img /mnt/disk". I may have even been on a custom kernel and had a crosscompiled mount, so good work, this is probably going to be a common problem for people.
The problem with busybox seems to be that it thinks /dev/block/loop0 is free, but it's not. Doing losetup -f returns /dev/block/loop0.
If you could mount the loopdevice in init.rc this would be the easiest way to expand the 300MB /data problem with archos.
Also it might be the best way in CM7 until its stable for the persistent Data between revisions.
fzelle said:
If you could mount the loopdevice in init.rc this would be the easiest way to expand the 300MB /data problem with archos.
Also it might be the best way in CM7 until its stable for the persistent Data between revisions.
Click to expand...
Click to collapse
I have had no luck adding anything to init.rc with the rw root.
Moreover, /storage and /storage/sdcard get mounted quite late in the boot process--late enough that I think one can't just move the /data directory there. I suppose one might be able to mount them earlier in the process, but I haven't been able to figure out how to run anything in an init script. If anybody knows how to do it, please speak up!
What one could do, however, is mount the loop from an app's on-boot notification, and then symlink individual app files.
It looks like with a better busybox than the one included with the device, one can also use losetup to specify the loop device--see here.
I built a full 1.18.5 version of Busybox, and it does loop mounting just right. You can replace Step 1 of my HOWTO with fetching my modified busybox and putting it in /data/local, from http://code.google.com/p/busybox-for-android/downloads/list
Then step 3 is not needed.
Step 4 should be replaceable with the very simple:
Code:
/data/local/busybox mount -orw,exec,noatime,nodiratime,sync,loop /storage/sdcard/myext2system.img /mnt/myloop
Or if you're pressed for time, and want to use default mount options:
Code:
/data/local/busybox mount -oloop /storage/sdcard/myext2system.img /mnt/myloop
But if you want to implement this is inside an app, depending on your license needs, you may want to use the longer method, since busybox is GPL while bettermount is Apache 2.

[HOWTO] Add init.d to stock ROM + a few other goodies

I have been resisting the urge to flash a custom ROM for a bit, but I really miss having init.d support. So I read a few threads for other phones and rolled my own.
Warnings
I borrowed bits and pieces from various places. If you don't know what init.d is, you probably don't want to do this. If you aren't willing to take responsibility for bricking your tablet, don't do this. Seriously, the risk of bricking is very low, but if you aren't comfortable booting into an adb shell from recovery, maybe this is not for you. Strongly suggest a nandroid backup before you get started so if you totally bork things you can just hit rewind.
Note: The latest CWM may prompt you on a reboot that the ROM may overwrite the bootloader and offer to fix it for you. Don't do that. The init.d hack takes over the bootloader install script, but does not change your bootloader! If you accidentally do let it fix things for you, just rebuild the install-bootloader.sh file. The other steps should be fine.
Prerequisites
First, you need root, busybox, and some sort of terminal (either adb, or some terminal you like using on the tablet).
I have found that I like Busybox Installer (from the market; https://play.google.com/store/apps/details?id=com.jrummy.busybox.installer) but for some reason it doesn't create new symlinks unless you click advanced install.
Let's get to it!
In the shell (don't type # or anything after #):
Code:
su # get root
mount -o remount,rw /system # get access to /system (4.04 seems to mount ro as is usual; seems like the original mounted rw)
which run-parts # if you don't see /system/xbin/run-parts you need to install/reinstall busybox; if it is somewhere else, note it
mkdir /system/etc/init.d
Create a file called sysinit -- we are going to put it in /system/bin. You can edit it in place with vi, mount your tablet and edit it on your computer, or create it on the computer and push it via adb. Whatever.
Here's the file (you do need the # and the things after it in the file!):
Code:
#!/system/bin/sh
export PATH=/sbin:/system/sbin:/system/bin:/system/xbin
/system/bin/logwrapper /system/xbin/run-parts /system/etc/init.d
Note that if your run-parts is not in /system/xbin (from the which command) then fix the above to reflect your reality.
In the shell, make it executable
Code:
chmod 755 /system/bin/sysinit
Now go in the init.d directory and create some things you want to run at start up. For example:
Code:
cd /system/etc/init.d
echo '#!/system/bin/sh' >99test # note: you do need the first # in this line but not the 2nd!
echo 'date >>/data/tmp/init.d-log.txt' >>99test
chmod 755 99test
Here's a more practical one (yes, you need the # signs). Name it something like 10diskperf -- don't forget to chmod it.
Code:
#!/system/bin/sh
# Set disk read aheads to 1024
chmod 777 /sys/block/mmcblk0/queue/read_ahead_kb
echo "1024" > /sys/block/mmcblk0/queue/read_ahead_kb
chmod 777 /sys/block/mmcblk1/queue/read_ahead_kb
echo "1024" > /sys/block/mmcblk1/queue/read_ahead_kb
chmod 777 /sys/devices/virtual/bdi/179:0/read_ahead_kb
echo "1024" > /sys/devices/virtual/bdi/179:0/read_ahead_kb
Or here is one to tweak some TCP parameters (25sysctl):
Code:
#!/system/bin/sh
sysctl -w net.core.rmem_max=524288
sysctl -w net.core.wmem_max=524288
sysctl -w net.ipv4.tcp_rmem=6144 87380 524288
sysctl -w net.ipv4.tcp_wmem=6144 87380 524288
Whatever files you put in, you need to remember to make them executable (chmod 755).
Finally, you need to kick it all off at start up. The hack for that is we are going to create /system/etc/install-recovery.sh which apparently runs on each boot.
Code:
cd /system/etc
echo '#!/system/bin/sh' >install-recovery.sh
echo '/system/bin/sysinit' >>install-recovery.sh
chmod 755 install-recovery.sh
Tips and troubleshooting
If you are too lazy to cut and paste I have the files here (View attachment init.d-support.zip) that you can just move to the right places and change permission. If you are really lazy there is lightly tested install script below.
I like to try running the whole thing before a reboot to see if I get any errors:
Code:
/system/etc/install-recovery.sh
I'd suggest putting the 99test file in first. Verify that you get the expected file in /data/tmp and then reboot and check again. Then you can remove 99test.
Same goes for adding new scripts. Try running them from the shell to see if they throw errors before you reboot!
If you have trouble, see if this looks right:
Code:
ls -ld /system/etc/install-recovery.sh /system/bin/sysinit /system/etc/init.d /system/xbin/run-parts
-rwxr-xr-x root root 39 2012-07-14 10:00 install-recovery.sh
-rwxr-xr-x root root 140 2012-07-14 10:01 sysinit
drwxrwxrwx root root 2012-07-14 10:10 init.d
lrwxrwxrwx root root 2012-07-14 09:55 run-parts -> /system/xbin/busybox
For the brave
The install-init.d zip file (View attachment install-init.d.zip) contains a lightly tested script that SHOULD do the install steps for you.
Send the file to your android to someplace that can execute code (e.g., /system/xbin; I had to use adb to put it on the sdcard and then move it to /systemxbin in the shell since I don't have the adb root kernel installed).
Code:
cd /system/xbin # or wherever you have it
chmod 755 install-init.d
./install-init.d
It performs rude checks to see if init.d exists, and tries to handle moving or missing busybox. It only installs 99test as a script.
Let me know if this works or doesn't work for you.
For the extra brave: There is no reason this should only work on the Samsung. This ought to work on pretty much most stock ROMs as long as they execute install-recovery.sh on start up.
Scripts
What do you put in your init.d? If you post anything cool I'll put it up here in the op.
One that gave me some real gains in I/O performance required a new version of the tune2fs executable. By default, it is part of busybox but the busybox one only has a few simple options. I've included a stand alone version and the script 10disktune here View attachment disktune.zip. Unpack the zip and put the 10disktune in /system/etc/init.d (don't forget to chmod) and put tune2fs in /system/bin (chmod that too). Note that busybox has one in /system/xbin but the script specifically calls out the one in /system/bin.
Here's one that will zipalign your apks on each boot
Code:
#!/system/bin/sh
for apk in /data/app/*.apk ; do
zipalign -c 4 $apk
ZCHECK=$?
if [ $ZCHECK -eq 1 ]; then
zipalign -f 4 $apk /cache/$(basename $apk)
if [ -e /cache/$(basename $apk) ]; then
cp -p -f /cache/$(basename $apk) $apk
rm /cache/$(basename $apk)
fi;
fi;
done;
Fin
Corrections welcome. I considered using exec or . to load some of this into one shell but given that it runs once at startup, I figured it is fine as is.
All files for reference
View attachment init.d-support.zip
View attachment install-init.d.zip
View attachment disktune.zip
Great guide, gonna try it tonight.
Sent from a GNote, hell yeah!
SirRhor said:
Great guide, gonna try it tonight.
Sent from a GNote, hell yeah!
Click to expand...
Click to collapse
I'm curious how it went. If you ran into any issues, let me know so I can update the op. Thanks!
Hmm did anyone get this to work?
wd5gnr said:
Hmm did anyone get this to work?
Click to expand...
Click to collapse
I did it on my Galaxy Nexus.
It works great, I had a bit of problem with the sysinit file, but when I downloaded your zip file and used your sysinit, it worked, so it must be a problem from my side
Thanks for this, I can finally use "Odex Me"
aavan said:
I did it on my Galaxy Nexus.
It works great, I had a bit of problem with the sysinit file, but when I downloaded your zip file and used your sysinit, it worked, so it must be a problem from my side
Thanks for this, I can finally use "Odex Me"
Click to expand...
Click to collapse
Great, just wanted to be sure I hadn't made any typos/errors in the guide.
A lot of init.d files collected here: http://forum.xda-developers.com/showthread.php?t=1227269
Also build.prop things, etc.
Thanks, I use your guide and worksperfect for my RK3066 devices. Very simple to understand all steps and what we are doing to our system, perfect for me. Thanks again dude
Melch1zedeK said:
Thanks, I use your guide and worksperfect for my RK3066 devices. Very simple to understand all steps and what we are doing to our system, perfect for me. Thanks again dude
Click to expand...
Click to collapse
Glad to help!
What is thhe utility of this?
moliverac8 said:
What is thhe utility of this?
Click to expand...
Click to collapse
Init.d is how Linux and many Android (which is kind of Linux, after all) systems manage executing commands on boot up.
The /etc/init.d files run in numerical order as root and you can do things like change system settings, manipulate the file system, etc.
See the init.d section linked below for some ideas.
http://forum.xda-developers.com/showthread.php?t=1227269
Question? what is the difference in this method and running a script?
wd5gnr said:
Init.d is how Linux and many Android (which is kind of Linux, after all) systems manage executing commands on boot up.
The /etc/init.d files run in numerical order as root and you can do things like change system settings, manipulate the file system, etc.
See the init.d section linked below for some ideas.
http://forum.xda-developers.com/showthread.php?t=1227269
Click to expand...
Click to collapse
I use the "swap memory script" and was wondering if it would also work this way with the init.d If so would there be any benefit this way over the current way of running it one way or the other? One drawback I see running the script as is is that I have to wait once the system has fully booted until the script has run and I see the Smanager screen to let me know that my memory has been remounted.
Thanks for the info and the learning process.
Here is the script and the link.
http://forum.xda-developers.com/showthread.php?t=1961097
Code:
sleep 5
mount -o remount,rw /
mount -t vfat -o umask=0000 /dev/block/vold/179:25 /mnt/sdcard
sleep 5
mount -o bind /data/media /mnt/extSdCard
As long as the device is ready to mount at boot time and doesn't get remounted, ought to work. Backup and try it
External memory wasn't ready
wd5gnr said:
As long as the device is ready to mount at boot time and doesn't get remounted, ought to work. Backup and try it
Click to expand...
Click to collapse
Thanks for the guide, but I think that the external memory was not ready to be mounted at that time. it didn't see the card till after boot. It was worth a shot, Reverted back to the script in /data and all worked again,
Note: I didn't find /system/xbin/run-parts however, I did find /system/bin/run-parts and changed the path to reflect that, I don't think this was an issue but I'm not 100% sure.

[Q] Mounting & Changing Permissions Using Terminal Emulator on Android Phone

How to properly MOUNT the system so I can change its permission? (USING TERMINAL EMULATOR)
I know the first command for it (mount) (I dont know what command follows)
Because I need to first mount the system before changing permissions.
How to change permissions for a system app (for example SystemUI.apk)? After doing some changes into my SystemUI.apk, I push it into my system and it has different permissions.
I want to change its permission into rw-r--r
In the emulator:
Code:
$ su
# mount -o remount,rw /system
# chmod 0644 /system/app/SystemUI.apk
or:
Code:
$ su
# cd system/app
# mount -o remount,rw /system
# chmod 0644 SystemUI.apk
- What does the "0" in 0644 stands for?
Can you elaborate how that mount works so I can properly use it.
mount -o (what this for) remount (and this) ,rw (this also) /system(its the directory, the one I understand)
klmiciano said:
- What does the "0" in 0644 stands for?
Can you elaborate how that mount works so I can properly use it.
mount -o (what this for) remount (and this) ,rw (this also) /system(its the directory, the one I understand)
Click to expand...
Click to collapse
Permissions for system files go beyond simply rw-r-r. Since Android is essentially Linux, Linux permissions do exist in Android. Alongside the Owner, Group and Other permissions, of which you set rw, r and r respectively, special permissions which are the Sticky bit, GID and UID exist as well. However, since these special permissions are not required for the functioning of Android, the 0 in 0644 is to disable all three of them.
-o in mount is essentially a flag. Flags are options to obtain different outcomes for each command. For example,
Code:
ls -s
not only lists the files in the current directory, but also lists the files' sizes in kB. I am not sure about -o in this case, however.
Remounting is required as your system is already a mounted filesystem, but as read-only (ro). Hence you have to remount it as read-write (rw), in order to change the properties of its files.
This is some good stuff. I need to learn more.
The last time I use the chmod command. I didn't include the '0'. I've only type
chmod 644 (blahblah)
Btw, Thank you for teaching me this stuff.
More power.:laugh:
NightRaven49 said:
Permissions for system files go beyond simply rw-r-r. Since Android is essentially Linux, Linux permissions do exist in Android. Alongside the Owner, Group and Other permissions, of which you set rw, r and r respectively, special permissions which are the Sticky bit, GID and UID exist as well. However, since these special permissions are not required for the functioning of Android, the 0 in 0644 is to disable all three of them.
-o in mount is essentially a flag. Flags are options to obtain different outcomes for each command. For example,
Code:
ls -s
not only lists the files in the current directory, but also lists the files' sizes in kB. I am not sure about -o in this case, however.
Remounting is required as your system is already a mounted filesystem, but as read-only (ro). Hence you have to remount it as read-write (rw), in order to change the properties of its files.
Click to expand...
Click to collapse
This guide probably helped me as well

Categories

Resources