[Q] Extracting files from system images - Samsung Galaxy Nexus

Does anyone know what format is used to pack the stock system.img and userdata.img images for the Galaxy Nexus? I'm trying to extract the files from these images but not sure how to do so. So far I've tried unyaffs but it's segfaulting on the images, so I suppose these images aren't yaffs.

Try ext4 if unyaffs doesn't work
Sent from my PG86100 using xda premium

xHausx said:
Try ext4 if unyaffs doesn't work
Sent from my PG86100 using xda premium
Click to expand...
Click to collapse
Doesn't work, unfortunately...
Code:
> sudo mount -t ext4 -o loop system.img temp
mount: wrong fs type, bad option, bad superblock on /dev/loop0,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so
> dmesg | tail
[ 1790.501835] EXT4-fs (loop0): VFS: Can't find ext4 filesystem

Ah, so it's a special sparse ext4 image that needs to be converted to a normal ext4 image using one of the tools in AOSP.
http://forum.xda-developers.com/showthread.php?t=1081239
This worked.

Related

[GUIDE] Extract .rfs files

I came from HTC Hero to the Samsung Galaxy S GT-I9000
So I had never problems with cooking something up, but in the Galaxy I faced .rfs files and a flashing tool I can't use on linux...
So I searched through some boards to find a way to extract the .rfs files here a working guide for the S I9000.
What you need
Linux (tested with Debian testing)
It's pretty simple, execute this commands as root on your computer
SHORT WAY (thanks to mimocan)
Code:
# mount -o loop factory.rfs /some_dir
LOOOONG WAY
Attatch the rfs file to the loop device
Code:
# losetup /dev/loop0 /somedir/factoryfs.rfs
Create a directory to mount the device
Code:
# mkdir /somedir/mnt
Mount the device
Code:
# mount /dev/loop0 /somedir/mnt
the content of the rfs is NOT saved on the sdcard! you have to copy it!
Now you can copy the content from the /sdcard/tmp directory to the sdcard
Code:
# cp -R /somedir/mnt /somedir/factoryfs
hope this is helpful for someone
Code:
#mount -o loop factory.rfs /some_dir
should do the same
This works because rfs is based on vfat.
But have you ever tried this on cache.rfs or dbdata.rfs?
The mounted folder is empty. The cache.rfs in my case was around 1.2 mb.
Maybe the 1.2 mb are journaling data rfs uses?
I also tried mounting cache.rfs and dbdata.rfs directly on my sgs without any luck.
Since the phone has built in rfs drivers it should be able to mount it.
psternx said:
This works because rfs is based on vfat.
But have you ever tried this on cache.rfs or dbdata.rfs?
The mounted folder is empty. The cache.rfs in my case was around 1.2 mb.
Maybe the 1.2 mb are journaling data rfs uses?
I also tried mounting cache.rfs and dbdata.rfs directly on my sgs without any luck.
Since the phone has built in rfs drivers it should be able to mount it.
Click to expand...
Click to collapse
If you open the cache.rfs or dbdata.rfs from a PDA build (tested I900XXJP3) in a hexeditor you will see they are empty, just the headers and a lot of zeros
Have you been able to modify something from a rfs file and save it?
Actually Cache.rfs file in CSC is a renamed update.zip. At least with a few firmwares I have tried. So just open it with, for example, 7-zip and you can browse the files.
deleted............
Tried to mount a cache.rfs and got a "Device or resource busy".
Then tried to open it trough MagicISO, and voilá, I got the CSC files I needed
Now im into modifying factoryfs.rfs and hoping you can give me some tips.
Alt1
mount -o loop factoryfs.rfs directory & Copy files to a new place and edit them but how to create a .rfs from that point?
Alt2
sudo mount -v -o rw,loop,uid=$UID factoryfs.rfs Directory
Edit the files , umount the .rfs . Mount it again but the the changes are gone.
How do you do it?
Thanks.
a-son said:
Now im into modifying factoryfs.rfs and hoping you can give me some tips.
Alt1
mount -o loop factoryfs.rfs directory & Copy files to a new place and edit them but how to create a .rfs from that point?
Alt2
sudo mount -v -o rw,loop,uid=$UID factoryfs.rfs Directory
Edit the files , umount the .rfs . Mount it again but the the changes are gone.
How do you do it?
Thanks.
Click to expand...
Click to collapse
for me, i'll definitelty mod it elsewhere
ykk_five said:
for me, i'll definitelty mod it elsewhere
Click to expand...
Click to collapse
Thanks for answer.
Alt 1 i suppose you mean. But how to create the .rfs ?
a-son said:
Thanks for answer.
Alt 1 i suppose you mean. But how to create the .rfs ?
Click to expand...
Click to collapse
yess!!!!
how to recompile the .rfs ?????
KBJ911 said:
yess!!!!
how to recompile the .rfs ?????
Click to expand...
Click to collapse
BUMP!
Actually some cache.rfs aren't simple renamed zipfiles, as they (i.e. multi-csc) also contains more stuff
So I loopmounted rw the vfat cache.rfs, extracted and modified the contained sec_csc.zip (this one IS an update.zip structured file...)
But when I put it inside, sync, unmount and mount again to verify stuff, I got a corrupted filesystem and a corrupted zip file.
Any clue to successfully modify contents of such .rfs ?
mopodo said:
I came from HTC Hero to the Samsung Galaxy S GT-I9000
So I had never problems with cooking something up, but in the Galaxy I faced .rfs files and a flashing tool I can't use on linux...
So I searched through some boards to find a way to extract the .rfs files here a working guide for the S I9000.
What you need
Linux (tested with Debian testing)
It's pretty simple, execute this commands as root on your computer
SHORT WAY (thanks to mimocan)
Code:
# mount -o loop factory.rfs /some_dir
LOOOONG WAY
Attatch the rfs file to the loop device
Code:
# losetup /dev/loop0 /somedir/factoryfs.rfs
Create a directory to mount the device
Code:
# mkdir /somedir/mnt
Mount the device
Code:
# mount /dev/loop0 /somedir/mnt
the content of the rfs is NOT saved on the sdcard! you have to copy it!
Now you can copy the content from the /sdcard/tmp directory to the sdcard
Code:
# cp -R /somedir/mnt /somedir/factoryfs
hope this is helpful for someone
Click to expand...
Click to collapse
Is there a way to convert it back to rfs?
@all
Is there a way to convert it back to rfs?
criskelo said:
@all
Is there a way to convert it back to rfs?
Click to expand...
Click to collapse
If you used the shortway # mount -o loop factory.rfs /some_dir
than you can modify the files in some_dir.
when finished simple un mount the some_dir and the files are saved in the factory.rfs
Then tar and md5 the factory.rfs and you can flash it with odin
in windows use "magiciso" to extract .rfs
lownoise said:
Then tar and md5 the factory.rfs and you can flash it with odin
Click to expand...
Click to collapse
I lost at there, what does that means?
From linux
fastcx said:
I lost at there, what does that means?
Click to expand...
Click to collapse
From the linux command line you have to use
tar -cf filename.tar factory.rfs
md5sum filename.tar >filename.tar.md5
If you have extracted it with MagicISO and now just want to create it back to factoryfs.rfs can I do this with Cygwin and what would the command line be?

