Mount boot partition on Galaxy S4 (i9500) (CyanogenMod 12.1) - android

I'm interesting in make some changes in init.rc file.
As I have read, I must get copy of boot.img, unpack it, add my changes to init.rc file, pack and push back new boot.img to phone, and after reboot my changes will be considered. (I can't just change init.rc file, that is at / directory, due to it will be rewritten at next reboot.)
So I try:
adb shell
su
fdisk -l /dev/block/mmcblk0
fdisk outputs list of all partition (mounted and unmounted) which are on phone.
I'm intersting in boot:
9 147456 163839 8192K 0700 BOOT
where 9 - is partition number, so my partition (device to mount) is /dev/block/mmcblk0p9.
Then I remount rootfs to read/write permissions:
mount -o rw,remount rootfs /
Create directory (mount point) /boot:
mkdir /boot
And then try to mount boot partition to /boot:
mount -t auto /dev/block/mmcblk0p9 /boot
but retrive "mount: No such device".
Are anybody faced with this ?
Thanks in advance for you help.
PS:
List of partitions can be also obtained by:
ls -l /dev/block/platform/dw_mmc.0/by-name
Edited:
I have sources, but I don't want to rebuild their, due to a large amount of time compilation. (I must make many changes in init.rc file and recompile all CyanogenMod it's very expensive).
I have tried to build only module tied, as I think, with init.rc (system/core/rootdir), just type mmp:
ila:~/cm_s4/cm_12_1/system/core/rootdir$ mmp
and obtained next line:
Install: /home/ila/cm_s4/cm_12_1/out/target/product/i9500/root/init.rc
but, no line such as (for example, when I type mmp in external/hello_world):
Pushing: /system/bin/hello_world

Related

How to mount an external drive's ext4 partition on android and make it rw-available to all the apps

I have written the following shell script:
alias mount='/system/xbin/busybox mount'
set -e
set -x
MNT=sda1
function mkdir_ext() {
if [ ! -d $1 ]; then
mkdir -p $1
fi
chown $2 $1
chmod $3 $1
}
mkdir_ext /storage/emulated/$MNT root:media_rw 777
mount -t ext4 /dev/block/$MNT /storage/emulated/$MNT
mkdir_ext /data/media/$MNT root:media_rw 777
sdcard -u 1023 -g 1023 /storage/emulated/$MNT /data/media/$MNT
After executing the commands above, mount reports:
root#NEO-X8:/sdcard # mount|grep sda
/dev/block/sda1 /storage/emulated/sda1 ext4 rw,seclabel,relatime,data=ordered 0 0
/dev/fuse /data/media/sda1 fuse rw,nosuid,nodev,relatime,user_id=1023,group_id=1023,default_permissions,allow_other 0 0
I am working via ssh, remotely, using rooted ssh/sftp daemon, and while logged in as root, I can list the files in /storage/emulated/sda1.
From what I understand, android is case-insensitive in regards to filesystems by design, so the filesystem has to be fused.
The problem is, I see just an empty directory in /data/media/sda1. Even stranger is that, if I navigate to /storage/emulated/sda1 from the device as root with bash shell X, I also see an empty directory.
I have tried different other apps and I've tried to also use sdcard_rw instead of media_rw (with the uid / gid 1015 instead of 1023), nothing works.
How to get ext4 to work for all apps on a rooted Minix NEO X8-H? Using anything but ext4 is not an option, the 4TB drive already contains important data. As a side note, sda1 is just a small 1GB partition.
I will assume that your device is rooted from what you have done so far so will not go into that. Though I cannot be certain this is your issue I shall explain how I solved a similar problem.
Resent versions of android with the intent on improving device security are now using the (somewhat half arsed) feature of making mounts performed by most processes not visible to other processes. Working around this is frustratingly device specific, however it appears the Minix NEO X8-H is using a "vanilla" style source build of android. Therefore you have a good chance of using StickMount in order to mount the USB stick, it should enable the global mounting of USB devices running any file-system supported by your ROM (which should include ext4 given you have already mounted it before).
I have not tested this personally on your device so cannot guarantee it will work but have had success with a number of other android devices so this is certainly worth a shot.
I use mkfs -t ext4 /dev/sdf2 format SDcard and insert into samsung s4 anrdoid phone.
adb shell
su
mount /dev/block/mmcblk1p2 /root
I cant't mount this SDcard, I have googled it but no solution.
The last, I found this can succeed :)))
mk2fs -t ext4 /dev/sdf2
and ...

