Converting cache.rfs and datafs.rfs to (ext2/4) for packaging a ROM.tar

revant

Senior Member
Dec 29, 2010
56
61
0
Mumbai
Most of the ROMs with appropriate kernels come with ext2 for /system

and then convert the filesystems with the .convert file to data-ext4 and cache-ext2

so while i was messing around i tried this:

Required:
  • Kernel supporting filesystems,
  • factoryfs.rfs is already ext2 and has cwm recovery in it
  • stl7 and stl8 converted to desired filesystems
  • use a freshly flashed rom without any private data on /cache and /data for "dd" if you packaging it for people to download (just in case, it wont matter because it will get formatted on first boot itself)

create cache.rfs (12,45,184 bytes) and datafs.rfs (14,82,752 bytes) using terminal editor/adb

For datafs.rfs
Code:
# dd if=/dev/block/stl7 of=/sdcard/datafs.rfs bs=4096 count=362
it will create a datafs.rfs file in your sdcard which is (4096 x 362 = 14,82,752 bytes)

For cache.rfs
Code:
# dd if=/dev/block/stl8 of=/sdcard/cache.rfs bs=4096 count=304
it will create a cache.rfs file in your sdcard which is (4096 x 304 = 12,45,184 bytes)

now i packed it in a tar with a factoryfs.rfs (ext2) with recovery in it and flashed the rom

It showed CWM recovery on first boot,
Here i did a factory reset which formatted data cache and sd-ext into clean filesystems, then i fixed permissions superstitiously

This way ROM gets flashed and at the first boot itself the fs are converted to desired fs.

I don't know the quality of what i did or whether it has been done before or is it even correct..
but it worked :)

If you like it, thank me :)
if you don't, Ignore :)

Attached: my data (ext4) & cache (ext2) 2011-07-24
 

Attachments

Last edited:

Mohanshbhr

Senior Member
Jan 8, 2011
647
356
0
Mau, Lucknow
Most of the ROMs with appropriate kernels come with ext2 for /system

and then convert the filesystems with the .convert file to data-ext4 and cache-ext2

so while i was messing around i tried this:

Required:
  • Kernel supporting filesystems,
  • factoryfs.rfs is already ext2 and has cwm recovery in it
  • stl7 and stl8 converted to desired filesystems

create cache.rfs (12,45,184 bytes) and datafs.rfs (14,82,752 bytes) using terminal editor/adb

For datafs.rfs
Code:
# dd if=/dev/block/stl7 of=/sdcard/datafs.rfs bs=4096 count=362
it will create a datafs.rfs file in your sdcard which is (4096 x 362 = 14,82,752 bytes)

For cache.rfs
Code:
# dd if=/dev/block/stl8 of=/sdcard/cache.rfs bs=4096 count=304
it will create a cache.rfs file in your sdcard which is (4096 x 304 = 12,45,184 bytes)

now i packed it in a tar with a factoryfs.rfs (ext2) with recovery in it and flashed the rom

It showed CWM recovery on first boot,
Here i did a factory reset which formatted data cache and sd-ext into clean filesystems, then i fixed permissions superstitiously

This way ROM gets flashed and at the first boot itself the fs are converted to desired fs.

I don't know the quality of what i did or whether it has been done before or is it even correct..
but it worked :)

If you like it, thank me :)
if you don't, Ignore :)
Thanks a lot, i was searching the same thing for appearing cwm on first boot after flashing rom. when i flash new rom i will check it and i m sure that it will work
 

revant

Senior Member
Dec 29, 2010
56
61
0
Mumbai
I dont know why the CWM is seen on first boot.
May be because of error in filesystem
the output Cache.rfs and datafs.rfs are just initial bytes of the partition, if you get whole partition cache will be 6.0+ mB and datafs around 270 mB

But with this it is somehow managing to say to cwm that the fs is bad and CWM stops for us.. CWM seems to think it is certain type of fs and formats it to same type.

If you dont format (factory reset) the phone wont boot and the logcat will show error that it cannot create anything on /data
I tried "mkdir 123" in /data with adb and it gives IO error

but after format everything works fine.

and if you accidentally reboot and miss the CWM first time and the phone doesnt boot.. Just manually go to recovery and do factory reset