find out fuses mountpoints on android - android

i'm developing the gentoo extractor of the dSploit application and i've found a problem.
now that user can choose a custom directory for the gentoo root,
we must ensure that we can make symlinks in that folder.
from android 4.2 and above, the storage infrastructure uses FUSE.
create symlink where the ext FS is mounted on is fine.
create symlink where the FUSE is mounted on will fail.
root#mako:/ # ln -s /system /storage/emulated/0/gentoo/test
link failed Function not implemented
root#mako:/ # ln -s /system /data/media/0/gentoo/test
this happens because /storage/emulated/0 is a fuse bind mount of /data/media/0.
i think that the solution is to find what is mounted where and how.
how can i get FUSE mounts ?
/proc/mount will show /dev/fuse as source block device.
i need to have something that say:
source destination
/data/media/0 /storage/emulated/0
in order to replace /storage/emulated/0 with /data/media/0 and got symlink to work.
thanks in advance for any help and suggestion.
-- tux_mind

i found a workaround/hack to list them.
when you open a file on the mountpoint the fuse FS handler will open it too.
i used this information and i wrote a small C program that use proc to find source directories.
if you are interested the project is hosted on github.
regards, tux_mind.

The way I use was to bind mount instead of symlink:
Copy than remove because mv won't work accross filesystems
cp -a /sdcard/DCIM /Removable/MicroSD/DCIM
rm -r /sdcard/DCIM
Create a mount point to bind DCIM on SD card.
mkdir /sdcard/DCIM
Finaly bind mount:
mount -o bind /Removable/MicroSD/DCIM /sdcard/DCIM
This work fine, but on reboot, You will have to re-mount your binds

Related

Android: Cannot read from external storage and cannot create folder in /storage/sdcard0

I have mounted an external ext4 hardrive from the device tree /dev/block/sda1 to /storage/emulated/legacy. My mainActivity is trying to access a file under /legacy/data/abc.txt. However it cannot get to it. The owner of /legacy/data is root.
Also, mainActivity tries to create a folder under /storage/sdcard0/results called folderx using foldername.mkdir(), but it cannot. /storage/sdcard0/results also is owned by root.
I have changed permission on both these folders using chmod 777. I suspect the problem is that root is the owner and mainActivity runs as a different user. However i dont know what the owner should be changed to.
Any ideas?
Formatting an external NTFS hard drive to use on a CHT RVP
mkfs -t ext4 /location/of/hdd
Edit platform.xml in /system/etc/permisssions: reference http://technofaq.org/posts/2014/04/fixing-external-sd-card-write-issue-on-android-kitkat/
Add an additional group definition for the external storage permissions : <group gid="media_rw" />
save the changes to the file
restart the device
Mount the formatted hard drive on CHT RVP:
mount -t ext4 /dev/block/sda1 /storage/sdcard1 /* /dev/block is the device tree, /storage/sdcard1 is the location where you are mounting the hard drive
Change owner of the /storage/sdcard1 to media_rw:
chown -R media_rw:media_rw /storage/sdcard1
Change permissions:
chmod -R 777 /storage/sdcard1
And done. You should be able to read/write to the external hard drive.

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.

Android ADB shell commands: Mount host PC folder?

Hope this isn't too much of an amateur/moron question: I'm trying to replace most ringtones and alarms (Dell Streak 5 (2.2.2 rooted)) with a few of my own pet sounds.
For reasons I won't bother you with, I can't use an SD card, so my .ogg replacements need be transferred straight from my PC to their respective default folders under /system/media/audio/ .
ADB push and pull commands don't seem to accept widlcards (which is a pain) but anyway, despite setting the system folder to rw, I get 'permission denied' when I tediously attempt to pull or push files one by one.
But I should be able to rm and cp interactively from ADB's shell # prompt, with simple Unix commands to transfer groups of files between the /system/media/audio folders and my Windows PC. But to do this I presumably need to mount my PC source folder, and I have no idea how to do this.
I'd be grateful for any info or ideas...
You need to have root access on the phone. My advice as a programmer would be to
1) Write a program to do this...
or just do it the easy way haha. Try this (your device must be rooted):
adb shell into your device using $> adb shell
move to the local folder using $> cd /data/local
Now create a directory for your tones with $> mkdir my_tones - this shouldn't require su
Next you must push your .ogg files from your computer to the /data/local/my_tones folder
Now you can become su user with $> su
Now you should be able to copy the files from the /data/local/my_tones directory to where ever it is you would like them.
Hope this helps.

Change file permission:/system/etc/bluetooth/audio.config

I use a Samsung Dart - SGH-T499 with Android v2.2.2 on it.
Now I need to edit the /system/etc/bluetooth/audio.config file. For that I rooted my phone using the SuperOneClickv2.3.3-ShortFuse. And browsed the file-system using Root Explorer. But I am unable to edit the permission of the audio.config. Could you please help me?
You also need to ensure that the /system directory, as it's a filesystem, is mounted read-write. In the adb shell use -o rw,remount as parameters to the mount command to do this. First you need to determine what ( hardware / physical / logical ) device that particular filesystem is stored on - use the mount command on its own to see the list and select the one which has /system as its mount point.
Can you not issue a
chmod 777 /system/etc/bluetooth/audio.config
...from the adb shell?

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.

Categories

Resources