mmcblk1p1 access from initrd - Galaxy S III Q&A, Help & Troubleshooting

Hi,
I wish to perform a read/write to /dev/block/mmcblk1p1 from the initrd stage of the booting sequence on my SGS III.
I've managed to unpack the boot.img, add some shell code to /sbin/init and re-pack the image and flash it to my device.
but when i try to access the mmcblk1p1 (the external sd, which is of course present) it seems that the write fails. i tried the most simple procedure:
Code:
echo "hello world" > /dev/block/mmcblk1p1 # shuld write to the first sector.
or
Code:
mkdir /mysd
mount -t vfat /dev/block/mmcblk1p1 /mysd
echo "hello world" > /mysd/test.txt # should create a file on the sd card.
umount /mysd
but non seems to work.
with the second code i actually managed to create a test.txt with with "hello world" into the internal sd "/" partition.
as well I've added mknod and created the mmcblk1p1 file descriptor. i think I've might need to add something to the fstab file.
many thanks.

Another try :angel:

Related

[Q] MKFS.EXT4 Compiled for Android

I'm trying to make an auto install script within the initramfs. I've got everything working, including automatic fdisk, but I cannot get mkfs.ext4 to work on the Android kernel, and there is no version of Busybox with the ext4 applet. Does anyone have a mkfs.ext4 that runs successfully on Android? When I run it from a terminal the output is
Code:
mkfs.ext4: 1: Syntax error: word unexpected (expecting ")")
Here's my code if you want to see what I'm doing.
Code:
mount /dev/mmcblk1p1 /tmp/mnt
if [ -f /tmp/mnt/mysticfw.tar.gz ]; then
$FDISK /dev/mmcblk0 < /home/fdisk.input
$MKFS_EXT4 -O ^huge_file /dev/mmcblk0p2
mount /dev/mmcblk1p2 /tmp/tmproot
mkdir /tmp/tmproot/itworks
tar -xzvf /tmp/mnt/mysticfw.tar.gz -C /tmp/tmproot/
sync
#rm /tmp/mnt/mysticfw.tar.gz
umount /tmp/tmproot
fi
sync
umount /tmp/mnt
It automatically partitions the stock Android block and installs a tar.gz from the internal storage to simplify my unsquashed 2.1.4 filesystem install, and the only part I can't get working is mkfs.ext4.
Found one! It's 3 MBs though, so if anyone has a smaller one, it would be very nice.
msticninja said:
I'm trying to make an auto install script within the initramfs. I've got everything working, including automatic fdisk, but I cannot get mkfs.ext4 to work on the Android kernel, and there is no version of Busybox with the ext4 applet. Does anyone have a mkfs.ext4 that runs successfully on Android? When I run it from a terminal the output is
Code:
mkfs.ext4: 1: Syntax error: word unexpected (expecting ")")
Click to expand...
Click to collapse
Why do you don't use the mke2fs from Uruk for example (the easiest way) asking $auron if it's ok for him. His size is only 49KB.
Find it like the following on Uruk installation:
Code:
[COLOR="DarkRed"]
# mkfs.ext4 -V
mke2fs 1.41.3 (12-Oct-2008)
Using EXT2FS Library version 1.41.3
# find / -name mke2fs | xargs ls -l
-rwxr-xr-x 1 root root 30584 Dec 15 03:46 /system/bin/mke2fs
[B]-rwxr-xr-x 5 root root 49248 4 Jan 15 13:14 /usr/local/sbin/mke2fs[/B]
#/usr/local/sbin/mke2fs -V
mke2fs 1.41.3 (12-Oct-2008)
Using EXT2FS Library version 1.41.3
[/COLOR]
Here's my code if you want to see what I'm doing.
Code:
mount /dev/mmcblk1p1 /tmp/mnt
if [ -f /tmp/mnt/mysticfw.tar.gz ]; then
$FDISK /dev/mmcblk0 < /home/fdisk.input
$MKFS_EXT4 -O ^huge_file /dev/mmcblk0p2
mount /dev/mmcblk1p2 /tmp/tmproot
mkdir /tmp/tmproot/itworks
tar -xzvf /tmp/mnt/mysticfw.tar.gz -C /tmp/tmproot/
sync
#rm /tmp/mnt/mysticfw.tar.gz
umount /tmp/tmproot
fi
sync
umount /tmp/mnt
It automatically partitions the stock Android block and installs a tar.gz from the internal storage to simplify my unsquashed 2.1.4 filesystem install, and the only part I can't get working is mkfs.ext4.
Click to expand...
Click to collapse
and don't forget to add "-l" on FDISK command and change the device mmcblk0 with mmcblk1 on the lines:
Code:
$FDISK /dev/mmcblk0 < /home/fdisk.input
$MKFS_EXT4 -O ^huge_file /dev/mmcblk0p2
Cheers,
shklifo said:
Why do you don't use the mke2fs from Uruk for example (the easiest way) asking $auron if it's ok for him. His size is only 49KB.
Find it like the following on Uruk installation:
Code:
[COLOR="DarkRed"]
# mkfs.ext4 -V
mke2fs 1.41.3 (12-Oct-2008)
Using EXT2FS Library version 1.41.3
# find / -name mke2fs | xargs ls -l
-rwxr-xr-x 1 root root 30584 Dec 15 03:46 /system/bin/mke2fs
[B]-rwxr-xr-x 5 root root 49248 4 Jan 15 13:14 /usr/local/sbin/mke2fs[/B]
#/usr/local/sbin/mke2fs -V
mke2fs 1.41.3 (12-Oct-2008)
Using EXT2FS Library version 1.41.3
[/COLOR]
and don't forget to add "-l" on FDISK command and change the device mmcblk0 with mmcblk1 on the lines:
Code:
$FDISK /dev/mmcblk0 < /home/fdisk.input
$MKFS_EXT4 -O ^huge_file /dev/mmcblk0p2
Cheers,
Click to expand...
Click to collapse
Why didn't I think of that? Thanks.
But regarding mmcblk0/1, I'm replacing the stock Android, so the fdisk.input file contains the commands to delete mmcblk0p2 and p3, and make a new partition in the unused space. I hate using space on my Internal Storage, so I'm using Archos' space.
msticninja said:
Why didn't I think of that? Thanks.
But regarding mmcblk0/1, I'm replacing the stock Android, so the fdisk.input file contains the commands to delete mmcblk0p2 and p3, and make a new partition in the unused space. I hate using space on my Internal Storage, so I'm using Archos' space.
Click to expand...
Click to collapse
If you are using the mmcblk0p2 as rootfs as you say (and you are expanded tar archive on mmcblk1p2), than you have to change the line:
mount /dev/mmcblk1p2 /tmp/tmproot
Click to expand...
Click to collapse
with
mount /dev/mmcblk0p2 /tmp/tmproot
Click to expand...
Click to collapse
shklifo said:
If you are using the mmcblk0p2 as rootfs as you say (and you are expanded tar archive on mmcblk1p2), than you have to change the line:
with
Click to expand...
Click to collapse
I know, that's my current data partition, I'll change it once I'm done testing. The tar file just has a test file in it, so when I boot back into block1, I can see if the IF statement was executed by seeing if it was extracted to block1. I'll also have to change etc/mountpoints once testing is actually finished.
One more question since you're so quick. I think I have everything working, except it needs a reboot in between the fdisk and mke2fs commands to reload the partition table. I'm trying to use partprobe instead of rebooting, but it hasn't been cross compiled to work on Android, AFAIK. Have you seen a way to reload the MBR without rebooting?
msticninja said:
I know, that's my current data partition, I'll change it once I'm done testing. The tar file just has a test file in it, so when I boot back into block1, I can see if the IF statement was executed by seeing if it was extracted to block1. I'll also have to change etc/mountpoints once testing is actually finished.
One more question since you're so quick. I think I have everything working, except it needs a reboot in between the fdisk and mke2fs commands to reload the partition table. I'm trying to use partprobe instead of rebooting, but it hasn't been cross compiled to work on Android, AFAIK. Have you seen a way to reload the MBR without rebooting?
Click to expand...
Click to collapse
I'v been looking at the recovery_lib.sh in the recovery boot image and can't find anything special to re-read the partition table. And yes they also use fdisk to repartition. So I suspect the driver for the block device does not cache the MBR and you can just mke2fs after the partition table is created.
I can't remember from what firmware that recovery boot image was but I think it's from the 2.1.04 and they do some repartitioning there for the swap space.
I'll check it again and get back to you.
wdl1908 said:
I'v been looking at the recovery_lib.sh in the recovery boot image and can't find anything special to re-read the partition table. And yes they also use fdisk to repartition. So I suspect the driver for the block device does not cache the MBR and you can just mke2fs after the partition table is created.
I can't remember from what firmware that recovery boot image was but I think it's from the 2.1.04 and they do some repartitioning there for the swap space.
I'll check it again and get back to you.
Click to expand...
Click to collapse
I just checked the recovery image from 2.1.04 and after the fdisk commands there is nothing to re-read the MBR the next commands executed are mount commands to check if the fs is present I suggest you look at the /etc/scripts/recovery_lib.sh yourself it could give some clues on how to do things.
wdl1908 said:
I just checked the recovery image from 2.1.04 and after the fdisk commands there is nothing to re-read the MBR the next commands executed are mount commands to check if the fs is present I suggest you look at the /etc/scripts/recovery_lib.sh yourself it could give some clues on how to do things.
Click to expand...
Click to collapse
For me too, it have nothing to do with a reboot to load partitions table and access partition to format them with the choised filesystem.
You can delete any partition on linux (except rootfs one ), recreate them and directly format them as you like, reboot isn't necesary.
Thanks for all the replies, very helpful, but I'm stuck. Fdisk seems to use ioctl to reload the partition table, so you don't need a reboot if everything on the device is unmounted before writing the partition table, but I'm having very strange issues with mke2fs now. I've had the whole thing work twice now, but when I flash back to stock, then retry the script, it usually does everything except the formatting. Here's the code:
Code:
mount /dev/mmcblk1p1 /tmp/mnt
if [ -f /tmp/mnt/mysticfw.tar.gz ]; then
umount /dev/mmcblk0p1
umount /dev/mmcblk0p2
umount /dev/mmcblk0p3
umount /dev/mmcblk0p4
fdisk /dev/mmcblk0 < /home/fdisk.input
mv /tmp/mnt/mysticfw.tar.gz /tmp/mnt/mysticf.tar.gz
sync
umount /tmp/mnt
log_and_reboot
fi
if [ -f /tmp/mnt/mysticf.tar.gz ]; then
rm /etc/mtab
touch /etc/mtab
mke2fs -T ext4 -O ^huge_file /dev/mmcblk0p2
mount /dev/mmcblk0p2 /tmp/tmproot
tar -xzf /tmp/mnt/mysticf.tar.gz -C /tmp/tmproot/
sync
mv /tmp/mnt/mysticf.tar.gz /tmp/mnt/mysticdone.tar.gz
umount /tmp/tmproot
rm /etc/mtab
ln -s /proc/mounts /etc/mtab
fi
sync
umount /tmp/mnt
I have it reboot after the fdisk just in case, and the fdisk works perfectly, so the second IF/THEN is the issue. I had to retouch the mtab just to make sure it's empty, as mke2fs fails if mtab doesn't exist(at least in terminal), then I relink it to /proc/mounts as they do in the stock firmware. Here's my mke2fs.conf:
Code:
[defaults]
base_features = sparse_super,filetype,resize_inode,dir_index,ext_attr
blocksize = 4096
inode_size = 256
inode_ratio = 16384
[fs_types]
ext3 = {
features = has_journal
}
ext4 = {
features = has_journal,extent,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize
inode_size = 256
}
ext4dev = {
features = has_journal,extent,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize
inode_size = 256
options = test_fs=1
}
small = {
blocksize = 1024
inode_size = 128
inode_ratio = 4096
}
floppy = {
blocksize = 1024
inode_size = 128
inode_ratio = 8192
}
news = {
inode_ratio = 4096
}
largefile = {
inode_ratio = 1048576
blocksize = -1
}
largefile4 = {
inode_ratio = 4194304
blocksize = -1
}
hurd = {
blocksize = 4096
inode_size = 128
}
Is there a way to echo the output from my script to a file like dontpanic so I can see what the error is?
msticninja said:
Is there a way to echo the output from my script to a file like dontpanic so I can see what the error is?
Click to expand...
Click to collapse
Simple append (">>") and "echo" doesn't work to a redirected logfile?
I've only learned what I've needed to learn over the years, usually with endless google searches and reading through man pages, so I've never tried to log outputs, because I could always see the output in a terminal or onscreen during boot. Android is the first time I haven't been able to actually see the boot process.
Once again, thanks for your help. I probably could've googled this, but I kind of asked as an afterthought. I didn't even think about redirecting. So if the mke2fs line is the one I want to log, I just add "2&>> /tmp/mnt/logfile" to the end of it, right?
Also, thanks for your original thread about booting from Internal Storage, I never got around to developing on Android until you posted that, and I realized just how similar Android is to L/unix(e.g. exactly the same).
msticninja said:
I didn't even think about redirecting. So if the mke2fs line is the one I want to log, I just add "2&>> /tmp/mnt/logfile" to the end of it, right?
Click to expand...
Click to collapse
ehm, no.
In your case must be like the following:
Code:
"your command" >> /tmp/mnt/logfile 2>&1
That means redirect all messages from STDERR (2 - standard error) to STDOUT (1 - standard output) and all messaged collected on STDOUT to the redirected log file /tmp/mnt/logfile, or more comprensible redirect all mesage including error ones to the log file.
I'm working in Unix environments and use them often
And a good practice in developing is to use "echo" to the same log file, so you know the exact place the script is running, like:
Code:
echo "I'm just before the formatting step of the ..." >> /tmp/mnt/logfile
shklifo said:
ehm, no.
In your case must be like the following:
Code:
"your command" >> /tmp/mnt/logfile 2>&1
That means redirect all messages from STDERR (2 - standard error) to STDOUT (1 - standard output) and all messaged collected on STDOUT to the redirected log file /tmp/mnt/logfile, or more comprensible redirect all mesage including error ones to the log file.
I'm working in Unix environments and use them often
And a good practice in developing is to use "echo" to the same log file, so you know the exact place the script is running, like:
Code:
echo "I'm just before the formatting step of the ..." >> /tmp/mnt/logfile
Click to expand...
Click to collapse
Strange. The google searching lead me to believe the "2>&1" was before the location, and replaced ">>". Once again, thanks for the help.
any chance of you getting this uploaded? iterested in this since I'm not that good with linux
TjaXanK said:
any chance of you getting this uploaded? iterested in this since I'm not that good with linux
Click to expand...
Click to collapse
I could probably finish it, but I'm waiting for a new version of Uruk first, as his install script already gets rid of the linux steps, it just doesn't give you the choice to install to the internal memory yet. Once he does that, I'll add my changes to make it install to the Archos partition. The latest Uruk is also a bit too big for the archos partition. I had to cut my data partition down to ~150 megs.
msticninja said:
I could probably finish it, but I'm waiting for a new version of Uruk first, as his install script already gets rid of the linux steps, it just doesn't give you the choice to install to the internal memory yet. Once he does that, I'll add my changes to make it install to the Archos partition. The latest Uruk is also a bit too big for the archos partition. I had to cut my data partition down to ~150 megs.
Click to expand...
Click to collapse
ok, I'm currently running urk with the new install system and it's brillant but it would be perfect if we could run it without cutting down on our storage space