[Q] How to access Desire's dd image?

Hi there,
I have dd dump image of HTC Desire's system partition.
I dump as following.
#dd if=/dev/block/mtdblock2 of=/mnt/sdcard/Desire_System.dd bs=4096
My Desire is rooted.
I tried to mount my dd image to my Ubuntu machine as following.
#mount -t yaffs2 /usr/Desire_System.dd /mnt
However, my Ubuntu machine displayed "it is not a block device"
Could help me how to mount my dd image to Ubuntu machine and access to files of in image?
You need to create a loop device, then mount that.
Try
mount -o loop -t yaffs2 image.img directory.to.mount.on
Afaik Ubuntu doesn't support yaffs filesystem you'll have to compile a custom kernel if it doesn't.
You can use unyaffs to get at the contents but I can never get it to work with the dd method but does work with recovery images.
Sent from my HTC Desire using XDA App

Galaxy Nexus Firmware Image

https://groups.google.com/group/android-building/msg/43c3a418144fc6c5?pli=1
as a platform nexus prime (TI4460)
very similar to the iron in Kindle Fire(TI4430) /
her release will accelerate work on the ICS
Do you know which format are those img files?
Can not unpack system.img .
riverzhou said:
Do you know which format are those img files?
Can not unpack system.img .
Click to expand...
Click to collapse
ext4
mount it in linux
river-lap:/river/test # mount -t ext4 -o loop system.img t
mount: wrong fs type, bad option, bad superblock on /dev/loop0,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so
Any suggestion?
...or or or go here http://sourceforge.net/projects/ext2read/
and download that handy tool. allows a gui interface browsing of ext partitions or images and allows extracting thereof. no linux needed
riverzhou said:
river-lap:/river/test # mount -t ext4 -o loop system.img t
mount: wrong fs type, bad option, bad superblock on /dev/loop0,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so
Any suggestion?
Click to expand...
Click to collapse
try
losetup /dev/loop0 system.img
mount /dev/loop0 mnt-point/
If that doesn't work then paste the result of doing this to here (Unless you can figure that out yourself):
dd if=system.img | file -
I wanna rebuilt the system.img for kf, so linux is needed. Windows is no use for build android image .
On my linux:
river-lap:/river/gn/yakju-itl41f/a # losetup /dev/loop0 system.img
river-lap:/river/gn/yakju-itl41f/a # mount /dev/loop0 mnt/
mount: you must specify the filesystem type
river-lap:/river/gn/yakju-itl41f/a # dd if=system.img | file -
/dev/stdin: data
All not work.
riverzhou said:
I wanna rebuilt the system.img for kf, so linux is needed. Windows is no use for build android image .
On my linux:
river-lap:/river/gn/yakju-itl41f/a # losetup /dev/loop0 system.img
river-lap:/river/gn/yakju-itl41f/a # mount /dev/loop0 mnt/
mount: you must specify the filesystem type
river-lap:/river/gn/yakju-itl41f/a # dd if=system.img | file -
/dev/stdin: data
All not work.
Click to expand...
Click to collapse
Try
dd if=file.img | strings | head -20
and paste the result
river-lap:/river/gn/yakju-itl41f/a # dd if=system.img | strings | head -20
toolbox
toolbox
toolbox
toolbox
toolbox
toolbox
toolbox
toolbox
toolbox
toolbox
toolbox
toolbox
toolbox
toolbox
toolbox
toolbox
toolbox
toolbox
toolbox
toolbox
I did strings yesterday. It seems no difference :
river-lap:/river/gn/yakju-itl41f/a # strings system.img |head
toolbox
toolbox
toolbox
toolbox
toolbox
toolbox
toolbox
toolbox
toolbox
toolbox
Yeah, it might be yaffs then. Try using a utility for that
http://code.google.com/p/yaffs2utils/
[email protected] yakju-itl41f# dd if=system.img | strings | head -20
toolbox
toolbox
toolbox
toolbox
toolbox
toolbox
toolbox
toolbox
toolbox
toolbox
toolbox
toolbox
toolbox
toolbox
toolbox
toolbox
toolbox
toolbox
toolbox
toolbox
I get the same thing lol.
Here are my attempts to use unyaffs2
[email protected] yakju-itl41f# ./unyaffs2 -p 512 system.img /home/anthony/test/yakju-itl41f/
unyaffs2-0.2.3: image extracting tool for YAFFS2
image size (325426112) is NOT a mutiple of 512 + 16
operation incomplete
files contents may be broken
./unyaffs2 system.img /home/anthony/test/yakju-itl41f/
unyaffs2-0.2.3: image extracting tool for YAFFS2
image size (325426112) is NOT a mutiple of 2048 + 64
operation incomplete
Also tried regular ./unyaffs
[email protected] yakju-itl41f# ./unyaffs system.img
Segmentation fault (core dumped)
yareally said:
Yeah, it might be yaffs then. Try using a utility for that
http://code.google.com/p/yaffs2utils/
Click to expand...
Click to collapse
I can sure it's not yaffs.
I had unpacked some yaffs image files before.
riverzhou said:
I can sure it's not yaffs.
I had unpacked some yaffs image files before.
Click to expand...
Click to collapse
It looks like an ext4 filesystem image, just offset +40 bytes, but it's not complete, so not sure what is needed to make it complete.
Brandas said:
It looks like an ext4 filesystem image, just offset +40 bytes, but it's not complete, so not sure what is needed to make it complete.
Click to expand...
Click to collapse
Anybody know how to unpack this image now?
I am interesting in porting Galaxy Nexus ROM to Kindle Fire.
Finally, I find the way.
http://forum.xda-developers.com/showthread.php?p=5626296#post5626296
Why are you guys doing this?
Sent from my Galaxy Nexus using XDA App
JackpotClavin said:
Why are you guys doing this?
Sent from my Galaxy Nexus using XDA App
Click to expand...
Click to collapse
Trying to port Office Galaxy Nexus Rom to Kindle Fire.
My plan is based on the office rom, add some CM9's drivers and some linaro's performance components.
Of course, it need a new kernel too.
riverzhou said:
Finally, I find the way.
http://forum.xda-developers.com/showthread.php?p=5626296#post5626296
Click to expand...
Click to collapse
I was going to suggest the Android Kitchen, I've had to use it that way many times.
But what were you looking to remove from the nexus rom? You can download any rom for the nexus and it'll have the same stuff as that system image
Sent from my Galaxy Nexus using XDA App
Exactly. Just peruse the Nexus forum and find a stock rom. Easy enough.