Can't mount system android : read file only [duplicate]

I recently rooted my Droid X and everything seems to be working perfectly. I made some changes to build.prop and when I do adb push build.prop /system/ I get the following error: failed to copy 'c:\build.prop' to '/system//build.prop': Read-only file system.
How can I fix this?
Not all phones and versions of android have things mounted the same.
Limiting options when remounting would be best.
Simply remount as rw (Read/Write):
# mount -o rw,remount /system
Once you are done making changes, remount to ro (read-only):
# mount -o ro,remount /system
adb remount
works for me and seems to be the simplest solution.
While I know the question is about the real device, in case someone got here with a similar issue in the emulator, with whatever tools are the latest as of Feb, 2017, the emulator needs to be launched from the command line with:
-writable-system
For anything to be writable to the /system. Without this flag no combination of remount or mount will allow one to write to /system.
After the emulator is launched with that flag, a single adb remount after adb root is sufficient to get permissions to push to /system.
Here's an example of the command line I use to run my emulator:
./emulator -writable-system -avd Nexus_5_API_25 -no-snapshot-load -qemu
The value for the -avd flags comes from:
./emulator -list-avds
Got this off an Android forum where I asked the same question. Hope this helps somebody else.
On a terminal emulator on the phone:
mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
Then on the cmd prompt, do the adb push
I think the safest way is remounting the /system as read-write, using:
mount -o remount,rw /system
and when done, remount it as read-only:
mount -o remount,ro /system
adb disable-verity
adb reboot
adb root
adb remount
This works for me, and is the simplest solution.
On my Samsung galaxy mini S5570 (after got root on cellphone):
Fist, as root, I ran:
systemctl start adb
as a normal user:
adb shell
su
Grant root permissions on touch screen
mount
list all mount points that we have and we can see, in my case, that /dev/stl12 was mounted on /system as ro (ready only), so we just need do:
mount -o rw,remount /dev/stl12 /system
Try the following on the command prompt:
>adb remount
>adb push framework-res_old.apk /system/framework-res.apk
Here is what worked for me. I was running an emulated Android 7.1.1 (Nougat) device.
On a terminal, I hit the following command. One thing to be noticed is the -writable-system flag
./emulator -writable-system -avd Nexus_6_API_25 -partition-size 280
On another tab
./adb shell
su
mount -o rw,remount -t ext4 /dev/block/vda /system
All the changes that you do on the /system contents will survive a restart.
I checked with emulator and following worked.
adb reboot
adb root && adb remount && adb push ~/Desktop/hosts /system/etc/hosts
As mentioned above as well, execute second step in single shot.
Open terminal emulator on the phone:
then
adb shell
after that daemon is started
su
mount -o rw,remount /mnt/sdcard
then the read only is converted into the read-Write.
Sometimes you get the error because the destination location in phone are not exist. For example, some android phone external storage location is /storage/emulated/legacy instead of /storage/emulated/0.
mount -o rw,remount /dev/stl12 /system
works for me
This worked for me
#Mount as ReadOnly
su -c "mount -o rw,remount /system"
# Change Permission for file
su -c "chmod 777 /system/build.prop"
#Edit the file to add the property
su -c "busybox vi /system/build.prop"
# Add now
service.adb.tcp.port=5678
# Reset old permissions
su -c "chmod 644 /system/build.prop"
# Mount as readonly again once done
su -c "mount -o ro,remount /system"
I found this article from google, and thought I'd add the steps necessary on a Sony Xperia Z (4.2.2).
The Sony has a watchdog process which detects when you've changed ro to rw on / and /system (these are the only ones I was trying to modify) and possibly others.
The following was what I ran to perform the changes I was trying to achieve. I pasted these into a window, because removing the execute bit from /sbin/ric needs to be done quickly in order to stop it restarting itself. (I tried stop ric; this doesn't work - although it worked on a previous version of android on the phone).
pkill -9 ric; mount -o rw,remount -t rootfs /
chmod 640 /sbin/ric
mount -o rw,remount /system
I modified the hosts file here, so this is the place you make the changes you need to the filesystem. To leave things the way we found them, do this:
mount -o ro,remount /system
chmod 750 /sbin/ric
mount -o ro,remount -t rootfs /
At which point ric should automatically restart. (It restarted for me automatically.)
Adding a little bit more to Jan Bergström's answer: Because Android is a Linux based system, and the path in Linux contains forward slashes(../), while using push command, use "/" to define destination path in the Android device.
For Example, the command goes: adb push C:\Users\admin\Desktop\1.JPG sdcard/pictures/
Notice that here, back slashes are used to define source path of the file to be pushed from windows PC and forward slashes are used to define destination path because Android is a Linux based system. You don't have to act as a root to use this command and also, it works perfectly fine on production devices.
Thanks, Sérgio, for "mount" command without parameters idea.
I'd need to made adb push into /data/data/com.my.app/lib for some test issue, and get "Read-only filesystem" message.
ls command shows me:
root#android:/ # ls -l /data/data/com.my.app/
drwxrwx--x u0_a98 u0_a98 2016-05-06 09:16 cache
drwxrwx--x u0_a98 u0_a98 2016-05-06 09:04 files
lrwxrwxrwx system system 2016-05-06 11:43 lib -> /mnt/asec/com.my.app-1/lib
So, it's understood, that "lib" directory is separated from other application directories.
Command
mount -o rw,remount /mnt/asec
didn't resolve "r/o fs" issue, it wants device parameter before directory parameter.
"df" command didn't help also, but shows that my /mnt/asec/com.my.app-1 directory is at the separate mount point.
Then I looks by mount and voila!
root#android:/ # mount
.........
/dev/block/dm-4 /mnt/asec/com.my.app-1 ext4 ro,dirsync,relatime 0 0
Next steps are already described upwards: remount to RW, push and remount back to RO.
it sames that must extract and repack initrc.img and edit init file with the code of mount /system
Copy files to the SD-card?
Well, I assume you like to copy data to the Sd-card from the developers computer? You might have rooted the devise and made the area you address available?) I had about the same problem to upload data files for my application(Android Studio 1.3.2 in Win7), but.
First the adb command-shell has to be found in th path:
PATH=%PATH%;C:\Users\XXXXX\AppData\Local\Android\sdk\platform-tools (the folder AppData is hidden, so you have to set the folder setup not hiding concealed files and folder to find it, Path works regardless)
You have to spell the folder path right or you get a read-only error message, most likely it must start with /sdcard or it is read only area. As soon as I did no problem pushing the file to the emulator.
So for instance the the adb command can look like this:
adb push C:\testdata\t.txt /sdcard/download/t.txt
If there's a failure in copying the read-only file you can try locating the original file in the root directory and modify it with a root text editor (preferably) RB text editor, it comes with ROM Toolbox app.
Try this in a Terminal Emulator as root:
restorecon -v -R /data/media
In my case I was using the command adb push ~/Desktop/file.txt ~/sdcard/
I changed it to ~/Desktop/file.txt /sdcard/ and then it worked.
Make sure to disconnect and reconnect the phone.
As chen-xing mentioned the simplest way is:
adb reboot
But for me I had to change my settings first:
Settings → Developer options → Root access
Make sure ADB has Root access:
I just only needed this:
su -c "mount -o rw,remount /system"