[Q]How to mount directories across SD cards

Okay, this is what I want to do. Under Linux, it would be done via /etc/fstab, but Android has changed some things up.
Certain apps store files and other things on the internal SD card of the RAZR. For example, the Amazon MP3 Cloud player stores all downloaded music files to /sdcard/amazonmp3. There is no way to change this. However, I store all my music on my external SD card. So, what I want to do is create a mount point on the internal sdcard for the /sdcard/amazonmp3 directory that points to a directory on my external sd card (/sdcard-ext/amazonmp3).
That way, when I download music, it will still attempt to save it to /sdcard/amazonmp3 which really is a mount point that points to /sdcard-ext/amazonmp3.
Now, there is an app called FoldersPlug which does this. However, it's not doing it across reboots and it's a little buggy in how it works. I'd rather just fix the /etc/vold.fstab file (if that's possible) to mount my directories for me, but I don't completely understand all the needs to be set up in it.
If I have the following directories set up:
/sdcard/amazonmp3 (this will be empty)
/sdcard-ext/amazonmp3 (this will contain all the files and folder structures that would normally be in /sdcard/amazonmp3)
I want it so that the /sdcard-ext/amazonmp3 directory is mounted to the /sdcard/amazonmp3 directory.
Here is what I see when I run the "mount" command to look at the current mount points that are mounted:
Code:
/dev/block/vold/179:97 /mnt/sdcard/amazonmp3 vfat rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0
/dev/block/vold/179:97 /mnt/sdcard/DCIM vfat rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0
/dev/block/vold/179:97 /mnt/sdcard/Pictures vfat rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0
/dev/block/vold/179:97 /mnt/sdcard/Android/data/com.iconology.comics.app vfat rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0
These are the mount points that FoldersPlug set up and what I want to do instead is define them in the /etc/vold.fstab file but I don't know how they should be entered into the /etc/vold.fstab file.
Any help would be greatly appreciated!
Thanks!
I may be wrong, but I don't believe Android Vold can mount loopback (bind). You'll have to create a partition on the SD card instead, feeding it to Vold. Then try something similar to;
dev_mount /dev/block/mmcblk0p2 /mnt/sdcard/amazonmp3 /devices/platform/msm_sdcc.2/mmc_host/mmc1
Or if you forget about Vold, and use an ordinary mount;
# mount -o bind /sdcard-ext/amazonmp3 /sdcard/amazonmp3
In this case (bind loopback mount), you don't need it to be a partition.
Maybe the easies way is you just forget about the internal sdcard, replacing /mnt/cdcard with The real McCoy instead.
Cool. Thanks for the help. I see that this would have to be done using busybox, which is cool since I have that installed.
I tested what you stated and yup, that mounts them. So, I guess I'll fool around a little more with the scripts in /etc/init.d and see if I can't get it to work. I might have to do a sleep or something in the script to give the system time to mount the sdcards, but hopefully, this will work.
Thanks again for the tip!
UPDATE:
Well, here's my script but it doesn't seem to work. I have it first check to see if the number of lines returned from doing directory listing on the /sdcard and /sdcard-ext directories are 0. If so, it sleeps for 10 seconds and then tries it again, waiting for the sdcards to be mounted.
Once they are mounted, then I go and mount my directories. However, it doesn't seem to work. I have the script in the /etc/init.d directory and the permissions are set for execution (0777) like the other two scripts in there (98tweaks and S99SuperCharger).
If I go and run the script myself, it works and mounts the directories.
Here is the script. Any other ideas?
Code:
#!/system/xbin/sh
# Check if the SDCARDs are mounted yet.
result="`ls /sdcard/ | wc -l`"
while [ "$result" -eq 0 ]
do
sleep 10
result="`ls /sdcard/ | wc -l`"
done
result="`ls /sdcard-ext/ | wc -l`"
while [ "$result" -eq 0 ]
do
sleep 10
result="`ls /sdcard-ext/ | wc -l`"
done
# The cards are mounted. Now mount the directories
busybox mount --bind /sdcard-ext/DCIM /sdcard/DCIM
busybox mount --bind /sdcard-ext/amazonmp3 /sdcard/amazonmp3
busybox mount --bind /sdcard-ext/Pictures /sdcard/Pictures
busybox mount --bind /sdcard-ext/Android/data/com.iconology.comics.app /sdcard/Android/data/com.iconology.comics.app
Okay. Got it to work finally. I just decided to set it up using ScriptManager instead to run on boot.
Not sure why it wasn't working with the init.d process.
you rock!
iBolski said:
Cool. Thanks for the help. I see that this would have to be done using busybox, which is cool since I have that installed.
I tested what you stated and yup, that mounts them. So, I guess I'll fool around a little more with the scripts in /etc/init.d and see if I can't get it to work. I might have to do a sleep or something in the script to give the system time to mount the sdcards, but hopefully, this will work.
Thanks again for the tip!
UPDATE:
Well, here's my script but it doesn't seem to work. I have it first check to see if the number of lines returned from doing directory listing on the /sdcard and /sdcard-ext directories are 0. If so, it sleeps for 10 seconds and then tries it again, waiting for the sdcards to be mounted.
Once they are mounted, then I go and mount my directories. However, it doesn't seem to work. I have the script in the /etc/init.d directory and the permissions are set for execution (0777) like the other two scripts in there (98tweaks and S99SuperCharger).
If I go and run the script myself, it works and mounts the directories.
Here is the script. Any other ideas?
Code:
#!/system/xbin/sh
# Check if the SDCARDs are mounted yet.
result="`ls /sdcard/ | wc -l`"
while [ "$result" -eq 0 ]
do
sleep 10
result="`ls /sdcard/ | wc -l`"
done
result="`ls /sdcard-ext/ | wc -l`"
while [ "$result" -eq 0 ]
do
sleep 10
result="`ls /sdcard-ext/ | wc -l`"
done
# The cards are mounted. Now mount the directories
busybox mount --bind /sdcard-ext/DCIM /sdcard/DCIM
busybox mount --bind /sdcard-ext/amazonmp3 /sdcard/amazonmp3
busybox mount --bind /sdcard-ext/Pictures /sdcard/Pictures
busybox mount --bind /sdcard-ext/Android/data/com.iconology.comics.app /sdcard/Android/data/com.iconology.comics.app
Click to expand...
Click to collapse
Dude...a little renaming of dirs and i was running. thanx:good:
iBolski said:
Okay. Got it to work finally. I just decided to set it up using ScriptManager instead to run on boot.
Not sure why it wasn't working with the init.d process.
Click to expand...
Click to collapse
Works perfectly
Thanks for your work.
I have a question. Is it possible to create a folder in /mnt/sdcard (for example /mnt/sdcard/myfolder) with a script or automaticly after boot?
What i want is to mount the external SD to this folder (/mnt/sdcard/myfolder) but first you have to create the folder "mysdcard".
But i hope it works with a script only like:
Code:
#!/system/xbin/sh
# The cards are mounted. Now mount the directories
mkdir /mysdcard
busybox mount --bind /sdcard-ext /sdcard/mysdcard
sorry for my english
xoxys said:
Thanks for your work.
I have a question. Is it possible to create a folder in /mnt/sdcard (for example /mnt/sdcard/myfolder) with a script or automaticly after boot?
What i want is to mount the external SD to this folder (/mnt/sdcard/myfolder) but first you have to create the folder "mysdcard".
But i hope it works with a script only like:
Code:
#!/system/xbin/sh
# The cards are mounted. Now mount the directories
mkdir /mysdcard
busybox mount --bind /sdcard-ext /sdcard/mysdcard
sorry for my english
Click to expand...
Click to collapse
sorry my english bad...
if i don't have /etc/init.d directory... can i execute this command in another way?
thanks...
nb:
* modified with debuggerd is not work, my jelly-bean not execute debuggerd on boot
* add script install-recovery.sh on /system/etc is not work too....