ext4 extraction from system.sin issues

Hi,
As you probably know, ext4 image can be extracted from system.sin but cannot be mounted. When trying to mount it, it fails with :
[ 1476.821582] EXT4-fs (loop0): bad geometry: block count 262144 exceeds size of device (144631 blocks)
I open this thread just to share what I did around the issue and maybe have some helpful quotes about it
Here is what I did (under linux)
# First create an zero filled file. Size is system partition size (262144 blocks of 4096 each)
dd if=/dev/zero of=/home/xperia/virtualfs bs=4096 count=262144
# Attach file to loopback
sudo losetup /dev/loop0 /home/xperia/virtualfs
# Format it with same features as system partition on phone
sudo mkfs.ext4 -O has_journal,^ext_attr,^dir_index,^flex_bg,^huge_file,resize_inode,filetype,extent,sparse_super,large_file,^uninit_bg,^dir_nlink,^extra_isize -v /dev/loop0
# Write extracted system.sin.ext4 extracted image to loopback
sudo dd if=system.sin.ext4 of=/dev/loop0
# Mount filesystem
sudo mount /dev/loop0 /mnt
It can be mounted and I can have folder structure but I can't work with files. Editing default.prop gives me a non readable file.
But we can go a step ahead as we can now mount the image.
Still some issues have to be worked out.
The poit is, why we cant mount system.img on ICS but we can on GB?
maybe someone can contact with sony t oask
im extracting the .sin to .img like always but its impossible to mount.. what are you using to extract the .sin to a .ext4?
BTW, thanks for the info, i've been trying to modify system.img since ICS appeared.
EDIT: of, ext4 can be extracte with flashtool ~.~
maybe we need to read something from system.partinfo
Yakandu said:
The poit is, why we cant mount system.img on ICS but we can on GB?
maybe someone can contact with sony t oask
im extracting the .sin to .img like always but its impossible to mount.. what are you using to extract the .sin to a .ext4?
BTW, thanks for the info, i've been trying to modify system.img since ICS appeared.
EDIT: of, ext4 can be extracte with flashtool ~.~
maybe we need to read something from system.partinfo
Click to expand...
Click to collapse
Yes Flashtool can extract image from system.sin.
partinfo is partition information used by loader in flashmode to identify where to flash image on phone. (Something like start nand address of system partition)
so, any ideas why ext4 cant be mounted? maybe its encrypted or something..
Sorry for double post, i found a solution
Flash the system through a .ftf with flashtools
Flash a custom kernel with recovery (or the nozomi recovery)
Backup nandroid
We get a system.ext4.tar ··· move it to your developement folder
Create a folder (mkdir system)
Enter nautilus with root acces
Extract system files to the created folder
Modify whatever you want
Make a flashable system.img with: "./mkuserimg.sh -s /system ./system.img ext4 ./temp 1024M"
AND ITS WORKING!
Yakandu said:
Sorry for double post, i found a solution
Flash the system through a .ftf with flashtools
Flash a custom kernel with recovery (or the nozomi recovery)
Backup nandroid
We get a system.ext4.tar ··· move it to your developement folder
Create a folder (mkdir system)
Enter nautilus with root acces
Extract system files to the created folder
Modify whatever you want
Make a flashable system.img with: "./mkuserimg.sh -s /system ./system.img ext4 ./temp 1024M"
AND ITS WORKING!
Click to expand...
Click to collapse
This solution is already known
But my goal is to be able to mod a system partition without having to flash it before. And more, understand why extracted system image cannot be mounted and how to work this out
oh, ok xD
i didnt know that solution, its new for me
Yakandu said:
Sorry for double post, i found a solution
Flash the system through a .ftf with flashtools
Flash a custom kernel with recovery (or the nozomi recovery)
Backup nandroid
We get a system.ext4.tar ··· move it to your developement folder
Create a folder (mkdir system)
Enter nautilus with root acces
Extract system files to the created folder
Modify whatever you want
Make a flashable system.img with: "./mkuserimg.sh -s /system ./system.img ext4 ./temp 1024M"
AND ITS WORKING!
Click to expand...
Click to collapse
Have you already tried flashing this img on your device? I have already tried this solution twice but didn't succeed (@Spectre51 that's why I haven't replied your PM yet). system.img was succesfully created but I got boot loop when I flashed it on my device.
Hi Androxyde,
I figured it out, basically we have to dig further in sin format as new ext4 sins skips part of the file. See my thread for more details.
PS: Thanks for flashtool, it's a great tool!
LeTama
letama said:
Hi Androxyde,
I figured it out, basically we have to dig further in sin format as new ext4 sins skips part of the file. See my thread for more details.
PS: Thanks for flashtool, it's a great tool!
LeTama
Click to expand...
Click to collapse
:good:

Repack system.img with simg2img/mkuserimg

Has anyone been able to repack system.img using these tools? I've tried a couple variations of of parameters for mkuserimg, but everytime it gets stuck on the boot animation.
simg2img ./system.img system.raw
sudo mount -t ext4 -o loop system.raw ./mount/system/
sudo mkuserimg.sh -s mount/system/ system_new.img ext4 /system 3221028864
I've also tried
sudo mkuserimg.sh -s mount/system/ system_new.img ext4 /system 3195826176
Neither one works. The first one gets the file size of the .raw files to match, but the number of blocks (per tune2fs) differ. The second one gets the number of blocks to match, but not the .raw file sizes.
The base system.img I have flashes without any problems.
Appreciate any help!
Did you disabled the encryption in the boot.img ? It might be getting stuck since the signatures don't match. Have a look at the boot.img used to root. The fstab entries are relaxed. I think there is another change from stock.
gee one said:
Did you disabled the encryption in the boot.img ? It might be getting stuck since the signatures don't match. Have a look at the boot.img used to root. The fstab entries are relaxed. I think there is another change from stock.
Click to expand...
Click to collapse
Definitely using a boot.img with encryption disabled. Using this one: http://forum.xda-developers.com/apps/supersu/wip-android-6-0-marshmellow-t3219344
I've tried running both stock system.img through the repack process and a AOSP built system.img and both images stop working once run through mkuserimg
Maybe I'll give the ElementalX kernel a try.

Categories

Resources