How to execute a file on /sdcard?

I'm trying to run sqlite3 on my rooted Nexus 4. I've gotten as far as pushing the executable to /sdcard but I cannot execute it. I'm running stock Android 4.3, rooted with SuperSU 1.45.
The file looks like this:
-rw-rw-r-- root sdcard_rw 36860 2013-09-30 17:29 sqlite3
So far:
chmod 777 sqlite3 does nothing
File.setExecutable() returns false (but File.exists() returns true).
Is there a better way to do this?
SD cards are usually formatted as FAT32 and mounted with all files unexecutable. SD card directory on Nexus 4 is a simulated one, but still the system prevents any file in it to be marked as executable. You need to move your file outside of your SD card to mark it as executable.
I know this is an old question.
But I want to suggest another work around for this problem by creating disk .img file in sdcard then mount it on /data/
Well, I know it was quite redundant, but at the very least it could be used as workaround if your internal disk was low on space.
Here, some instructions in case needed.
adb shell to your device,
go to /sdcard (mouting point may vary on each device)
dd if=/dev/zero of=<your-new>.img bs=1M count=0 seek=2048. This creates a new image file called <your-new>.img change the seek value to the size you want (e.g 2048 = 2GB). If dd not available, try to install busybox first, then from dd change into busybox dd
Format <yout-new>.img, in my case I used ext2. eg. mke2fs -F ubuntunew.img
Mount <your-new>.img to /data. eg. mount -o loop /sdcard/<your-new>.img /data/<your-mount-point>. If mount command not available use busybox.
Ok. That's all
References:
https://forum.xda-developers.com/showthread.php?t=2743108
https://linuxonandroid.uservoice.com/knowledgebase/articles/74683-how-to-i-give-linux-more-space
chmod 777 sqlite3 does nothing...
chmod +x doesn't work... I get "bad mode".
The "Bad Mode" is from a+x, +x, etc. Remember, its octal. Try:
chmod 0777 sqlite3
And Yuichi is probably correct - /mnt/sdcard is likely mounted with noexec.

