Android device, I want to touch a file or dir in /mnt, it say "Read only file system", I don't know how to do. i try fix it with that fix /system, but it no work.
root#android:/ # ls -l
.....
drwxrwxr-x root system 2011-01-01 11:33 mnt
.....
root#android:/ #
root#android:/ # mkdir /mnt/test
mkdir failed for /mnt/test, Read-only file system
255|root#android:/ #
root#android:/ # mount -o remount,rw /mnt
Usage: mount [-r] [-w] [-o options] [-t type] device directory
1|root#android:/ #
can't fix it as /system.
how can i do it?
root#android:/ # id
uid=0(root) gid=0(root)
root#android:/ #
But i can make directory in /mnt/xxx/, like this:
root#android:/ # mkdir /mnt/usb_storage/test
root#android:/ # ls /mnt/usb_storage/test/
root#android:/ # ls /mnt/usb_storage/
test
root#android:/ #
And
i fond difference between /mnt and /mnt/usb_storage in init.rc
look /mnt:
# create mountpoints
mkdir /mnt 0775 root system
look /mnt/usb_storage:
# Directory for multi usb storage
mkdir /mnt/usb_storage 0700 root system
mount tmpfs tmpfs /mnt/usb_storage mode=0755 gid=1000
Yes!I fix it!
create mountpoints
mkdir /mnt 0775 root system
add mount tmpfs tmpfs /mnt/ mode=0755 gid=1000
now i can touch file or make directory in /mnt
root#android:/mnt # mkdir /mnt/test
root#android:/mnt # ls -l /mnt/
....
drwxrwxrwx root root 2011-01-01 11:04 test
drwxrwxrwt root system 2011-01-01 11:00 usb_storage
root#android:/mnt #
Resolved
ramdisk rootfs is read only.
mount -o remount,rw /
you should have to add certain permission into your manifest file..
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
and for more see the following which near to what you looking for
Can't create file in sd-card
Related
Android rootfs is compressed and split into:
super.raw.00.gz, super.raw.01.gz, super.raw.03.gz, super.raw.04.gz
How to unzip, combine, unpack them to ext4 files that can be mounted ?
Steps are:
Unzip each of the multi-zip files:
gzip -d super.raw.00.gz
gzip -d super.raw.01.gz
gzip -d super.raw.02.gz
gzip -d super.raw.03.gz
Concatenate them to a single file:
cat super.raw.00 super.raw.01 super.raw.02 super.raw.03 > super.raw
Unpack the super image using lpunpack tool. Download link.
./lpunpack super.raw
Mount the image- For eg: system_a
mkdir mount_system
sudo mount -t ext4 -o loop system_a.img mount_system
There is a file named bootanimation.zip in /system/media:
1853 -rw-r--r-- 1 root root 2.1M 2018-07-10 17:29 bootanimation.zip
I want to make it writeable.
So I do this in init.rc:
on fs
+ mount ext4 /dev/block/platform/mstar_mci.0/by-name/system /system wait rw
+ chmod 0777 /system/media/bootanimation.zip
mount_all /fstab.m7221
But it is useless.The bootanimation.zip still is -rw-r--r--.
How can I make /system/media/bootanimation.zip rw in init.rc ?
Can someone tell me how to debug init.rc , I can not see any log!
I know it's there, because ls shows it to me, but every time I try to run it, it says No such file or directory, or simply not found.
Here's the contents of my terminal:
C:\Users\benleggiero>adb shell
root#android:/ # cd /cache/imaging
cd /cache/imaging
root#android:/cache/imaging # ls
ls
backup-data-partition.sh
data-partition-imager.sh
flag-imaging-mode-boot.sh
flags
restore-data-partition.sh
root#android:/cache/imaging # ./backup-data-partition.sh
./backup-data-partition.sh
/system/bin/sh: ./backup-data-partition.sh: not found
127|root#android:/cache/imaging # . ./backup-data-partition.sh
. ./backup-data-partition.sh
/system/bin/sh: .: ./backup-data-partition.sh: No such file or directory
1|root#android:/cache/imaging # sh ./backup-data-partition.sh
sh ./backup-data-partition.sh
sh: ./backup-data-partition.sh: No such file or directory
127|root#android:/cache/imaging # sh backup-data-partition.sh
sh backup-data-partition.sh
sh: backup-data-partition.sh: No such file or directory
127|root#android:/cache/imaging #
127|root#android:/cache/imaging # chmod 777 backup-data-partition.sh
chmod 777 backup-data-partition.sh
Unable to chmod backup-data-partition.sh: No such file or directory
10|root#android:/cache/imaging #
I want to replace a system library by one where I made some small changes. Both libraries were compiled with the same version of cyanogenmod source. The one I copied to the sdcard worked on an earlier flash of CM.
Now I try to run the following:
$ adb shell
shell#m0:/ $ su
root#m0:/ # mount -o rw,remount /system
root#m0:/ # chmod 777 /system/lib/libwilhelm.so
root#m0:/ # cp /sdcard/libwilhelm.so /system/lib/libwilhelm.so
root#m0:/ # chmod 644 /system/lib/libwilhelm.so
root#m0:/ # mount -o ro,remount /system
root#m0:/ # reboot
However even after reboot the old libwilhelm.so is used
I know this because I log something in the not-overriden version in
frameworks/wilhelm/src/sl_entry.c:
#include <android/log.h>
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "frameworks/wilhelm/src/sl_entry.c", __VA_ARGS__))
// ...
SL_API SLresult SLAPIENTRY slCreateEngine(SLObjectItf *pEngine, SLuint32 numOptions,
const SLEngineOption *pEngineOptions, SLuint32 numInterfaces,
const SLInterfaceID *pInterfaceIds, const SLboolean *pInterfaceRequired)
{
LOGI("qqqqqqqqqqqqqqqqqqqq in slCreateEngine");
//... continue original code
This log is then different in the other library that is on the sdcard. So the logcat should display something else once I replaced the library and rebooted but it still prints the original log message.
Also the library doesn't seem to be read from another location:
root#m0:/ # find . -name "libwilhelm*"
./mnt/shell/emulated/0/libwilhelm.so
./system/lib/libwilhelm.so
find: ./proc/1897/task/2088/fd/49: No such file or directory
find: ./proc/1897/task/2088/fd/57: No such file or directory
find: ./proc/1897/task/2100/fd/42: No such file or directory
find: ./proc/2466/task/2471/fd/88: No such file or directory
find: ./proc/2466/task/2741/fd/85: No such file or directory
find: ./proc/2466/task/2741/fd/95: No such file or directory
./data/media/0/libwilhelm.so
What did I miss?
Turns out frameworks/wilhelm/src/sl_entry.c is not part of the libwilhelm.so but the libOpenSLES.so
Moreover it is safer to replace the library by an updater-script that can be executed from a recovery program like TWRP. The script could look like:
ui_print("mounting /system");
mount("ext4", "EMMC", "/dev/block/mmcblk0p9", "/system");
ui_print("/system now mounted");
ui_print("adding new shared library libOpenSLES.so");
package_extract_file("libOpenSLES.so", "/system/lib/libOpenSLES.so");
ui_print("done adding new shared library libOpenSLES.so");
ui_print("unmounting /system");
unmount("/system");
ui_print("/system now unmounted");
ui_print("finished");
I am trying to load a simple Systemtap module on my GT-i9300
I get the error
Error inserting module '/sdcard/systemtap/modules/monitor_fopen.ko':
Unknown symbol in module
Steps that I took:
1. Get root on the device
I did this by installing this Rom
2. Build custom kernel
# ====================================================
# Add toolchain
user#ubuntu1210:~/Programs$ git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7
user#ubuntu1210:~$ sudo gedit .bashrc
# Toolchain
export PATH=${PATH}:~/Programs/arm-linux-androideabi-4.7/bin
# Reboot ubuntu
# ====================================================
# ====================================================
# Download and extract to ~/android/kernel :
# https://github.com/SlimRoms/kernel_samsung_smdk4412.git
user#ubuntu1210:~$ cd android/kernel/kernel_samsung_smdk4412/
# ====================================================
# ====================================================
# Set configuration for compiling
user#ubuntu1210:~/android/kernel/kernel_samsung_smdk4412$ make clean -j4 ARCH=arm SUBARCH=arm CROSS_COMPILE=arm-linux-androideabi-
user#ubuntu1210:~/android/kernel/kernel_samsung_smdk4412$ make ARCH=arm SUBARCH=arm CROSS_COMPILE=arm-linux-androideabi- slim_i9300_defconfig
user#ubuntu1210:~/android/kernel/kernel_samsung_smdk4412$ gedit .config
# Enable config parameters:
CONFIG_DEBUG_INFO, CONFIG_KPROBES, CONFIG_RELAY, CONFIG_DEBUG_FS, CONFIG_MODULES, CONFIG_MODULE_UNLOAD
# ====================================================
# Build Kernel
user#ubuntu1210:~/android/kernel/kernel_samsung_smdk4412$ make -j4 ARCH=arm SUBARCH=arm CROSS_COMPILE=arm-linux-androideabi-
3. Flash built zImage to device
# Download and extract bootimg_tools.zip from
# http://forum.xda-developers.com/showpost.php?p=44670032&postcount=12
#
# Download correct ROM .zip file and extract boot.img to the same folder as bootimg_tools
user#ubuntu1210:~/bootimg_tools$ perl split_bootimg.pl boot.img
user#ubuntu1210:~/bootimg_tools$ perl unpack_ramdisk boot.img-ramdisk.gz ramdisk
user#ubuntu1210:~/bootimg_tools$ perl repack_ramdisk ramdisk boot.img-ramdisk.cpio.gz
user#ubuntu1210:~/bootimg_tools$ cp /home/user/kernel_samsung_smdk4412/arch/arm/boot/zImage boot.img-kernel
user#ubuntu1210:~/bootimg_tools$ ./mkbootimg --kernel boot.img-kernel --ramdisk boot.img-ramdisk.cpio.gz --cmdline 'console=null androidboot.hardware=qcom user_debug=31 zcache' --base 0x80200000 --pagesize 2048 -o boot.img
# Download and install heimdall
# https://bitbucket.org/benjamin_dobell/heimdall/downloads
user#ubuntu1210:~/bootimg_tools$ adb reboot bootloader
user#ubuntu1210:~/bootimg_tools$ sudo heimdall flash --BOOT boot.img --verbose
4. Install systemtap on PC
user#ubuntu1210:~$ mkdir systemtap
user#ubuntu1210:~$ cd systemtap/
user#ubuntu1210:~/systemtap$ git clone https://github.com/flipreverse/systemtap-android.git
user#ubuntu1210:~/systemtap$ cd systemtap-android/
user#ubuntu1210:~/systemtap/systemtap-android$ git submodule init
user#ubuntu1210:~/systemtap/systemtap-android$ git submodule update
user#ubuntu1210:~/systemtap/systemtap-android$ sh build.sh
5. Create an .stp file
user#ubuntu1210:~$ cd /home/user/systemtap/systemtap-android/scripts/
user#ubuntu1210:~$ vi monitor_fopen.stp
#! /usr/bin/stap
probe begin
{
printf("start monitoring");
}
probe end
{
printf("end monitoring");
}
6. Build .ko file out of .stp file using compiled Kernel
user#ubuntu1210:~$ /home/user/systemtap/systemtap-android/installed/bin/stap
-p 4 -v
-a arm
-B CROSS_COMPILE=/home/user/Programs/arm-linux-androideabi-4.7/bin/arm-linux-androideabi-
-r /home/user/android/kernel/kernel_samsung_smdk4412/
-j /home/user/systemtap/systemtap-android/installed/share/systemtap/tapset/
-R /home/user/systemtap/systemtap-android/installed/share/systemtap/runtime/
-t -g -m monitor_fopen /home/user/systemtap/systemtap-android/scripts/monitor_fopen.stp
7. Install Systemtap Android App on the device that runs the custom Kernel
https://github.com/flipreverse/systemtap-android-app
8. Start the app and give the app root access
Superuser.apk should ask you whether Systemtap can have root access
9. Push the .ko file from step 6 to the sdcard
user#ubuntu1210:~$ adb push monitor_fopen.ko /sdcard/systemtap/modules/monitor_fopen.ko
10. Load the module
user#ubuntu1210:~$ adb shell
shell#android:/ $ su
root#android:/ # cd /data/data/com.systemtap.android
root#android:/data/data/com.systemtap.android # sh start_stap.sh
modulename=monitor_fopen
moduledir=/sdcard/systemtap/modules
outputname=monitor_fopen_2014.mm.dd_sss
outputdir=/sdcard/systemtap/stap_output
logdir=/sdcard/systemtap/stap_log
rundir=/sdcard/systemtap/stap_run
stapdir=/data/data/com.systemtap.android
:q!
11. Read result from loading the module
user#ubuntu1210:~$ adb shell
shell#android:/ $ cd sdcard/systemtap/stap_log/
shell#android:/sdcard/systemtap/stap_log $ cat monitor_fopen_2014.mm.dd_sss.txt
Loaded kernel module: monitor_fopen.ko
Output file: monitor_fopen_2014.mm.dd_sss.*
Error inserting module '/sdcard/systemtap/modules/monitor_fopen.ko': Unknown symbol in module
I have no idea in what step I went wrong. Does anyone have a clue?
thanks to #adelphus, he remembered me to use dmesg and I found the error:
Android: Unknown symbol _GLOBAL_OFFSET_TABLE_
With the help of this site I edited the Makefile of the kernel to
CFLAGS_MODULE = -fno-pic
Redoing all the other steps in my OP then worked.