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.
Related
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
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
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.
Context:
I designed an embedded system and I ported Android Gingerbread to run on it. I use an ARM Cortex-A8 based CPU module that has the CPU, SDRAM, NANDFLASH on it and all the rest available on module pins so I can add my own hardware interfaces. The first one came with u-boot pre-installed. All I had to do to install my Gingerbread was to place the 4 images (kernel.img, system.img, ramdisk-yaffs.img and userdata.img) in a directory (/sdfuse) on the SD-CARD and just burn it to the on-board NANDFLASH using command "sdfuse flash kernel kernel.img" and the equivalent commands for the other 3 files. Simple enough. After that, I use the SDCARD in Android as an external storage. (Life was good!)
The Problem:
Now I bought more modules and they did not come with u-boot pre-loaded. So, I need to make a bootable SDcard with u-boot on it. It needs to be FAT in order to be recognized by my processor at boot time. I actually have a SDHC 4GB card in FAT32, successfully installed U-boot and it boots my system up to the u-boot prompt telling me it can't find the 4 image files. It's expected since the images are not there yet. The problem is now I can't create the /sdfuse folder and put the 4 image files on it. Neither my MACBook nor my Ubuntu machine let me mount that SDcard anymore to create the "/sdfuse" folder on it. Both diskmanagers see the SD-Card but neither allow to mount it. Obviously, I missed something somewhere. What I have now is a bootable 4GB FAT32 SD-Card with U-boot on it but the rest of the card is not usable anymore. Anybody knows what the problem could be? Why can't I use this 4GB bootable FAT32 partition to install my "/sdfuse" folder with the images? I used a Ubuntu machine to create the bootable SD-Card so, the USB/SD-Card reader is working well, in other words, the problem is not hatdware but some software configurations of some sort.
EDIT following Chris Stratton comment about file system:
I have an SD Card containing the "/sdfuse" with the 4 image files (kernel.img etc) and a bunch of other file and folders. With Ubuntu Diskutility, I can see it as one partition W95 FAT32 (LBA) (0x0c) Master Boot Record. I can read/write just about anything on it from Ubuntu and MacOSX. The second SD-Card that I made is also seen has one FAT32 partition Master Boot Record, type W95 FAT32 (LBA) (0X0c) but I can't mount it neither from Ubuntu (but seen under /dev/sdb) nor MacOSX. That last one, is the one with u-boot on it. Just strange! Just to work around the problem, I just had an idea so I can keep working, I just tried to boot with the "u-boot SD-Card" then, I changed the SD-Card "live" for the one with the 4 files. I used the command "sdfuse" to flash u-boot, kernel, android etc to my NANDFLASH device. Then, when I force a reboot from NAND, it boots into Android. It is OK for development but this is way too complicated for a production procedure. Chris Stratton is probably right when he points to a filesystem partition or structure. I just did not figure it out yet. Anybody has some clues?
After running from Ubuntu Terminal "dmesg | tail", I get the following results:
dmesg | tail
[5871490.553791] sd 16:0:0:0: [sdb] 7829504 512-byte logical blocks: (4.00 GB/3.73 GiB)
[5871490.556190] sd 16:0:0:0: [sdb] Write Protect is off
[5871490.556197] sd 16:0:0:0: [sdb] Mode Sense: 03 00 00 00
[5871490.556201] sd 16:0:0:0: [sdb] Assuming drive cache: write through
[5871490.559054] sd 16:0:0:0: [sdb] Assuming drive cache: write through
[5871490.559064] sdb: sdb1
[5871490.563912] sd 16:0:0:0: [sdb] Assuming drive cache: write through
[5871490.563920] sd 16:0:0:0: [sdb] Attached SCSI removable disk
[5872079.044194] FAT: bogus number of reserved sectors
[5872079.044201] VFS: Can't find a valid FAT filesystem on dev sdb1.
So, it appears there is something wrong with the format even though the card boots and is seen has a W95 FAT32 (LBA)(0x0c)
EDIT following the Comment from TheCodeArtist
Here is how I create a "u-boot" bootable image disk. I run a script (on my Ubuntu machine) that was created by Samsung. Here is what is inside the script:
#
# Copyright (C) 2010 Samsung Electronics Co., Ltd.
# http://www.samsung.com/
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
####################################
reader_type1="/dev/sdb"
reader_type2="/dev/mmcblk0"
if [ -z $1 ]
then
echo "usage: ./sd_fusing.sh <SD Reader's device file>"
exit 0
fi
if [ $1 = $reader_type1 ]
then
partition1="$11"
partition2="$12"
partition3="$13"
partition4="$14"
elif [ $1 = $reader_type2 ]
then
partition1="$1p1"
partition2="$1p2"
partition3="$1p3"
partition4="$1p4"
else
echo "Unsupported SD reader"
exit 0
fi
if [ -b $1 ]
then
echo "$1 reader is identified."
else
echo "$1 is NOT identified."
exit 0
fi
####################################
# make partition
echo "make sd card partition"
echo "./sd_fdisk $1"
./sd_fdisk $1
dd iflag=dsync oflag=dsync if=sd_mbr.dat of=$1
rm sd_mbr.dat
####################################
# format
umount $partition1 2> /dev/null
umount $partition2 2> /dev/null
umount $partition3 2> /dev/null
umount $partition4 2> /dev/null
echo "mkfs.vfat -F 32 $partition1"
mkfs.vfat -F 32 $partition1
#echo "mkfs.ext2 $partition2"
#mkfs.ext2 $partition2
#echo "mkfs.ext2 $partition3"
#mkfs.ext2 $partition3
#echo "mkfs.ext2 $partition4"
#mkfs.ext2 $partition4
####################################
# mount
#umount /media/sd 2> /dev/null
#mkdir -p /media/sd
#echo "mount -t vfat $partition1 /media/sd"
#mount -t vfat $partition1 /media/sd
####################################
#<BL1 fusing>
bl1_position=1
uboot_position=49
echo "BL1 fusing"
./mkbl1 ../u-boot.bin SD-bl1-8k.bin 8192
dd iflag=dsync oflag=dsync if=SD-bl1-8k.bin of=$1 seek=$bl1_position
rm SD-bl1-8k.bin
####################################
#<u-boot fusing>
echo "u-boot fusing"
dd iflag=dsync oflag=dsync if=../u-boot.bin of=$1 seek=$uboot_position
####################################
#<Message Display>
echo "U-boot image is fused successfully."
echo "Eject SD card and insert it again."
Also, you can see there is a call to a function "sd_fdisk". I have the source code but it is also on Google code: sd_fdisk.c
I am trying to mount an sd card that I put into my tablet. The sd card is in ext2 format. I tried using BusyBox with the following command in my terminal app on the tablet:
busybox mkfs.ext2
But it seems I need to add some arguments to the command. What commands would I need to add to it? Or is there an easier way to mount the sd card?
I would like to not format the sd card as there is data on it; but whatever it takes to read it as ext2 format is ok.
you need to mount the ext2 filesystem not create the filesystem.
Depending on your tablet, the device in /dev could be different from my example. but in general you want to run a similar command :
busybox mount -t ext2 /dev/block/vold/179:2 /data/sd-ext
where /dev/block/vold/179:2 is the device that you are trying to mount.
and /data/sd-ext is the path where you want to mount your sd card to.
here's the help page for the mount command
1|shell#android:/ $ busybox mount -t
option requires an argument -- t
BusyBox v1.20.0.git (2012-03-21 01:44:00 GMT) multi-call binary.
Usage: mount [OPTIONS] [-o OPTS] DEVICE NODE
Mount a filesystem. Filesystem autodetection requires /proc.
-a Mount all filesystems in fstab
-f Dry run
-i Don't run mount helper
-r Read-only mount
-w Read-write mount (default)
-t FSTYPE[,...] Filesystem type(s)
-O OPT Mount only filesystems with option OPT (-a only)
-o OPT:
loop Ignored (loop devices are autodetected)
[a]sync Writes are [a]synchronous
[no]atime Disable/enable updates to inode access times
[no]diratime Disable/enable atime updates to directories
[no]relatime Disable/enable atime updates relative to modification time
[no]dev (Dis)allow use of special device files
[no]exec (Dis)allow use of executable files
[no]suid (Dis)allow set-user-id-root programs
[r]shared Convert [recursively] to a shared subtree
[r]slave Convert [recursively] to a slave subtree
[r]private Convert [recursively] to a private subtree
[un]bindable Make mount point [un]able to be bind mounted
[r]bind Bind a file or directory [recursively] to another location
move Relocate an existing mount point
remount Remount a mounted filesystem, changing flags
ro/rw Same as -r/-w
There are filesystem-specific -o flags.
Should be busybox mount /dev/block/something /mountpoint. mkfs creates a filesystem like format in Windows
http://www.busybox.net/downloads/BusyBox.html#mount
Or is there an easier way to mount the sd card?
It usually happens automatically, check busybox mount without arguments if it is already mounted somewhere.