How to mount the android img file under linux? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
Recently, I'm interest in the android rom, I want to change and rebuild them.
So, I did some test on my XOOM, it's very easy to flash something into the machine.
I got some ROM from MOTOROLA (http://developer.motorola.com/products/software/),
they are some img file, and I want to know what's inside, I hope to unpack them.
I tried the unyaffs, it said broken img file.
I try to mount them, it works great on the system.img, and I can get the file inside.
When I want to mount userdata.img by mount -o loop userdata.img /mnt/userdata (the same as system.img), it tells me mount: you must specify the filesystem type so I try the mount -t ext2 -o loop userdata.img /mnt/userdata, it said mount: wrong fs type, bad option, bad superblock on...
So, how to get the file from the inside of userdata.img?
See the answer at: http://omappedia.org/wiki/Android_eMMC_Booting#Modifying_.IMG_Files
First you need to "uncompress" userdata.img with simg2img, then you can mount it via the loop device.
I have found a simple solution: http://andwise.net/?p=403
Quote
(with slight adjustments for better readability)
This is for all who want to unpack and modify the original system.img that you can flash using recovery.
system.img (which you get from the google factory images for example) represents a sparse ext4 loop mounted file system.
It is mounted into /system of your device. Note that this tutorial is for ext4 file system. You may have system image which is yaffs2, for example.
The way it is mounted on Galaxy Nexus:
/dev/block/platform/omap/omap_hsmmc.0/by-name/system /system ext4 ro,relatime,barrier=1,data=ordered 0 0
Prerequisites:
Linux box or virtual machine
simg2img and make_ext4fs binaries, which can be downloaded from the linux package android-tools-fsutils
Procedure:
Place your system.img and the 2 binaries in one directory, and make sure the binaries have exec permission.
Part 1 – mount the file-system
mkdir sys
./simg2img system.img sys.raw
sudo mount -t ext4 -o loop sys.raw sys/
Then you have your system partition mounted in ‘sys/’ and you can modify whatever you want in ‘sys/’. For example de-odex apks and framework jars.
Part 2 – create a new flashable system image
sudo ./make_ext4fs -s -l 512M -a system new.img sys/
sudo umount sys
rm -fr sys
Now you can simply type:
fastboot flash system new.img
In Android file system, "system.img" and "userdata.img" are VMS Alpha executable. "system.img" and "userdata.img" have the contents of /system and /data directory on root file system. They are mapped on NAND devices with yaffs2 file system. Now, yaffs2 image file can not be mounted on linux PC. If you can, maybe you got some rom that not packed in yaffs2 file system. You can check those rom file by execute the command:
file <system.img/userdata.img>
If it show "VMS Alpha executable" then you can use "unyaffs" to extract it.
Another option would be to use the File Explorer in DDMS (Eclipse SDK), you can see the whole file system there and download/upload files to the desired place. That way you don't have to mount and deal with images. Just remember to set your device as USB debuggable (from Developer Tools)
I have found that Furius ISO mount works best for me. I am using a Debian based distro Knoppix. I use this to Open system.img files all the time.
Furius ISO mount: https://packages.debian.org/sid/otherosfs/furiusisomount
"When I want to mount userdata.img by mount -o loop userdata.img /mnt/userdata (the same as system.img), it tells me mount: you must specify the filesystem type so I try the mount -t ext2 -o loop userdata.img /mnt/userdata, it said mount: wrong fs type, bad option, bad superblock on...
So, how to get the file from the inside of userdata.img?"
To load .img files you have to select loop and load the .img Select loop
Next you select mount
Select mount
Furius ISO mount handles all the other options loading the .img file to your /home/dir.

Read only file system on Android

I recently rooted my Droid X and everything seems to be working perfectly. I made some changes to build.prop and when I do adb push build.prop /system/ I get the following error: failed to copy 'c:\build.prop' to '/system//build.prop': Read-only file system.
How can I fix this?
Not all phones and versions of android have things mounted the same.
Limiting options when remounting would be best.
Simply remount as rw (Read/Write):
# mount -o rw,remount /system
Once you are done making changes, remount to ro (read-only):
# mount -o ro,remount /system
adb remount
works for me and seems to be the simplest solution.
While I know the question is about the real device, in case someone got here with a similar issue in the emulator, with whatever tools are the latest as of Feb, 2017, the emulator needs to be launched from the command line with:
-writable-system
For anything to be writable to the /system. Without this flag no combination of remount or mount will allow one to write to /system.
After the emulator is launched with that flag, a single adb remount after adb root is sufficient to get permissions to push to /system.
Here's an example of the command line I use to run my emulator:
./emulator -writable-system -avd Nexus_5_API_25 -no-snapshot-load -qemu
The value for the -avd flags comes from:
./emulator -list-avds
Got this off an Android forum where I asked the same question. Hope this helps somebody else.
On a terminal emulator on the phone:
mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
Then on the cmd prompt, do the adb push
I think the safest way is remounting the /system as read-write, using:
mount -o remount,rw /system
and when done, remount it as read-only:
mount -o remount,ro /system
adb disable-verity
adb reboot
adb root
adb remount
This works for me, and is the simplest solution.
On my Samsung galaxy mini S5570 (after got root on cellphone):
Fist, as root, I ran:
systemctl start adb
as a normal user:
adb shell
su
Grant root permissions on touch screen
mount
list all mount points that we have and we can see, in my case, that /dev/stl12 was mounted on /system as ro (ready only), so we just need do:
mount -o rw,remount /dev/stl12 /system
Try the following on the command prompt:
>adb remount
>adb push framework-res_old.apk /system/framework-res.apk
Here is what worked for me. I was running an emulated Android 7.1.1 (Nougat) device.
On a terminal, I hit the following command. One thing to be noticed is the -writable-system flag
./emulator -writable-system -avd Nexus_6_API_25 -partition-size 280
On another tab
./adb shell
su
mount -o rw,remount -t ext4 /dev/block/vda /system
All the changes that you do on the /system contents will survive a restart.
I checked with emulator and following worked.
adb reboot
adb root && adb remount && adb push ~/Desktop/hosts /system/etc/hosts
As mentioned above as well, execute second step in single shot.
Open terminal emulator on the phone:
then
adb shell
after that daemon is started
su
mount -o rw,remount /mnt/sdcard
then the read only is converted into the read-Write.
Sometimes you get the error because the destination location in phone are not exist. For example, some android phone external storage location is /storage/emulated/legacy instead of /storage/emulated/0.
mount -o rw,remount /dev/stl12 /system
works for me
This worked for me
#Mount as ReadOnly
su -c "mount -o rw,remount /system"
# Change Permission for file
su -c "chmod 777 /system/build.prop"
#Edit the file to add the property
su -c "busybox vi /system/build.prop"
# Add now
service.adb.tcp.port=5678
# Reset old permissions
su -c "chmod 644 /system/build.prop"
# Mount as readonly again once done
su -c "mount -o ro,remount /system"
I found this article from google, and thought I'd add the steps necessary on a Sony Xperia Z (4.2.2).
The Sony has a watchdog process which detects when you've changed ro to rw on / and /system (these are the only ones I was trying to modify) and possibly others.
The following was what I ran to perform the changes I was trying to achieve. I pasted these into a window, because removing the execute bit from /sbin/ric needs to be done quickly in order to stop it restarting itself. (I tried stop ric; this doesn't work - although it worked on a previous version of android on the phone).
pkill -9 ric; mount -o rw,remount -t rootfs /
chmod 640 /sbin/ric
mount -o rw,remount /system
I modified the hosts file here, so this is the place you make the changes you need to the filesystem. To leave things the way we found them, do this:
mount -o ro,remount /system
chmod 750 /sbin/ric
mount -o ro,remount -t rootfs /
At which point ric should automatically restart. (It restarted for me automatically.)
Adding a little bit more to Jan Bergström's answer: Because Android is a Linux based system, and the path in Linux contains forward slashes(../), while using push command, use "/" to define destination path in the Android device.
For Example, the command goes: adb push C:\Users\admin\Desktop\1.JPG sdcard/pictures/
Notice that here, back slashes are used to define source path of the file to be pushed from windows PC and forward slashes are used to define destination path because Android is a Linux based system. You don't have to act as a root to use this command and also, it works perfectly fine on production devices.
Thanks, Sérgio, for "mount" command without parameters idea.
I'd need to made adb push into /data/data/com.my.app/lib for some test issue, and get "Read-only filesystem" message.
ls command shows me:
root#android:/ # ls -l /data/data/com.my.app/
drwxrwx--x u0_a98 u0_a98 2016-05-06 09:16 cache
drwxrwx--x u0_a98 u0_a98 2016-05-06 09:04 files
lrwxrwxrwx system system 2016-05-06 11:43 lib -> /mnt/asec/com.my.app-1/lib
So, it's understood, that "lib" directory is separated from other application directories.
Command
mount -o rw,remount /mnt/asec
didn't resolve "r/o fs" issue, it wants device parameter before directory parameter.
"df" command didn't help also, but shows that my /mnt/asec/com.my.app-1 directory is at the separate mount point.
Then I looks by mount and voila!
root#android:/ # mount
.........
/dev/block/dm-4 /mnt/asec/com.my.app-1 ext4 ro,dirsync,relatime 0 0
Next steps are already described upwards: remount to RW, push and remount back to RO.
it sames that must extract and repack initrc.img and edit init file with the code of mount /system
Copy files to the SD-card?
Well, I assume you like to copy data to the Sd-card from the developers computer? You might have rooted the devise and made the area you address available?) I had about the same problem to upload data files for my application(Android Studio 1.3.2 in Win7), but.
First the adb command-shell has to be found in th path:
PATH=%PATH%;C:\Users\XXXXX\AppData\Local\Android\sdk\platform-tools (the folder AppData is hidden, so you have to set the folder setup not hiding concealed files and folder to find it, Path works regardless)
You have to spell the folder path right or you get a read-only error message, most likely it must start with /sdcard or it is read only area. As soon as I did no problem pushing the file to the emulator.
So for instance the the adb command can look like this:
adb push C:\testdata\t.txt /sdcard/download/t.txt
If there's a failure in copying the read-only file you can try locating the original file in the root directory and modify it with a root text editor (preferably) RB text editor, it comes with ROM Toolbox app.
Try this in a Terminal Emulator as root:
restorecon -v -R /data/media
In my case I was using the command adb push ~/Desktop/file.txt ~/sdcard/
I changed it to ~/Desktop/file.txt /sdcard/ and then it worked.
Make sure to disconnect and reconnect the phone.
As chen-xing mentioned the simplest way is:
adb reboot
But for me I had to change my settings first:
Settings → Developer options → Root access
Make sure ADB has Root access:
I just only needed this:
su -c "mount -o rw,remount /system"

Categories

Resources