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
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 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 ...
I have a smartphone without the possibility to insert an SD-card.
I would like to make a dump of the biggest partition (cause I lost files and I'd like to use a dump to recover them).
The partition is 10GB.
I was looking for an ADB command to pull using dd but nothing...
I tried to use Carliv touch recovery with a 32GB usb key by OTG but the USB key didn't mount ... Then I couldn't use "dd" directly on the phone using Aroma file manager and a terminal emulation.
Thank you!
I don't understand why they closed a question that has already an accepted answer by linking a completely different question. Copying a file and copying a partition are 2 different things.
As said in comment, adb pull /dev/block/mmcblk0 mmcblk0.img worked for me. A "DD image" is only a binary image file of the device.
You want to copy a disk from your android device to your computer (preferably on your fastest drive) for faster and lossless analysis/recovery.
This is short step-by-step guide in windows (linux: scroll down) to achieve it using the linux tool dd intended for precise, bit-wise copies of data. Credits go to scandium on xda for the code, see his post for more details.
Prerequisites
make sure your device is rooted and busybox is installed
Windows:
install cygwin. During install, add netcat (under Net) and pv (under util-linux) packages; the standard install is located in C:\ so make sure you have enough disk space beforehand;
install adb e.g. through Android Studio. Make sure to add adb.exe executable file to the path variable to access it properly (guide).
Open two cygwin consoles/terminals (one sending data, one receiving data) and enter in one of the terminals to enter the device:
# terminal 1
adb forward tcp:5555 tcp:5555 # forward data over tcp connection
adb shell # open a connection
su # gain root access
BUSYBOX=/system/xbin/busybox # default location for most bb installers
# note: adapt the variable `BUSYBOX` to point to your install directory
# the TWRP default is `BUSYBOX=/sbin/busybox` (in case of bricked device)
Decide what partition to copy, the /dev/block/mmcblk0 partition is usually the one containing the data you typically would want.
In the following code, adapt the partition name according to 4. and quickly one after another type in terminal 1 and terminal 2:
# terminal 1
$BUSYBOX nc -l -p 5555 -e $BUSYBOX dd if=/dev/block/mmcblk0
# terminal 2
nc 127.0.0.1 5555 | pv -i 0.5 > $HOME/mmcblk0.raw
This saves the partition in the cygwin home directory (in a nutshell: it sends/receives output of dd over a tcp connection)
Look at the files / analysis
To mount the partition in Windows you can use (OSFmount).
To analyze the files I recommend Active# Undelete but there are tons of alternatives. With that program you can also directly load all partitions from the file (without mounting it, so step 5 is redundant in this case).
Guide for GNU/Linux users: install netcat and pv (step 1), use the Disks utility to analyze
Run as root:
adb root
Use dd to output content into stdout and write file on your computer:
adb shell 'dd if=/dev/block/platform/msm_sdcc.1/by-name/XXXXXX 2>/dev/null' > XXXXXX.img
Or all (see cat /proc/partitions)
adb shell 'dd if=/dev/block/mmcblk0 2>/dev/null' > mmcblk0.img
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.
I have placed an ubuntu.img file in a folder on my SD card as well as the following scripts obtained from - http://blog.coralic.nl/2010/08/17/ubuntu-on-samsung-galaxy-s-android/
/mnt/sdcard/ubuntu/start
#!/bin/bash
#Created by Armin Coralic http://blog.coralic.nl
if [ "$1" == "" ] ;
then
echo "You need to specify the img file!"
exit 9;
fi
if `test -d /data/local/mnt` ; then
echo "/data/local/mnt"
else
mkdir /data/local/mnt
fi
export HOME=/root
export USER=root
export PATH=$bin:/usr/bin:/usr/sbin:/bin:$PATH
mount -o loop,noatime -t ext2 $1 /data/local/mnt
sleep 3
mount -t proc proc /data/local/mnt/proc
mount -t devpts devpts /data/local/mnt/dev/pts
chroot /data/local/mnt /bin/bash
/mnt/sdcard/ubuntu/stop
#!/bin/bash
#Created by Armin Coralic http://blog.coralic.nl
umount /data/local/mnt/dev/pts
umount /data/local/mnt/proc
umount /data/local/mnt
After running the start script, I get an ubuntu chrooted shell, but I do not have access to my external storage SD card from within the chroot.
I would like to know the answer for the following two questions:
1) what is the /dev/block/ device file name for the external SD card
which I should mount on a Samsung
Galaxy S I9000?
2) what is the exact syntax that I should use before/after entering
chroot to get read/write/execute
access to the external SD storage?
It would be helpful if the start/stop scripts could be modified with the required changes.
You can check the block devices by running ls in /dev/block/
But actually, there are multiple ways to address the devices, for instance through vold, or sys etc.
you might check a file cald vold.fstab, it should give you an idea of which device is your external SD car