[GUIDE][U, SOLA, GO, P][ICS/JB][Unlocked BL] Enable Multi Boot Feature

Hello Guys,
This is my first thread in XDA and probably the most important one too. As the title says, I would like to introduce the awesome multiboot capabilities of Xperia U, Sola, Go, P developed by our favourite dev munjeni . Here is the original thread http://forum.xda-developers.com/showthread.php?t=2418241. Go there & give thanks to him for this awesome feature.
UPDATE: September 20, 2013
Made it to the Portal Homepage!!!!
Thanks all for your constant support for updating this thread and thanks to munjeni without whom this feature would've been just a dream
Portal Link: http://www.xda-developers.com/android/enable-multi-boot-on-the-xperia-u-sola-go/​
Click to expand...
Click to collapse
So, What is Multiboot ?
Ever got tired of flashing ROM again & again because of bootloop or to choose a good ROM?? Well news flash, now u don't have to. U can install multiple operating system in your ROM just like you do in your computer. Don't like the new ROM? Just switch your ROM to previous one with just a click. No flashing, wiping needed. The secondary ROM will be loaded from the sdcard partition.​
WARNING: Your warranty is already void. You will do this at your own risk. Me or XDA will take no responsibility if you brick your device while attempting to do these.
Requirements
ADB connection. Please check if you can connect adb in normal mode, recovery mode, fastboot mode. It's mandatory.
Rooted phone with unlocked bootloader
Any text editor except notepad, microsoft word or wordpad.
It is recommended to edit all files in PC with text editors and with unix/utf-8 format.
Brain & Brave heart
This is a step by step guide to enable multiboot intended for all users including noobs like me . The whole process is divided into several parts. First I'll guide you to boot your current rom (primary rom) through boot menu. Then I'll cover how to boot the second rom.
So, Let's Get Started !!!!
Booting Into Primary/Current ROM​
Part 1: Configure BootMenu Settings
So, the basic is this: when you power on your device, a menu will appear containing the list of ROMs' you have installed in your device. You browse it and select which ROM you want to boot. Then it'll be loaded. Pretty simple, eh ? But how will this menu figure out which ROM you have in your device? That's right, we have to define them.
Create a folder named "bootmenu" in your sdcard
Inside the folder, create a file named "settings.ini"
Now say you have stock JB 4.1.2 installed. So create a folder inside "bootmenu" named "StockJB". Also we have to create another folder "recovery" so that we have cwm recovery in Boot.
Don't use space while naming the folder. Otherwise bootmenu will show error at startup.
Now we have to edit the settings.ini file. Copy it to desktop and open it with text editor. Write these code....
Code:
[rom-1]
menutitle=Stock JB
kernel=/sdcard/bootmenu/StockJB/zImage
ramdisk=/sdcard/bootmenu/StockJB/initrd.gz
cmdline=[COLOR="Red"]your_cmdline[/COLOR]
[rom-2]
menutitle=CWM Touch Recovery
kernel=/sdcard/bootmenu/recovery/zImage
ramdisk=/sdcard/bootmenu/recovery/initrd.gz
cmdline=[COLOR="Red"]your_cmdline[/COLOR]
Let's explain these. "menutitle" is the name that'll appear in the menu when you power on the device. kernel, ramdisk, cmdline will be extracted from the boot.img that is provided with the ROM. More info about extracting them will be discussed later. You can see that in the kernel,ramdisk we have to set the path to the StockJB and recovery folder we created earlier. There are 2 rom settings for stock jb & recovery. If you want to have more ROM, you have to add another rom settings here. "cmdline" is kernel command line. You can find it when you extract boot.img or kernel.elf (see part 2). Open it with editor and copy-paste the whole text in your_cmdline. Now, ROM1 here will be the default rom i.e if you don't select any rom to load in 10 seconds, bootmenu will automatically load the ROM1 defined here :good:. After you're done editing simply overwrite the settings.ini with your new settings.ini in bootmenu folder. That's the end of first part. We'll come back to these folder again later.
Part 2: Extracting boot.img
Now we'll dive into more complex steps. We'll extract the kernel(zImage) and ramdisk(initrd.gz) from the boot.img that is provided with the rom.zip package. We'll need some tools to do that. Download the image_tools.rar from download section. Extract the files and copy them to your /system/bin folder. Make sure to give them permission 755 or rwx r-x r-x. Reboot your phone to apply the changes.
Now extract your current ROMs' boot.img and copy it to /data/local/tmp folder. Now connect your phone with pc, establish adb connection and follow the given code:
Code:
adb shell
su
cd /data/local/tmp
mkdir boot
kernel_dump ./boot boot.img
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
this will dump kernel(zImage), ramdisk(initrd.gz) and cmdline to your /data/local/tmp/boot folder. For elf based kernel, just change the boot.img with kernel.elf.
Part 3: Ready the ROM For Booting
We will be using ramdisk(initrd.gz) only from the dumped folder since the kernel(zImage) inside it is not kexec patched!!! (If zImage is kexec patched, then use that one rather than from download section). Download the zImage, bootmenu, recovery ramdisk from download section. Extract it, you will find zImage inside it along with another initrd.gz and a modules folder. Copy both zImage & initrd.gz from the downloaded folder and paste it in /sdcard/bootmenu/recovery folder that you created earlier. Now copy the recently dumped initrd.gz from /data/local/tmp/boot to /sdcard/bootmenu/StockJB that you created. For zImage copy the appropriate one for ICS/JB from downloads and paste in here. The folder structure will look like these:
/sdcard/bootmenu
Stock_JB
initrd.gz (from /data/local/tmp/boot folder)
zImage (from downloads)
recovery
initrd.gz (from downloads)
zImage (from downloads)
settings.ini
Note: When custom kernel with kexec patch will be released, you will use zImage, initrd.gz from that kernel.
We're nearly there. Only two thing remains. Since we'll use munjenis' JB kernel(zImage) or DevSwift1s' ICS kernel we need to flash the proper module for that kernel. Otherwise wifi & other module will not work. So copy the modules from modules folder and paste it in /system/lib/modules folder. Give them permission 644 or rw- r-- r--. Now you have to flash the boot_menu.img to get the menu at startup. That's simple, download the boot_menu.img from download section and flash it by fastboot.
That's it!!! Your current ROM (primary rom) is ready for booting. Reboot your device and you'll enter bootmenu. You'll find options for your Stock JB and CWM Touch Recovery. Simply select your rom and you'll boot into your Primary ROM :laugh::laugh:. Your bootmenu will look like these except you'll have Stock JB option (I'm using SlimBean & CM 10.1 ).
Downloads
Xperia U (JB)​1) packing, unpacking ->View attachment image_tools.rar
2) zImage. modules, recovery ramdisk -> View attachment cwm.rar
3) bootmenu -> View attachment boot_menu.img
Click to expand...
Click to collapse
Xperia Sola (JB)​1) packing, unpacking ->View attachment image_tools.rar
2) zImage, modules, recovery ramdisk, bootmenu
Click to expand...
Click to collapse
Xperia Go (JB)​1) packing, unpacking ->View attachment image_tools.rar
2) bootmenu
3) zImage, modules, recovery ramdisk
Click to expand...
Click to collapse
Xperia P ​Download from this thread http://forum.xda-developers.com/xperia-u/p-development/-t2647623
Click to expand...
Click to collapse
Xperia U, Sola, Go (ICS)​1) packing, unpacking -> same as JB
2) zImage. modules, -> here
3) recovery ramdisk, bootmenu -> same as JB
Click to expand...
Click to collapse
Customized Bootmenu, Recovery​http://forum.xda-developers.com/showpost.php?p=45733631&postcount=349
Click to expand...
Click to collapse
​::Credits::​
@munjeni bro for this awesome feature in our awesome device. ALL HAIL MUNJENI
@DevSwift1 for providing ICS kexec patched kernel
@percy_g2 for his work on Xperia P
Me, for writing this guide
Welcome to the second part of this guide . Here I'll cover how to create partitions in sdcard and from them how to boot the second ROM. Things that you need to know before doing this:
First if you do these, I'm assuming you've succeeded in booting into primary ROM. If not, please don't do this.
You need to have some space in your sdcard (depends on your rom size).
You can't use CWM Touch Recovery (created earlier) in your second ROM. You have to use its' own recovery. But its' recovery also won't work without modification. It'll be discussed in part2.
You can't flash ROM.zip normally on second ROM. For that you have to modify your updater-script a little bit. It'll be discussed in part 3.
Getting worried? Well, don't be. It's easy if you follow the steps thoroughly :fingers-crossed:
Let's get started!!!
Booting Into Second ROM
From Internal Storage​
Part 1: Creating Partition in SDCARD
We have to create three separate partition. One for system, one for data & last one for cache since your current roms' data, system, cache won't match with your second rom. Now say you want CM 10.1 as your second rom. It's size is around ~175MB. After unzipped it is ~290MB and with gapps it becomes ~450MB. So we'll create around 600~650MB sized system partition. Always create system with more space otherwise android will fail to boot.
Enough talk. Let's jump into action. Connect your phone, establish ADB connection do as the following:
Code:
adb shell
su
df
this'll show all your mounted partitions and their status. See that system is mounted at /dev/block/mmcblk0p10, data is mounted in /dev/block/mmcblk0p11, cache in /dev/block/mmcblk0p12 (see screenshot). We need to remember this for future use.
Now to create all partitions do as following after reading the explanation below:
Code:
[B][CENTER]##### for system partition only ([COLOR="red"]Updated[/COLOR]) #####[/CENTER][/B]
[COLOR="Red"]dd if=/dev/zero of=/sdcard/your_desired_folder/system.ext4 bs=4096 count=(your desired size)[/COLOR]
###### wait till the partitions is created ######
[COLOR="Red"]losetup /dev/block/loop1 /sdcard/your_desired_folder/system.ext4
blkid /dev/block/mmcblk0p10 ([COLOR="blue"]this'll give you a UUID[/COLOR])
mke2fs -T ext4 -O has_journal,extent,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize -U ([COLOR="Blue"]paste here your UUID[/COLOR]) -I 256 /dev/block/loop1
losetup -d /dev/block/loop1[/COLOR]
[B][CENTER]##### for data,cache partition #####[/CENTER][/B]
dd if=/dev/zero of=/sdcard/your_desired_folder/data.ext4 bs=4096 count=[COLOR="Blue"][B]76800[/B][/COLOR]
###### wait till the partitions is created ######
dd if=/dev/zero of=/sdcard/your_desired_folder/cache.ext4 bs=4096 count=(your desired size)
###### wait till the partitions is created ######
Ok, let's explain these. "dd" comand will create partition based on the parameter given by you. So in these case partition will be created from /dev/zero to /sdcard/your_folder. Be careful, don't switch "if" with "of" and "of" with "if", it may brick your device. Notice that there are some other parameters. "bs" is the blocksize of your new partition and it's default value is 4096KB(4MB). Don't change it. Let's say you want to create data partition with size of 300MB (cause you don't use many apps). So 300/4(block size) = 75 and 75*1024 = 76800. That's the "count" parameter. So modify system, data, cache size according to your needs but make sure that you have enough space to create your desired partition. "losetup" basically sets up the loop so that you can mount your partition into that loop.
Update: You can now create system partition with exact amount of size instead of cloning them ( big thanks to munjeni again ). Before, creating specific sized system partition caused bootloop cause it was missing an unique identifier (UUID). Now it has been fixed (marked with red code).
Now comes more complex steps. You need to make sure to avoid any partition corruption and check for errors. Reboot your phone to bootmenu and press any key to avoid auto restart. Keep the device in boot menu. Now again check your adb connection and do these:
Code:
adb shell
losetup /dev/block/loop1 /sdcard/your_folder/system.ext4
losetup /dev/block/loop2 /sdcard/your_folder/data.ext4
losetup /dev/block/loop3 /sdcard/your_folder/cache.ext4
##### To pack/unpack ext4 #####
make_ext4fs /dev/block/loop1
make_ext4fs /dev/block/loop2
make_ext4fs /dev/block/loop3
##### To check for error #####
e2fsck -f -y /dev/block/loop1
e2fsck -f -y /dev/block/loop2
e2fsck -f -y /dev/block/loop3
##### for tuning and cleaning up ([COLOR="red"]just loop2 & loop3[/COLOR]) #####
tune2fs -o journal_data_writeback /dev/block/loop2
tune2fs -o journal_data_writeback /dev/block/loop3
##### unmount loop and sdcard #####
losetup -d /dev/block/loop1
losetup -d /dev/block/loop2
losetup -d /dev/block/loop3
umount /sdcard
##### reboot #####
exit
adb reboot
That's it!!!! Your new partitions are now ready for booting. :laugh::laugh:
Part 2: Modifying Second ROMs' Ramdisk
So while booting into primary rom, we simply put the ramdisk in /sdcard/bootmenu/StockJB without modifying it. Why do we need to modify it for second rom? Well unless modified, all your recoveries will recognize only your primary rom. So If you flash a rom thinking that it'll be installed in second rom, you'll see it got installed in your primary rom!!! So we'll modify the second roms' recovery so that it can use second rom while cwm touch recovery will use primary rom. Two recoveries for two roms
First, extract boot.img from your second roms' zip file and place it in /data/local/tmp folder (if any boot.img or boot folder is present there just delete it). Then extract the boot.img the same way as discussed in 1st post (part2). Then you'll have boot folder in /data/local/tmp. After that do as following:
Code:
cd /data/local/tmp/boot
mkdir ramdisk
cd ramdisk
gunzip < ../initrd.gz | cpio -i -d
this'll extract ramdisk(initrd.gz) in the ramdisk folder inside boot folder. copy this ramdisk folder in your desktop. Inside there are many files. We only need to modify some of them. Ok, change these files in the following area:
For JB Ramdisk​
init.rc
find line "mkdir /system" and add line: "mkdir /sde" before line mkdir /system"
Click to expand...
Click to collapse
fstab.st-ericsson
# Android fstab file.
#<src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags>
# The filesystem that contains the filesystem checker binary (typically /system) cannot
# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
/dev/block/mmcblk0p6 /modemfs ext4 noatime,nosuid,nodev,nomblk_io_submit,errors=panic wait,check
/dev/block/loop1 /system ext4 ro wait
/dev/block/loop2 /data ext4 noatime,nosuid,nodev,nomblk_io_submit,errors=panic wait,check
/dev/block/loop3 /cache ext4 noatime,nosuid,nodev,nomblk_io_submit,errors=panic wait,check
Click to expand...
Click to collapse
recovery.fstab
# mount point fstype device [device2] fstype2
/boot emmc /dev/null
/system ext4 /dev/block/loop1
/data ext4 /dev/block/loop2
/cache ext4 /dev/block/loop3
/sdcard vfat /dev/block/mmcblk0p14
/external_sd vfat /dev/block/mmcblk1p1 /dev/block/mmcblk1
Click to expand...
Click to collapse
init.st-ericsson.rc
on fs
# If you change anything here, make sure to update
# <root>/vendor/semc/system/bootstrap/masterreset/fstab.riogrande
# accordingly.
setprop ro.crypto.state unsupported
wait /dev/block/mmcblk0p14
mkdir /sde
mount vfat /dev/block/mmcblk0p14 /sde rw wait
exec /sbin/losetup /dev/block/loop1 /sde/your_folder/system.ext4
exec /sbin/losetup /dev/block/loop2 /sde/your_folder/data.ext4
exec /sbin/losetup /dev/block/loop3 /sde/your_folder/cache.ext4
exec /sbin/e2fsck -y /dev/block/loop2
mount_all fstab.st-ericsson
# SEMC: Start the TrimArea Daemon and early TA-users
Click to expand...
Click to collapse
For ICS Ramdisk​
fstab (if doesn't exist, ignore it)
# These declarations must match the mount statements in
# <buildroot>/device/semc/riogrande/files/init.riogrande.rc
/data ext4 /dev/block/loop2
/cache ext4 /dev/block/loop3
/modemfs ext4 /dev/block/mmcblk0p6
Click to expand...
Click to collapse
init.rc
find line "mkdir /system" and add line: "mkdir /sde" before line mkdir /system"
Click to expand...
Click to collapse
recovery.fstab
# mount point fstype device [device2] fstype2
/boot emmc /dev/null
/system ext4 /dev/block/loop1
/data ext4 /dev/block/loop2
/cache ext4 /dev/block/loop3
/sdcard vfat /dev/block/mmcblk0p14
#/sd-ext ext4 /dev/block/mmcblk0p2
/emmc vfat /dev/block/mmcblk1p1 /dev/block/mmcblk1
Click to expand...
Click to collapse
init.st-ericsson.rc (red lines are modified & blue lines are new)
on fs
# If you change anything here, make sure to update
# <root>/vendor/semc/system/bootstrap/masterreset/fstab.riogrande
# accordingly.
# Wait for eMMC device to become available
wait /dev/block/mmcblk0p14
mkdir /sde
mount vfat /dev/block/mmcblk0p14 /sde rw
exec /sbin/losetup /dev/block/loop1 /sde/your_folder/system.ext4
exec /sbin/losetup /dev/block/loop2 /sde/your_folder/data.ext4
exec /sbin/losetup /dev/block/loop3 /sde/your_folder/cache.ext4
# Mount system partition
mount ext4 /dev/block/loop1 /system ro
# Mount user data partition
exec /system/bin/logwrapper /system/bin/e2fsck -y /dev/block/loop2
setprop ro.crypto.state unsupported
mount ext4 /dev/block/loop2 /data nosuid nodev noatime noauto_da_alloc
# Mount cache partition
mount ext4 /dev/block/loop3 /cache nosuid nodev noatime
mount ext4 /dev/block/mmcblk0p6 /modemfs nosuid nodev noatime
# FOTA must be started after partitions are mounted
# and property service is initialized
exec /sbin/fota-ua c
Click to expand...
Click to collapse
That's it. You're done editing. Now save & copy these modified files to your /data/local/tmp/boot/ramdisk folder. Then in cmd do as the following:
Code:
cd /data/local/tmp/boot
mkbootfs ./ramdisk | gzip > initrd.gz
this'll repack the ramdisk folder into initrd.gz and save it in /data/local/tmp/boot folder. Make a new folder in your /sdcard/bootmenu for the new rom and copy this initrd.gz to that folder. Also copy the appropriate zImage for ICS/JB and paste it here. Add a new rom settings in settings.ini for this rom. Now you've your ramdisk ready and modified for flashing zips in second rom .
Part 3: Finishing Touch
We're at the end of this long road. You just have to modify your "rom.zip"s updater-script so that it flashes the rom in your newly created partition. Extract your updater-script, open it with editor. Remember that we saw system is in /dev/block/mmcblk0p10, data in /dev/block/mmcblk0p11, cache in /dev/block/mmcblk0p12. Find all the lines that start with "format" or "mount" (example format("ext4", "EMMC", "/dev/block/mmcblk0p10", "0")) and replace the /dev/block/mmcblk0p10 with /dev/block/loop1, /dev/block/mmcblk0p11 with /dev/block/loop2 and /dev/block/mmcblk0p12 with /dev/block/loop3. Also remove the function that flashes the kernel. It's usually at the end of the script. Just search for kernel.elf or boot.img and delete that function. Save the updater-script and push it into the zip with winrar. Choose compression "store".
NOTE: If you forget to remove the kernel function then don't worry. It just removes your bootmenu when you flash the second rom. Just power off the device after flashing and flash boot_menu.img again by fastboot.
Now reboot to bootmenu, your second roms' title that you defined in settings.ini will appear here. Select it, then phone will restart and load your second rom. Press vol. down repeatedly to enter its' recovery. From there flash your second rom. Reboot again to bootmenu and select second rom again. Now you'll see second ROM BOOTING !!!!!!! :good::good:
Hope it is clear to all of you. I tried my best to explain everything. If you need help, feel free to post. Also if you like my guide, give it a 5 star and press thanks to appreciate my work
================== THE END ==================​
F.A.Q​
1. Will this work on GB,ICS ?
Ans: Now Working For ICS based ROM too. See this post for kexec patched kernels ICS kernel with kexec support
For GB, you have to wait for kernel.
2. How can I remove the second ROM ?
Ans: Make sure you are in primary ROM, then just delete the 3 partitions from sdcard.
3. Can't unmount sdcard: device or resource busy
Ans: Type fuser -km /sdcard. It'll kill all the process that's keeping your sdcard busy. Then unmount sdcard.
4. Getting status 7 error ?
Ans: Delete assert function from updater-script.
5. Wifi's not working even after flashing modules from attachment ?
Ans: Unpack initrd.gz and see if there's a lib/modules folder inside it. If it exists and deep inside there are 2 modules, then you need to replace them with the ones from attachment.
6.Getting status 6 error no matter what ?
Ans: Always edit files in unix/utf-8 format and use compression method store to push files in zip. NEVER USE DOS FORMAT.
7.Getting "somthing went wrong. please see log!" in bootmenu ?
Ans: You have done something wrong in settings.ini or folder naming. Check again.
Very good tut. Men !
Nice Bro,
So we don't need system.ext4, data.ext4 and cache.ext4 in sdcard?
I think this thread belong to Xperia U develompent section.
JohnLouise said:
Very good tut. Men !
Click to expand...
Click to collapse
thnx
mohammadagha said:
Nice Bro,
So we don't need system.ext4, data.ext4 and cache.ext4 in sdcard?
I think this thread belong to Xperia U develompent section.
Click to expand...
Click to collapse
Yes we'll need them for second ROM. I'll upload guides for them soon
If it belongs to dev section, pls can someone tell the moderator to move it ?
Nice
You are the best :good::laugh:
Good start!
very nice tutorial
@NoobCoder How the hell did u take screenshot in bootmenu recovery bro? :laugh:
Delete this thread fast and make new one in Development section because if u wait for Moderators and they say u can not move thread, Many pepole will lost this good thread.:good:
NoobCoder said:
I'll upload soon guides for booting into second ROM. Pls be patient
Click to expand...
Click to collapse
Thanks for this bro.... waiting for other part..... :cheers:
Anthrax said:
Thanks for this bro.... waiting for other part..... :cheers:
Click to expand...
Click to collapse
cmdline in setting.ini belongs to Xperia U, You can find it for sola, Just open kernel.elf for sola with notepad, You can find it at the end of notes.
mohammadagha said:
@NoobCoder How the hell did u take screenshot in bootmenu recovery bro? :laugh:
Delete this thread fast and make new one in Development section because if u wait for Moderators and they say u can not move thread, Many pepole will lost this good thread.:good:
Click to expand...
Click to collapse
By DDMS . Also I reported this thread to move into the dev section, but moderator said this is the right section. Anyway to all users, please report this thread to make it sticky/pinned so that no one have any problems finding it
in step 2 i got this error in cmd:
Using existing folder ./boot
dd: can't open 'boot.img': No such file or directory
FAILURE to dump boot.img to ./boot! Pllease try another folder!
I know what kernel i'm using so can i just extract it with winrar
can u post same for Xperia P
dd98 said:
in step 2 i got this error in cmd:
Using existing folder ./boot
dd: can't open 'boot.img': No such file or directory
FAILURE to dump boot.img to ./boot! Pllease try another folder!
I know what kernel i'm using so can i just extract it with winrar
Click to expand...
Click to collapse
No, boot.img can't be extracted with winrar. you copied the boot.img to /data/local/tmp, right ? Please provide a screenshot if this doesn't help you.
Aamirx12 said:
can u post same for Xperia P
Click to expand...
Click to collapse
Sorry bro, munjeni stopped P's development. So I can't do it
Thanks mate! I was waiting for this for a long time. It ws actually ment for go and sola, but ultimately, munjeni ended up with developing it for U
Thanks to him too!
One more question.
What exactly i have to do to make this for sola?
Sorry to bother you..
Sent from my MT27i using xda app-developers app
cpkunki said:
Thanks mate! I was waiting for this for a long time. It ws actually ment for go and sola, but ultimately, munjeni ended up with developing it for U
Thanks to him too!
One more question.
What exactly i have to do to make this for sola?
Sorry to bother you..
Sent from my MT27i using xda app-developers app
Click to expand...
Click to collapse
Guess we're the lucky ones . Also there were many user who tried to test. That encouraged munjeni bro to keep the thread updated.
I'll check files uploaded by munjeni to get an idea how to do it in sola. But I think he mentioned it in post 4 in sola section. Check that and follow this guide. I'm sure you'll be able to do it
Can't umount
When I write umount /sdcard (final step) the CMD say me: can't umount /storage/sdcard0: Device or resource busy.
But I have 1.2 gb free space in the SD. Why?
cesanaboia said:
When I write umount /sdcard (final step) the CMD say me: can't umount /storage/sdcard0: Device or resource busy.
But I have 1.2 gb free space in the SD. Why?
Click to expand...
Click to collapse
That's strange. It didn't occur to me. You have 1.2GB free after creating all partition or before? If before, then you have to free more space. If it doesn't help, pls post a screenshot. Also don't create partitions yet. I'll update the post with new code.
Sent from my Xperia U using Tapatalk 2

Move /data/apps to sdcard

What I want to do is partition my sdcard into 2 parts, 1 fat32 and the second as ext3. Mount both partitions at startup so i get /sdcard (fat) and /sdcardext3 (ext). Then create 2 folders /sdcardext3/apps and /sdcardext3/apps-private then delete the /data/apps and /data/apps-private folders and replace them with links to the folders on the sdcard 2nd partition I just created. Is this possible? I guess I'll be having to muss around with fstab but I'm not too well versed on that. Anyone got any tips on how I can achieve this. I know there are apps like foldermount and link2sd but they only work on a per app basis, i want a full "do it and forget it" solution that doesn't rely on an app.
Cheers
EDIT:
I'm seeing these 3 lines in /init.rc
Code:
mount rfs /dev/stl11 /data nosuid nodev usedm check=no
chown system system /data
chmod 0771 /data
Is it possible to create and format an rtf partition on the sdcard, then extract, change and repack the ramdisk image with the following changes?
Code:
mount rfs /dev/block/vold/179:2 /data nosuid nodev usedm check=no
chown system system /data
chmod 0771 /data
To move the data folder completely off the phone internal memory. My phone only has 512MB and my external SD is 64GB so I won't cry at the wasted half a gig.
So far I've managed to:
extract the boot.img from the stock firmware I'm using. Using a linux box with abootimg installed (apt-get abootimg)
I split it up into the kernel (zImage) and the ramdisk (initrd.img) .
Unpacked and cpio-ed initrd.img to files.
Edited init.rc and found two instances of
Code:
mount rfs /dev/stl11 /data nosuid nodev usedm check=no
in the file
Replaced /dev/stl11 with /dev/block/mmcblk0p2 and replaced rfs with ext3.
Combined the kernel and ramdisk back together with gzip, cpio and abootimg (newboot.img) and dumped it onto the phone using adb along with the flash_image command (which wasn't on the phone as standard).
Had to copy flash_image (in fact I had to cat flash_image >/data/flash_image because there's no cp command as standard either) to /data as it needed executable privs, chmod 777 /data/flash_image to allow it to execute,
Then execute /data/flash_image boot /sdcard/newboot.img
Reboot phone
Phone;s stuck on the Samsung splash screen, pah. Was worth a try anyway.

Mount ext4 formatted SD card

Requirements:
Rooted device
SD card formatted to ext4/3/2
Terminal app installed
Optional: A file explorer (I use ES file explorer)
Basic command line knowledge
Step 1: Run as root
Open the terminal app and execute this:
Code:
su
This is necessary for the next commands to be executed with root privilege.
Step 2: Identify SD card partition(s)
Execute:
Code:
blkid
or
Code:
cat /proc/partitions
This will spit out a bunch of partitions but we're looking for a device that reads something like "/dev/block/mmcblk1".
In my case there's two of those, because I have two partitions on my SD card. One reads "mmcblk1p1", which is ExFat and the other reads mmcblk1 and is ext2. We'll be mounting the second one, so my partition is /dev/block/mmcblk1p2. It isn't ext4 but the the process is the same.
Step 3: Create folder to mount to
We will need to create a folder to mount the partition to and I will go along with the "/storage/sdcard0" directory and choose "/storage/sdcard1". You can however choose any name you want.
So run this:
Code:
mkdir /storage/sdcard1
or replace sdcard1 with a different name if desired.
Step 4: Mounting
The command syntax for mounting is as follows:
Code:
mount -t ext4 partition path
My device is "/dev/block/mmcblk1p2" and my path is "/storage/sdcard1" so this is what I'll run:
Code:
mount -t ext4 /dev/block/mmcblk1p2 /storage/sdcard1
(I used ext4 with an ext2 partition but it works regardless.)
If there were no issues the command will run without an output.
Now you can test if it's mounted by going into the folder with
Code:
cd /storage/sdcard1
and making a folder:
Code:
mkdir test
If you list the files:
Code:
ls
you should see "test".
Step 5: Gaining read/write permission
Execute:
Code:
chmod -R 777 /storage/sdcard1
obviously with your own path and now you should be able to open the directory in a file manager and write into it.
Works, but no file managers recognise its mounted.
Spaceboy60 said:
Works, but no file managers recognise its mounted.
Click to expand...
Click to collapse
Check the folder you made with mkdir, it should be there.

Categories

Resources