[Q] System.img Editing Dev Help - Android Q&A, Help & Troubleshooting

Hi all,
im working on making a ROM for the Asus Transformer and im struggling a bit. im totall new to Linux, using mint and just getting used to it.
Basically im just trying to take a stock ROM and add root but adding superuser.apk and SU binary but im running into problems.
Asus Roms are a bit unusual, packed into blob files, ive unpacked that no problem, the system image is called blob.APP but its just the same as system.img just the name as i understand it.
ok so what ive done:
Code:
mkdir system
sudo mount -t ext4 -o loop blob.APP system/
so this mounts the ext4 fs as a loop device and allows me to copy the contents out
Code:
sudo cp -ar system new_system
then ive copied superuser.apk to /app and SU binary to /dev with drop and drag.
then make the filesystem image
Code:
sudo ./make_ext4fs -l 512m -a system blob.APP new_system/system
then just pack it up and flash it, flashing works fine, no errors but when i go to reboot it warns that theres no OS so somethings not worked. ive tried everything i can find googeling!
i just started learning linux on weds so go easy on me
any advice or help would be really great. thanks!

mkdir system here you will mount the old system
mkdir system_new here you will mount the new system
we now create the actual image
dd if=/dev/zero of=system_new.img bs=4k count=60000
bs=4k is the block size
count=60000 the number of blocks of 4kb size
so is something like 60000*4= 240000 which is actually 240 Mb
so it depends to you how big you want the image.
now we format the system.img in ext4
mkfs.ext4 system_new.img
Proceed anyway? (y,n) y
now we override the filesystem check
tune2fs -c0 -i0 system_new.img
Now we mount the the 2 directories that we created in the first step
mount -o loop system_new.img system_new/
mount -o loop system_new.img system/
Now we copy the contet of the old image to the new one with all the perimissions
cp -v -r -p system/* system_new/
We sinc the files
sync
We unmount the partitions
umount system_new/
umount system/
And voila, the system.img in ext4 is created.
Tips: you will need superuser acces.
if you will copy new files besides the ones from the old system you will have to set by hand all the permissions.
If you are using ubuntu just type
sudo su
and you will be root and no more sudo at each command.

Thank u so much for your guide this is exactly what I'm looking for so massive thanks!
So to add root I.can drop and drag superuser.apk and the binary into the new image?
Also do I need to worry about the android mountpoint?
Sent from my HTC Sensation Z710e using xda premium

yes you can do that, as long as you set the permissions right. (you can google for them)
and from what i remeber you will have to set also the ownership of the su, and superusers files
you need to do tests first, and then try
the mountpoint should be ok as it is now.

globula_neagra said:
mkdir system here you will mount the old system
mkdir system_new here you will mount the new system
we now create the actual image
dd if=/dev/zero of=system_new.img bs=4k count=60000
bs=4k is the block size
count=60000 the number of blocks of 4kb size
so is something like 60000*4= 240000 which is actually 240 Mb
so it depends to you how big you want the image.
now we format the system.img in ext4
mkfs.ext4 system_new.img
Proceed anyway? (y,n) y
now we override the filesystem check
tune2fs -c0 -i0 system_new.img
Now we mount the the 2 directories that we created in the first step
mount -o loop system_new.img system_new/
mount -o loop system_new.img system/
Now we copy the contet of the old image to the new one with all the perimissions
cp -v -r -p system/* system_new/
We sinc the files
sync
We unmount the partitions
umount system_new/
umount system/
And voila, the system.img in ext4 is created.
Tips: you will need superuser acces.
if you will copy new files besides the ones from the old system you will have to set by hand all the permissions.
If you are using ubuntu just type
sudo su
and you will be root and no more sudo at each command.
Click to expand...
Click to collapse
U said, we have to set permissions by ourselves. So what are the permissions that needs to be set when I add a new folder with an APK in it?

Sudo chmod 777 filepath/filename.apk
Sudo chmod a-rwx filepatch/filename.apk.
This is what I remember from top of my head. Google it a bit if it does not work from the first try as I have not used this like in 5 years.
If you allready have root you can you a file manager and just copy the file/folder where you want and set the permissions via thw file manager or using terminal commanda or via adb.
From what remember you can t make a folder in the apk folder as you won t be able to run the apk.

Related

[W-I-P][DEVELOPMENT] Dual / Multi Boot Project: Devs Only

{ LONG POST WARNING }
{ NOT FULLY WORKING YET}
{ NEEDS A LOT OF FURTHER DEVELOPMENT }
Hey everyone I had thought of making this Dual Booting system work along side recovery… because initially (with FreeX10-alpha) it was not possible to have both recovery & dual boot...
Thank you zdzihu & jerpelea for your great work on FreeX10-alpha, which booted off SDCARD… I got inspiration to try and make this work for FreeX10-beta4 based on the amazing work that u guys did! Thank you jerpelea for all your feedback on my repeated messages when I was testing this a few months back (hope I didn’t bother u too much with questions )...
zdzihu & jerpelea u are truly LEGENDS!!!
[This is just my personal opinion] Really hoping that some devs can take interest in this to provide compatible files (ramdisks, system files) for this to work… may be as an add-on to their main roms… please don’t keep bothering devs to create ramdisks for booting off SDCARD… they are already very busy trying to make our X10 better with faster and stable ROMS/MODS/etc… this is just an additional feature…
The basic idea was to use the chargemon booting scripts provided in FreeX10-alpha and to try and make FreeX10-beta4 to boot off SDCARD…
Initially I used the img files which came with FreeX10-alpha and wiped the image to then put FreeX10-beta4 on it… while doing so I realized that all of the symbolic links were not getting copied correctly (obviously)… so I started from scratch with blank ext2fs images…
Later I thought of using clean/base nandroid/recovery backups as they are already working/preconfigured system of FreeX10-beta4…
Following is a small How-To on converting NANDROID/RECOVERY images (with yaffs fs) to ext2 fs images keeping the symlinks intact!!
I have used Ubuntu for these steps.
I have attached blank_files.7z which contains precompiled ext2fs images:
system.img [size: 256 MB]
data.img [size: 512 MB]
cache.img [size: 128 MB]
To resize or create newer ext2fs images:
[APP] Windows: Create Your Own Data.img Maker Application, +/- From Existing data.img
U can use the commands provided there even in linux to create/resize these images...
We will keep the NANDROID images at:
Code:
/home/user/nandroid_imgs/test1/
and EXT2 FS images at:
Code:
/home/user/ext2fs_imgs/test1/
while temporary mounts points will be made at:
Code:
/home/user/mntpts/
We will be using unyaffs from here:
[How-To] Extracting/Accessing Recovery/Nandroid backup (.img) files
Extracting files from the nandroid/recovery backups:
Code:
cd /home/user/nandroid_imgs/test1
mv system.img /home/user/nandroid_imgs/test1/system/
cd /home/user/nandroid_imgs/test1/system/
sudo unyaffs system.img
mv system.img ../.
mv data.img /home/user/nandroid_imgs/test1/data/.
cd /home/user/nandroid_imgs/test1/data/
sudo unyaffs data.img
mv data.img ../.
mv cache.img /home/user/nandroid_imgs/test1/cache/
cd /home/user/nandroid_imgs/test1/cache/
sudo unyaffs cache.img
mv cache.img ../.
Loop mounting ext2 fs files:
Code:
sudo mount -t ext2 -o loop,rw,noatime,nodiratime /home/user/ext2fs_imgs/test1/system.img /home/user/mntpts/system/
sudo mount -t ext2 -o loop,rw,noatime,nodiratime,nosuid,nodev /home/user/ext2fs_imgs/test1/data.img /home/user/mntpts/data/
sudo mount -t ext2 -o loop,rw,noatime,nodiratime,nosuid,nodev /home/user/ext2fs_imgs/test1/cache.img /home/user/mntpts/cache/
Recursively copy all files (preserving symlinks) from extracted yaffs images to mount points
Code:
sudo cp -r -p /home/user/nandroid_imgs/test1/system/* /home/user/mntpts/system/.
sudo cp -r -p /home/user/nandroid_imgs/test1/data/* /home/user/mntpts/data/.
sudo cp -r -p /home/user/nandroid_imgs/test1/cache/* /home/user/mntpts/cache/.
Unmount the mounts:
Code:
sudo umount /home/user/mntpts/system/
sudo umount /home/user/mntpts/data/
sudo umount /home/user/mntpts/cache/
Ok now that the ext2fs iamges are populated with working files copy them onto SDCARD…
I have placed it at:
Code:
/sdcard/FreeX10
lets move on to the chargemon script...
This is, as of now, based off xRecovery chargemon (modified from FreeX10-alpha)
Code:
#!/system/bin/busybox sh
# modified chargemon for recovery + dual boot from NAND/SDCARD
/system/bin/charger
cat /dev/input/event2 > /dev/keycheck&
sleep 3
kill -9 $!
# intact recovery
if [ -s /dev/keycheck ]
then
# remount rootfs rw
mount -o remount,rw rootfs /
# Umount MTDs
umount -l /data
umount -l /cache
# Extract recovery
cd /
rm -r /sbin
rm -f etc
tar -xf /system/bin/xrecovery.tar
# Umount system
umount -l /system
chroot / /init
fi
echo "check if reboot into SDCARD OS was called"
if [ -e /data/local/tmp/rebootsdcardos ]
then
echo "Booting from SDCARD!"
# FreeX10-alpha code follows with slight modifications!!!
# remount rootfs rw
mount -o remount,rw rootfs /
busybox chmod 0777 /dev -R
busybox chown 0.2000 /dev/oncrpc -R
rm -r /sdcard
cd /
mkdir sd
chmod 777 sd
rm init*
rm logo.rle
rm default.prop
tar -xf /system/bin/sdcardos_ramdisk.tar
# Umount system,data,cache
umount -l /system
umount -l /data
umount -l /cache
# Check and mount SD Card
dosfsck -y /dev/block/mmcblk0p1
sleep 5
mount -t vfat -o rw,noatime,nodiratime /dev/block/mmcblk0p1 /sd
sleep 5
# Mount system and data ext2 images
losetup /dev/block/loop1 /sd/FreeX10/system.img
sleep 5
losetup /dev/block/loop2 /sd/FreeX10/data.img
sleep 5
losetup /dev/block/loop3 /sd/FreeX10/cache.img
sleep 5
e2fsck -y /dev/block/loop1
e2fsck -y /dev/block/loop2
e2fsck -y /dev/block/loop3
mount -t ext2 -o rw,noatime,nodiratime /dev/block/loop1 /system
sleep 5
mount -t ext2 -o rw,noatime,nodiratime,nosuid,nodev /dev/block/loop2 /data
sleep 5
mount -t ext2 -o rw,noatime,nodiratime,nosuid,nodev /dev/block/loop3 /cache
sleep 5
# zdzihu: hack-fix
if [ -e /data/data/com.android.providers.telephony/databases/telephony.db ]; then
/system/bin/chroot / /init
exit
fi
# Chroot :)
chroot / /init
# jump out of chargemon to skip NAND booting
exit
fi
echo "Booting from NAND!"
# remount rw
mount -o remount,rw rootfs /
cd /
rm -r /sdcard
rm init*
rm logo.rle
rm default.prop
tar -xf /system/bin/ramdisk.tar
# zdzihu: hack-fix
if [ -e /data/data/com.android.providers.telephony/databases/telephony.db ]; then
/system/bin/chroot / /init
exit
fi
chroot / /init
Recovery is intact so u can get into recovery the normal way… (press/tap back key after seeing SE text logo)
OS on NAND (normal system on MTD) will boot by default…
To reboot into OS on SDCARD issue the following commands in terminal emulator/adb shell:
Code:
touch /data/local/tmp/rebootsdcardos
reboot
NOW the OS should start booting off the SDCARD…
It completes commands in chargemon and then BootAnimation can be seen…
BUT HERE IS THE PROBLEM!
Check LOGCAT here: http://www.mediafire.com/?phxm3uqzp0dzzhb
here is wht J had to say:
jerpelea said:
as you can see in logcat
1.your prelink is not ok
2.you don't have something ok in initrd
3.you dont have all permisions ok on data
Click to expand...
Click to collapse
From my limited understanding we yet have to make a proper ramdisk (sdcardos_ramdisk.tar)… I feel the init.rc file has to be changed especially the following line (based off FreeX10-beta4 ramdisk):
Code:
mount yaffs2 [email protected] /system rw remount
mount yaffs2 [email protected] /data nosuid nodev
mount yaffs2 [email protected] /cache nosuid nodev
As for Multi-Booting:
We can keep adding different sections to chargmeon:
Code:
/data/local/tmp/rebootsdcardos1
/data/local/tmp/rebootsdcardos2
etc…
OR
possible solution for having both recovery and dual boot
and similarly keep adding ramdisks in NAND /system:
Code:
sdcardos1_ramdisk.tar
sdcardos2_ramdisk.tar
etc
So we can have as many OS/ROMs on SDCARD as u have free space… though we need to make specific ramdisks for each…
Hope this was slightly useful… and waiting for feedback from advance users on how we can get this working....
Lol, you're working very hard Doom! Keep going!
Doom! You are making enormous progress and helping a lot with Other Devs.
A Combination of a good rom and one of these additional Dual Boot would make x10 better than any Android mobile SE could deliver.
Thank you and I really pray to give SE a run for their money!
for someone thats always saying hes not a developer you sure as hell seem to know what your doing!
Keep up the great work, i hope to see this working flawlessly that would be awesome to be able to dual boot.
Whats the next steps in the project?
BULL3TPR00F said:
for someone thats always saying hes not a developer you sure as hell seem to know what your doing!
Keep up the great work, i hope to see this working flawlessly that would be awesome to be able to dual boot.
Whats the next steps in the project?
Click to expand...
Click to collapse
well i am not exactly a ROM developer and dont know much about how to compile libs/sources/etc...
next step is that we need to make compatible system files & ramdisk (init.rc) for dual booting
DooMLoRD said:
well i am not exactly a ROM developer and dont know much about how to compile libs/sources/etc...
next step is that we need to make compatible system files & ramdisk (init.rc) for dual booting
Click to expand...
Click to collapse
You may not be a rom developer but your an amazing commited x10 modder
Sent from my X10i TripNMiUI using XDA App
DooMLoRD said:
well i am not exactly a ROM developer and dont know much about how to compile libs/sources/etc...
next step is that we need to make compatible system files & ramdisk (init.rc) for dual booting
Click to expand...
Click to collapse
I am also excited buddy..... Once i get through my experiments i will surely like to focus on this as this will allow us to have more then one version of ROM on one machine.
Based on your first post
all i can get is we are getting the boot animation but not going after that.
i would suggest following things based on my experiments with ubuntu work.
use loops above 10 coz i suspect some loops are already in use during my ubuntu boot i am watching that loop7 is already created so i would suggest avoiding it.
also as we have been adding debug "we have reached here" style code can we do the same here that might help us.
also can we find any debug-able place i mean place where we can track the progress to get the position inside the rom so that we can understand except logcat where we are.
any progress or hurdles buddy.....
i am eager to test this .....
anantshri said:
any progress or hurdles buddy.....
i am eager to test this .....
Click to expand...
Click to collapse
sorry man havent had time to do any further testing for this... have been very busy with some personal work and kernel manager scripts...
DooMLoRD said:
sorry man havent had time to do any further testing for this... have been very busy with some personal work and kernel manager scripts...
Click to expand...
Click to collapse
Keep up the good Work Doom. ! and thx for your work
Sorry if its no help but there's a thread in the x10 mini pro section
http://forum.xda-developers.com/showthread.php?t=1084555
Sent from my SEX10 using XDA App
These are great news, keep on developing!
sent from my x10i with wolfbreaks CM 6.1.3 v006 undervolted, bb67
rtblittlebrown said:
Sorry if its no help but there's a thread in the x10 mini pro section
http://forum.xda-developers.com/showthread.php?t=1084555
Sent from my SEX10 using XDA App
Click to expand...
Click to collapse
they have posted exactly the same thing!
read my 1st post in this thread and then read the first few posts there
Ohk so since we now have one more option in Xrecovery i am back to my old suggestion.
however this time i will post my thought out in open so that if someone has required skills and time then they can work on .
I have an idea of using xrecovery as a boot menu.
process would be
1) Xrecovery to start everytime. (this needs some consideration.)
2) To have a timeout value if any key pressed before that then remain in menu otherwise boot to the os.
3) inside menu we should have options of all O.S. / ROM (os coz my intention are to run linux off dualboot) available with selection options.
4) ON selection it will just be the same procedure as already using in xrecovery 1.0 to handover the command to a script. and let it load.
5) boot menu if possible could be controlled by an outside file which we can edit just like grub.conf in linux.
Note : This will requires good understanding of booting process of X10i and c skills as xrecovery is written in complete c.
anantshri said:
Ohk so since we now have one more option in Xrecovery i am back to my old suggestion.
however this time i will post my thought out in open so that if someone has required skills and time then they can work on .
I have an idea of using xrecovery as a boot menu.
process would be
1) Xrecovery to start everytime. (this needs some consideration.)
2) To have a timeout value if any key pressed before that then remain in menu otherwise boot to the os.
3) inside menu we should have options of all O.S. / ROM (os coz my intention are to run linux off dualboot) available with selection options.
4) ON selection it will just be the same procedure as already using in xrecovery 1.0 to handover the command to a script. and let it load.
5) boot menu if possible could be controlled by an outside file which we can edit just like grub.conf in linux.
Note : This will requires good understanding of booting process of X10i and c skills as xrecovery is written in complete c.
Click to expand...
Click to collapse
point no.1 is easy... not an issue..
abt point 2 i think that too would be possible... a while loop with sleep function & wait for input/keppress
pt3 the newer xrecovery v1.0.0 already has something similar may be we can look into it to add "Boot NAND system" as first option
point no. 5 if possible WILL BE BRILLIANT!!!
@anantshri
dude may be these guys can help us:
http://forum.xda-developers.com/showpost.php?p=14354231&postcount=49
DooMLoRD said:
they have posted exactly the same thing!
read my 1st post in this thread and then read the first few posts there
Click to expand...
Click to collapse
Oops sorry..
Sent from my SEX10 using XDA App
rtblittlebrown said:
Oops sorry..
Sent from my SEX10 using XDA App
Click to expand...
Click to collapse
no dude thanks for the info... i have already contacted those guys for help... lets see may be they can help us out to get this working!!!
dual boot hint by Z
http://forum.xda-developers.com/showthread.php?t=1107111
something related

[Q] To devs... How to extract System.img

Hi guys..
Sorry If I'm posting this in the wrong section...
But can anyone guide me how to extract System.img from a Stock ROM as I'm planning to cook a custom ROM
If you would like to see some of my previous work for SGS1 look at my signature
You can try unyaffs in a cygwin environment or wunyaffs which is for windows.
For some reason I get access violation errors with stock roms for the Tab.
With HTC roms it was possible to dump the system.img with magiciso. Again with Tab roms this no longer works.
In CWM, after mounting /system:
make_ext4fs -l 568m -s /sdcard/system.img /system
This gives you a sparse system.img which you can turn into a Linux-mountable ext4 image with simg2img
Sorry i writed on wrong thread
In Linux you can do
mkdir tmp
sudo mount -o loop -t ext4 system.img ./tmp && cp -r ./tmp/* ./system/
sudo umount ./tmp
Sent from my Samsung Galaxy Tab 10.1 using Tapatalk
jamezelle said:
In Linux you can do
mkdir tmp
sudo mount -o loop -t ext4 system.img ./tmp && cp -r ./tmp/* ./system/
sudo umount ./tmp
Sent from my Samsung Galaxy Tab 10.1 using Tapatalk
Click to expand...
Click to collapse
I'm getting an error
Code:
sudo mount -o loop -t ext4 system.img ./tmp && cp -r ./tmp/* ./system
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
Nokia7Vista said:
I'm getting an error
Code:
sudo mount -o loop -t ext4 system.img ./tmp && cp -r ./tmp/* ./system
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
Click to expand...
Click to collapse
See the message I posted up above? You have to run the system.img through simg2img to make it mountable.
Sent from my Samsung Galaxy Tab 10.1
mabalito said:
See the message I posted up above? You have to run the system.img through simg2img to make it mountable.
Sent from my Samsung Galaxy Tab 10.1
Click to expand...
Click to collapse
oh ok,, Thanks
Nokia7Vista said:
oh ok,, Thanks
Click to expand...
Click to collapse
Hope this helps and welcome to the GT10.1 forum
Sent from my Samsung Galaxy Tab 10.1
You could always create a regular (non-sparse) image file using dd then mount it.
Command should be similar to ****, though I'm not sure if the busybox version of dd accepts bs=1M, it may require bs=1048576. (That's MB converted to B) And count is the number of MB you want the image to be.
Code:
dd if=/dev/zero of=squeeze.img bs=1M count=512
Then mount it like this:
Code:
mount -o loop,noatime -t ext4 /sdcard/debian/squeeze.img /data/local/debian/
*Pulled from a thread I wrote awhile back, you may be able to get away without using the "noatime" option.

B&N repartition SD card Boot

This is straight from the mSD card that they have been using at every B&N. So you can just do it yourself at your convenience.
Gives you 8GB of external storage and the rest is for Barnes and Noble content.
Thanks. But how should we use it? Copy to SD and reboot? Use Win32DiskImager write the image to a SD?
Sent from a Galaxy far, far away
Does it install version 1.42?
otisw said:
Does it install version 1.42?
Click to expand...
Click to collapse
I had 1.4.0 before, and still had it after.
Sent from a Galaxy far, far away
Did root remain intact?
Anxiyz said:
Did root remain intact?
Click to expand...
Click to collapse
No, it completely erases everything.
Sent from a Galaxy far, far away
Damn, I could have used that last week before I took my NT in and had them do it for me. Oh well. Thanks for posting it though.
.CRS. said:
Here is how I got it to work.
IT ERASES EVERYTHING SO BACKUP BEFORE YOU DO THIS
1. Put flashing_boot.img on the root of your sd card
2. Turn off Nook
3. Hold the power button and the N button until the black N flashes on and off
4. Push the power button to turn the nook back on
5. It will show a factory reset menu, just push the N button to continue
View attachment 955245
Sent from a Galaxy far, far away
Click to expand...
Click to collapse
Just a note. You must have stock recovery for this to work not CMW or other.
Failed Several Times
I tried this several times but my media storage was still 1GB. Do I need to write the attached image or just copy it straight forward. When just copying, I can't pursue with the factory reset.
Same thing here, tried several times and still getting 1GB
Ditto. I was able to perform a factory reset, but I still have just 1GB of user storage after the update.
I suspect the problem may have something to do with the NOOK Tablet not recognizing the microSD card. I've noticed when using ClockworkMod that sometimes I have to remove it and re-insert it before it's recognized -- but there's no way to tell whether the stock recovery is seeing the card or not.
I tried removing/re-inserting it a few times during one of the three attempts to use this img, but that didn't seem to help.
That's the issue I had, not recognizing the card itself. I even copied the file unto a different card altogether and same thing. Still working on it, not ready to give up on it just yet.
No luck here and I'm sure it's not my cards. The couple cards I've tried all work with CWM. I've tried 2 different 1GB cards, a 256MB card, a 4GB card and an 8GB card.... I don't feel like clearing out my 32GB card. I've tried both FAT and FAT32. Does this need a different format, such as ext2? I've also tried using Win32DiskImager to actually "write" the image to the card... This I only tried on the 256MB.
jmeyerhead, any chance of getting a MD5 checksum? I have f94cd4df7351f81a2623f15e1853e205 .
CRS... Did you do anything that the rest of us haven't listed? Did you download from a different location?
EDIT: I'm also running the stock recovery. I run CWM off SD when I need it.
To use this you will need a 50MB FAT32 LBA Bootable partition with MLO, u-boot.bin from b&n update 1.4.2 and flashing_boot.img from the first post.
I extracted the kernel and ramdisk and they have a couple of shell scripts to do all the work.
However the scripts refer to a second ext3 partition on the sdcard which will allow you to reinstall the tablet from scratch as they do in the factory
I was able to pull the executables genpart make_ext4fs mkdosfs simg2img busybox etc and push them to my nook running with clockwork mod. Then inside a adb shell I was able to restore my tablet completely the only files I needed were the rombackup.zip from the original so that I retained my serial etc
Here is a approximate record of the steps I did inside the adb shell
Code:
#!/bin/sh
export emmc_total_sectors=31129600
export disk_total_sectors=31117905
export disk_media_sectors=25165823
./genptable ptable.new
# Enable performance mode
echo 4 > "/sys/devices/platform/mmci-omap-hs.1/mmc_host/mmc0/mmc0:0001/power_class"
./busybox dd if=/dev/zero of=/dev/block/mmcblk0 bs=4096 count=256 conv=notrunc,fsync
./busybox if=ptable of=/dev/block/mmcblk0
./busybox dd if=MLO of=/dev/block/mmcblk0p1
./busybox dd if=u-boot.bin of=/dev/block/mmcblk0p2
./busybox dd if=recovery.img of=/dev/block/mmcblk0p3
./busybox dd if=boot.img of=/dev/block/mmcblk0p4
./mkdosfs -F32 -n rom /dev/block/mmcblk0p5
./mkdosfs -F32 -n bootdata /dev/block/mmcblk0p6
./mkdosfs -F32 -n MyNook /dev/block/mmcblk0p10
./make_ext4fs -L factory /dev/block/mmcblk0p7
./make_ext4fs -L system /dev/block/mmcblk0p8
./make_ext4fs -L cache /dev/block/mmcblk0p9
./make_ext4fs -L userdata /dev/block/mmcblk0p11
./busybox mkdir -p /mnt/factory
./busybox mkdir -p /mnt/rom
./busybox mkdir -p /mnt/bootdata
./busybox mount -t ext4 /dev/block/mmcblk0p7 /mnt/factory
./busybox mount -t vfat /dev/block/mmcblk0p5 /mnt/rom
./busybox mount -t vfat /dev/block/mmcblk0p6 /mnt/bootdata
cd /mnt
/tmp/byhand/busybox unzip /tmp/byhand/rombackup.zip
cd /tmp/byhand
./busybox dd if=/dev/zero of=/mnt/bootdata/BCB bs=1088 count=1
./busybox dd if=/dev/zero of=/mnt/bootdata/BootCnt bs=4 count=1
./busybox umount /mnt/rom
./busybox umount /mnt/bootdata
./busybox cp factory.zip /mnt/factory/
./busybox cp rombackup.zip /mnt/factory/
cd /mnt/factory
/tmp/byhand/busybox unzip factory.zip romrestore.zip
cd /tmp/byhand
./busybox umount /mnt/factory
I did fiddle with the partition sizes a bit since I wanted 12.6GB so the exports at the beginning are different from what is in the flashing_boot.img
BIG FAT WARNING - I did this and it works form me don't try it unless you feel confident to recover from a clockworkmod booting off a sdcard
Well, mine is bricked. I can boot CWM SD though so I'm sure all is not lost. I'll have to experiment with it later. Just so everyone else knows I made formatted the disk as stated, copied the stated files. When I booted I immediately got a "software update" screen (I don't think I even held the n button down). Then once done it said to remove the card and restart.... never restarted (screen didn't light up, no 'n' screen, nada. I popped in my CWM SD and it did boot. Tried restoring a backup but that won't boot either. Should have stuck to the manual method or just gone in... I was hoping for something in the middle as far as complexity.
UPDATE: Ok, well I've gone in with Parted and let it correct the found errors (the expected ones reported in the manual formatting thread). Looking at the output from parted the repartitioning worked but something got screwed up. I've tried another restore after letting Parter do its thing but no joy. Is there anything else I should try while I'm in CWM and have ADB up? Any ideas?
Oh, and mine is a 16GB NT.... not 8GB and not Nook Color. I'm trying to download Adam's total wipe Ubuntu image but the host has exceeded its daily limit and the torrent is near dead.... So I'll just hurry up and wait while continuing to try different fixes via CWM.
EDIT: Read on. I did actually get my NT partitioned but ran into some issues with the file system I didn't expect. Thanks to meghd00t everything is now working perfectly... Read on.
if you have a copy of acclaim_update.zip for 1.4.0 or the b&n updates for 1.4.1.or 1.4.2 rename the file to acclaim_update.zip put it on the root of a FAT32 formated sd card and boot the nook by inserting the usb cable
if the steps from my previous post have worked all you need is a partition table MLO u-boot.bin boot.img recovery.img and rombackup.zip
when the tablet boots just like it looks for flashing_boot.img it also looks for the acclaim_update.zip if it is present and the MLO u-boot boot and recovery are OK it will completely reflash the OS to stock - However to retain serial number and B&N website access preserve the rombackup.zip from the factory partition
Did your thread get cut off?
Well, obviously I don't know how to set this up properly. I assume that it had actually booted off the internal system and not the SD I *thought* I set up. Is there a tutorial on building a SD properly for this or should I just go ahead and go with AdamOutler's Ubuntu card? Do I need to take a special precautions in either case to preserve the serial number?
Thanks for all the help!
Actually I had the exact same experience as you, so when the partition table was fixed I did not bother to create the contents of the 2nd ext3 partition, Instead I just copied the necessary files in adb and used dd to install MLO, u-boot, boot & recovery format all the Fat32 & ext4 partitions and copied factory.zip rombackup.zip to the factory partition and allowed the factory reset to happen.
from a quick look at the script the 2nd ext3 partition should atleast have these files
Code:
mkdir /images_to_flash
mount /dev/mmcblk1p2 /images_to_flash
if [ -f /images_to_flash/preflash.img ]; then
test -r /images_to_flash/noshutdown && cp /images_to_flash/noshutdown /
test -r /images_to_flash/version.ppm.gz && fbsplash -s /images_to_flash/version.ppm.gz
dd if=/images_to_flash/preflash.img of=/dev/mmcblk0 bs=4M conv=notrunc,fsync
simg2img /images_to_flash/factory.img /dev/mmcblk0p7
umount /images_to_flash
elif [ ! -f /images_to_flash/factory.img ]; then
if [ -f /images_to_flash/bootcnt ]; then
dd if=/images_to_flash/MLO of=/dev/mmcblk0p1
dd if=/images_to_flash/u-boot.bin of=/dev/mmcblk0p2
dd if=/images_to_flash/recovery.img of=/dev/mmcblk0p3
test -r /images_to_flash/boot.img && dd if=/images_to_flash/boot.img of=/dev/mmcblk0p4
if [ -f /images_to_flash/factory.zip ]; then
cp /images_to_flash/factory.zip /mnt/factory/factory.zip
dd if=/images_to_flash/MLO of=/dev/mmcblk0p1 bs=4096 conv=notrunc,fsync
dd if=/images_to_flash/u-boot.bin of=/dev/mmcblk0p2 bs=4096 conv=notrunc,fsync
dd if=/images_to_flash/recovery.img of=/dev/mmcblk0p3 bs=4096 conv=notrunc,fsync
dd if=/images_to_flash/boot.img of=/dev/mmcblk0p4 bs=4096 conv=notrunc,fsync
test -r /images_to_flash/factory.img && simg2img /images_to_flash/factory.img /dev/mmcblk0p7
if [ ! -f /images_to_flash/factory.img ]; then
test -r /images_to_flash/system.img && simg2img /images_to_flash/system.img /dev/mmcblk0p8
if [ -f "/images_to_flash/factory.img" ]; then
if [ -f /images_to_flash/factory.zip ]; then
cp /images_to_flash/factory.zip /mnt/factory/factory.zip
if [ -f "/images_to_flash/factory.img" ]; then
umount /images_to_flash
I guess these could be made by
1. preflash.img - ignore we dont want a factory install
2. bootcnt - dd if=/dev/zero of=bootcnt bs=4 count=1
3. MLO - unzip from factory.zip and rename
4. u-boot.bin - unzip from factory.zip
5. boot.img - unzip from factory.zip
6. recovery.img - unzip from factory.zip
7. factory.zip - rename the acclaim_update.zip for 1.4.0 or rename one of the b&n updates for 1.4.1 or 1.4.2
8. factory.img - this i think is a blank ext4 fs on a sparse disk, however if it does not exist the script will format the partition
9. system.img - not required
Why dont you go ahead and create a 2nd ext3 partition on the sdcard and create these files I am sure you will be able to unbrick and retain the rombackup and all the serials etc
just FYI I am attaching the shell script inside the flashing_boot.img that is doing all the work

[Q] Unable to change permissions or delete a specific file WITH root

Hello Gentlemen. Sorry to disturb you with a noob question but I cannot solve it for the life of me and I have tried everything I could find on the forums. I have an Aluratek Cinepad AT107F. I have successfully rooted it. I have full super user permissions and I have no problems deleting any files or folders EXCEPT one directory. Let me explain the situation.
I recently did a firmware update and it included brand new APKs for Youtube, also added Google Play Support, and added Angry Birds.
I am unable to update Youtube to the latest version. It gives a "Package file was not signed correctly. Uninstall the previous copy of the app and try again.".
So I attempted to do just what it had asked. I rooted just to do this. I tried removing it with Titanium Backup, I tried Root Uninstaller, I tried Root Explorer, I tried deleting using the "adb shell rm" command. I still get a "Read-only file system".
Even though I have root and granted root access to Root Explorer, I am unable to change the permissions for this /oem/apps/ directory. It's on the top level of the internal memory. I have no external SD card.
I've spent 10+ hours trying to figure this out and I'm sure someone knows something that I don't and can fix this super easy. I'm asking for your help, you're my only hope!
Your issue is that the update gave you modded files that the OEM doesn't want deleted. Most likely do to them not have permission from Google to do so. You will be hard pressed to find help here as we mainly deal with official releases and apks.
Wayne Tech S-III
zelendel said:
Your issue is that the update gave you modded files that the OEM doesn't want deleted. Most likely do to them not have permission from Google to do so. You will be hard pressed to find help here as we mainly deal with official releases and apks.
Wayne Tech S-III
Click to expand...
Click to collapse
Am I in the wrong sub forum? Is there another forum at XDA-Developers that could help?
Vindicoth said:
Am I in the wrong sub forum? Is there another forum at XDA-Developers that could help?
Click to expand...
Click to collapse
No nowhere on the site really deals with unofficial android versions and knock of devices. Your best bet will be the OEM
Read the error message again. The file is on a read-only filesystem. That is why you cannot delete it. In other words, you lack permission to write to the partition.
System partitions get mounted readonly to prevent modification. To remount /system as read-write,
Adb shell mount -o remount,rw /system
If you get "not permitted" error, your ROM's ro.secure means you cannot execute mount operations passed with adb command. So instead you must first open the shell,
> AdB shell
# mount -o remount,rw /system
Now you can delete:
Adb shell rm /system/file
If it is a directory
Adb shell rm -rf /system/dir
If you accidentally mistype that last command with a space beyween that first forward-slash and "s" you will have a very unworkable device....and that's why it is mounted read-only.
If the file is on a different read only filesystem, identify the partition the file is on and
Adb shell mount -o remount,rw /dev/block/id /LocToMountTo
You may have to specify the type
-t fstype
Adb shell mount
will tell you this
Don't forget to remount it as read-only (ro) when you are done
anotherguy19 said:
Read the error message again. The file is on a read-only filesystem. That is why you cannot delete it. In other words, you lack permission to write to the partition.
System partitions get mounted readonly to prevent modification. To remount /system as read-write,
Adb shell mount -o remount,rw /system
Now you can delete:
Adb shell rm /system/file
If it is a dir
Adb shell rm -rf /system/file
If you accidentally mistype that last command with a space beyween that first forward-slash and "s" you will have a very unworkable device....and that's why it is mounted read-only.
If the file is on a different read only filesystem, identify the partition the file is on and
Adb shell mount -o remount,rw /partition/id /folder
You may have to specify the type
-t fstype
Adb shell mount
will tell you this
Don't forget to remount it as read-only (ro) when you are done
Click to expand...
Click to collapse
Well I can access /system just fine. The problem is the /oem/apps folder is not in the /system folder. It's in the top level folder.
/system and /oem/apps are in the root directory. I can change the permissions on /system just fine using Root Explorer, but when trying to change the permissions using any method possible, /oem wont change.
This happens alot on Devices out of China and other places that sell knock offs. They make it so you cant delete their apps and if you do then it bootloops which only a reflash will fix.
Vindicoth said:
Well I can access /system just fine. The problem is the /oem/apps folder is not in the /system folder. It's in the top level folder.
/system and /oem/apps are in the root directory. I can change the permissions on /system just fine using Root Explorer, but when trying to change the permissions using any method possible, /oem wont change.
Click to expand...
Click to collapse
/system and /oem are different partitions then
mount | grep oem
or
adb shell mount | grep oem
Will tell you what /dev/block/xxxx the /oem is on and if it is mounted as read-only (ro)
> adb shell
# mount -o rw,remount /oem
zelendel said:
This happens alot on Devices out of China and other places that sell knock offs. They make it so you cant delete their apps and if you do then it bootloops which only a reflash will fix.
Click to expand...
Click to collapse
Ever get the feeling that you're writing in invisible ink lol?.. Eventually he will listen! You have great patience!
zelendel said:
This happens alot on Devices out of China and other places that sell knock offs. They make it so you cant delete their apps and if you do then it bootloops which only a reflash will fix.
Click to expand...
Click to collapse
Referencing zelendel's post, the device could fail to boot because it is looking for the removed app in /oem
So you could try to remove it from being referenced by the startup scripts.
Try doing a search for files that could be referencing the apk you want to remove.
> adb shell
# grep -r AppName.apk /system/etc
CtrlAltDelIrl said:
Ever get the feeling that you're writing in invisible ink lol?.. Eventually he will listen! You have great patience!
Click to expand...
Click to collapse
If it bootloops then I'll just flash it again, but its worth a try isn't it? Thanks anyways.
anotherguy19 said:
Referencing zelendel's post, the device could fail to boot because it is looking for the removed app in /oem
So you could try to remove it from being referenced by the startup scripts.
Try doing a search for files that could be referencing the apk you want to remove.
> adb shell
# grep -r AppName.apk /system/etc
Click to expand...
Click to collapse
Thank you for your very helpful posts and willingness to help me possibly bootloop my device
when I type the grep command it says it is not found, so I will download busybox onto my tablet and try those commands.
Vindicoth said:
Thank you for your very helpful posts and willingness to help me possibly bootloop my device
when I type the grep command it says it is not found, so I will download busybox onto my tablet and try those commands.
Click to expand...
Click to collapse
So after running mount | grep oem it shows this
[email protected]:/ # mount | grep oem
/dev/block/nandi /oem cramfs ro,relatime 0 0
So is it possible to change this directory to rw? I tried the mount -o rw,remount oem but it doesnt show anything after i input the command
[EDIT]
So it seems that the cramfs file system is read-only.
Vindicoth said:
Thank you for your very helpful posts and willingness to help me possibly bootloop my device
when I type the grep command it says it is not found, so I will download busybox onto my tablet and try those commands.
Click to expand...
Click to collapse
I love breaking things. It's only then we can figure out how it works.
Busybox is exactly what you need.
grep will search for strings within all files and subdirs of /system/etc; matching whatever you type for "AppName.apk"
It is a case-sensitive search unless you add
-i
So
grep -ri ....
or
grep -r -i....
Both would work.
But you don't even know if you need to be searching for a file to modify.
You may want to go ahead and delete the file and reboot.
If it fails, note the file(s) you deleted and know the system is looking for them and then proceed with seeing if you can identify a file in /system/etc that is looking for it's presence.
---------- Post added at 11:59 PM ---------- Previous post was at 11:53 PM ----------
Vindicoth said:
So after running mount | grep oem it shows this
[email protected]:/ # mount | grep oem
/dev/block/nandi /oem cramfs ro,relatime 0 0
So is it possible to change this directory to rw? I tried the mount -o rw,remount oem but it doesnt show anything after i input the command
[EDIT]
So it seems that the cramfs file system is read-only.
Click to expand...
Click to collapse
Commands that complete "quietly" mean they were successful.
If you type
# mount | grep oem
After
# mount -o rw,remount /oem
/dev/block/nandi /oem cramfs ro,relatime 0 0
Should have changed to
/dev/block/nandi /oem cramfs rw,relatime 0 0
anotherguy19 said:
I love breaking things. It's only then we can figure out how it works.
Busybox is exactly what you need.
grep will search for strings within all files and subdirs of /system/etc; matching whatever you type for "AppName.apk"
It is a case-sensitive search unless you add
-i
So
grep -ri ....
or
grep -r -i....
Both would work.
But you don't even know if you need to be searching for a file to modify.
You may want to go ahead and delete the file and reboot.
If it fails, note the file(s) you deleted and know the system is looking for them and then proceed with seeing if you can identify a file in /system/etc that is looking for it's presence.
---------- Post added at 11:59 PM ---------- Previous post was at 11:53 PM ----------
Commands that complete "quietly" mean they were successful.
If you type
# mount | grep oem
After
# mount -o rw,remount /oem
/dev/block/nandi /oem cramfs ro,relatime 0 0
Should have changed to
/dev/block/nandi /oem cramfs rw,relatime 0 0
Click to expand...
Click to collapse
Followed those steps and its still
/dev/block/nandi /oem cramfs ro,relatime 0 0
Apparently the cramfs is a read only filesystem by design.
Vindicoth said:
Followed those steps and its still
/dev/block/nandi /oem cramfs ro,relatime 0 0
Apparently the cramfs is a read only filesystem by design.
Click to expand...
Click to collapse
You need to create an image of the partition, mount the partition on a system with tools to edit it, extract the contents, and re-create the cramfs.
You would need a linux box or linux virtual machine like Virtualbox, or maybe cygwin has the tools. I would just download and burn a Linux LiveISO and run it from VirtualBox, creating a shared folder to get access to the image file (oem partition).
With debian system, you would do
# apt-get install cramfsprogs fusecram
fusecram allow you to mount the cramfs partition on Linux PC via
# mount -t loop cramfsOEM.partition /mnt/workingdir
However since we cannot simply mount the filesystem on the device by plugging into the usb port of the linux machine and mounting from there, we must first create an image (file) of /dev/block/nandi.
> adb shell
# dd if=/dev/block/nandi of=/nandi.img bs=4k
And then copy it to our pc so we can work with the file.
# exit
> adb pull /nandi.orig.img .
Now we can transfer this file to a machine with the requisite cramfs tools to modify the file.
If you look back, I wrote
# mount -t loop cramfsOEM.partition /mnt/workingdir
replace cramfsOEM.partition for nandi.orig.img, or whatever you named it.
Workingdir needs to exist, so
# mkdir /mnt/workingdir
Now you will have to look up cramfsprogs which will allow you to extract the contents to modify. On the Debian or Ubuntu linux machine "/mnt/workingdir" would be the equivalent of "/oem" on your Android device.
However, all this is could very well be for naught, as it is likely the firmware has marked this partition as "signed" so if we try to write back our modified image, the system will fail to boot since the size will be different. On the other hand, the firmware may very well just check to see the partition size is correct. And since you are decreasing the size, the new cramfs image created with a linux box will (should) fit in the old partition.
Fyi, an image file is like a zip file without the compression.
After you modify the cramfs, you can write it back with something like
> adb push cramfs.mod.img /
> adb shell
Then write over the old partition. However, you shouldn't write over a mounted file system so
# umount /dev/block/nandi
Then write over it.
# dd if=/cramfs.mod.img of=/dev/block/nandi bs=4k
Then reboot
# shutdown -r now
And see what happens.
anotherguy19 said:
You need to create an image of the partition, mount the partition on a system with tools to edit it, extract the contents, and re-create the cramfs.
You would need a linux box or linux virtual machine like Virtualbox, or maybe cygwin has the tools. I would just download and burn a Linux LiveISO and run it from VirtualBox, creating a shared folder to get access to the image file (oem partition).
With debian system, you would do
# apt-get install cramfsprogs fusecram
fusecram allow you to mount the cramfs partition on Linux PC via
# mount -t loop cramfsOEM.partition /mnt/workingdir
However since we cannot simply mount the filesystem on the device by plugging into the usb port of the linux machine and mounting from there, we must first create an image (file) of /dev/block/nandi.
> adb shell
# dd if=/dev/block/nandi of=/nandi.img bs=4k
And then copy it to our pc so we can work with the file.
# exit
> adb pull /nandi.orig.img .
Now we can transfer this file to a machine with the requisite cramfs tools to modify the file.
If you look back, I wrote
# mount -t loop cramfsOEM.partition /mnt/workingdir
replace cramfsOEM.partition for nandi.orig.img, or whatever you named it.
Workingdir needs to exist, so
# mkdir /mnt/workingdir
Now you will have to look up cramfsprogs which will allow you to extract the contents to modify. On the Debian or Ubuntu linux machine "/mnt/workingdir" would be the equivalent of "/oem" on your Android device.
However, all this is could very well be for naught, as it is likely the firmware has marked this partition as "signed" so if we try to write back our modified image, the system will fail to boot since the size will be different. On the other hand, the firmware may very well just check to see the partition size is correct. And since you are decreasing the size, the new cramfs image created with a linux box will (should) fit in the old partition.
Fyi, an image file is like a zip file without the compression.
After you modify the cramfs, you can write it back with something like
> adb push cramfs.mod.img /
> adb shell
Then write over the old partition. However, you shouldn't write over a mounted file system so
# umount /dev/block/nandi
Then write over it.
# dd if=/cramfs.mod.img of=/dev/block/nandi bs=4k
Then reboot
# shutdown -r now
And see what happens.
Click to expand...
Click to collapse
Wow that was very detailed. I thought I might have to do something like that. Thanks so much again. I'll try this in the morning since it's getting very late here. I'll go ahead and download a linux livecd tonight.

How to auto mount cleanly a partiton on boot

I have a second partition on my SDCARD at /dev/block/mmcblk1p2, all I want to do is ensure that it is always mounted as /storage/sdcard0/mount seems simple I can do it in 5 second on Linux, on Android, it seems impossible I can try to add a hack, but that is lost every-time I update the ROM. There has to be some simple way to do it, that I'm missing. The best I have is to load up a terminal emulated su to root and run: mount -t ext4 /dev/block/mmcblk1p2 /storage/sdcard0/mount
Now in theory, the following would work but for 2 things:
mkdir /storage/sdcard0/mount
su - root -c 'mount -t ext4 /dev/block/mmcblk1p2 /storage/sdcard0/mount'
But for the fact the Android's su does not understand -c so that is out. as well as the fact that non-root users (u0_a216 in my case) can not access /storage/sdcard0.
All I want is a simple way to ensure that this is always mounted where I want it when I need it, yet this simple task is nearly impossible it appears on Android, so why is that?
The issue here is that the fat32 partition does not support large files so I need a separate partition that does such as ext4, in reality if the external sdcard could just be ext4 there would be no issues, and it would be faster, but that is Android for you.
Any suggestions?
Thanks,
ERIC
Insert mount script to init.d folder...
via XDA Premium
Ok, I have this mostly working with juicessh and tasker now for now
I have 2 shell scripts:
mountDev.sh:
Code:
mkdir /storage/sdcard2
chmod 777 /storage/sdcard2
mount -t ext4 /dev/block/mmcblk1p2 /storage/sdcard2
umountDev.sh
Code:
umount /storage/sdcard2
rmdir /storage/sdcard2
In Tasker I have 2 tasks defined:
I'm using the JuiceSSH plugin to open a terminal to localhost I then execute:
To Mount:
Code:
su -l --shell=/system/bin/sh --command='cd /storage/sdcard0 ; sh ./mountDSev.sh ; exit' ; exit
To umount:
Code:
su -l --shell=/system/bin/sh --command='cd /storage/sdcard0 ; sh ./mountDSev.sh ; exit' ; exit
I then created 2 icons, 1 for each operation on the home screen. I also created a Device Boot event to automatically execute and mount the task.
This works, mostly, however even though it is root, sometimes I get errors such as /storage/ is readonly, which makes no sense since it could create the directory at boot, but can not remove the directory later on, since it is readonly. Its a minor thing currently, but annoying.
The benefit of this is it is easy to transfer between ROM images and devices without worrying about it being wiped out every-time I update. In theory it also works without init.d support being enabled. Down side is it you need Tasker and the JuiceSSH plug-in so it costs money.
Hope this helps others.
ERIC

Categories

Resources