[Q] Why are there a lot of partitions in Android devices ? (DEV Question) - LG Optimus 3D

I think this is moronic , an ext4 partition to maintain the system and a swap partition for oom situations and cached processes is enough.
Obviously there are some benefits like if your system partition is corrupted you don't lose the data but since most non-dev users will end up either reflashing the device from scratch or take it to the service center anyway , it's not logical.
Plus , i've never seen an ext4 partition get corrupted on hdds let alone ssds...
USB connectivity is solved by MTP and you can do what you cannot with mtp with adb...
It would save the developers from a lot of work and not just devs on xda , manufacturers' own devs.
I looked at my partition table and there are over 10 partitions , what the f... is this i mean ?
When you compile a new kernel , you need to write scripts mounting over 10 partitions , manually...
and i'm not even counting the flags that refer to those partitions...
I had to learn a lot of things to compile a kernel for our device from the source , now i find out that i have to do this huge manual labor for no logical reason , i'm pissed off naturally.
Does anybody have something , i missed ? or Am i right on the spot ?
I'm really hoping that i missed something , because if i didn't then it'd mean that people who made this system are idiots.

Related

Regarding disk space

Has anyone tried to repartition our /system and /data folders to create an /emmc partition for our phones? Seems like OE partitioning scheme is a huge waste of space and we could better utilize the extra space if it was in user mountable partition.
This should be easy to do via recovery yes?
Sent from my MB865 using xda premium
unsivil_audio said:
Has anyone tried to repartition our /system and /data folders to create an /emmc partition for our phones? Seems like OE partitioning scheme is a huge waste of space and we could better utilize the extra space if it was in user mountable partition.
This should be easy to do via recovery yes?
Sent from my MB865 using xda premium
Click to expand...
Click to collapse
Yes both lfaber06 and I sort of do something similar, with the way we have safestrap setup, but we use the SDcard instead. The one issue I see with this is what the future brings for this phone, like what moto might do for us with ICS, and such, what may be needed in these partitions to make it work. Other that that I don't see an issue, but you will have to change a ton of start scripts if the partition numbers change.
Jim
Sent from my MB865 using xda premium
I don't think you understand, I want the space to be user accessible, like I have on my nook. I flashed a custom repartition from cwm to resize data and media partitions. The /emmc partition is a fat32 partition I believe (on my nook anyways). I've never even come close to filling my 2gb data partition, and now I have 4gb of space for music or videos storage.
unsivil_audio said:
I don't think you understand, I want the space to be user accessible, like I have on my nook. I flashed a custom repartition from cwm to resize data and media partitions. The /emmc partition is a fat32 partition I believe (on my nook anyways). I've never even come close to filling my 2gb data partition, and now I have 4gb of space for music or videos storage.
Click to expand...
Click to collapse
No, I don't think you understand what that really does under the covers. Both lfaber06 and I have been working on this device for a while, we are the ONLY two devs currently working on this device. What I am telling you is that if you change the size of ANY of the internal partitions, It might effect the ability to update to another version of Android. Your Nook, is not a Mototrola device, and Moto has completly messed with/up android, and therefore it is not safe to do what you are saying. No matter what you can not get access to the internal partitions, yes on AOSP devices / devices that can be AOSP (the nook is one), you can do those things. The Atrix2 still has a locked bootloader, so we are stuck with their kernel, and version of android. To do what you are saying you will need to have an AOSP kernel, and have MANY init scripts updated to understand the new partition table. It is not as easy as you make it out to be.
Okay, I was under the impression with rw abilities on /system and /data partitions we also have the ability to mount, unmount; also giving us the ability to edit the partition blocks via bootstrap.
Ok how about this, there is a guy in the Nook Tablet forum (locked bootloader, like us) who had the idea of basically running a fat32 "img" that in the /data (ext4) partition to that would mount via a script and be user accessible? That would be possible I would think.
unsivil_audio said:
Okay, I was under the impression with rw abilities on /system and /data partitions we also have the ability to mount, unmount; also giving us the ability to edit the partition blocks via bootstrap.
Ok how about this, there is a guy in the Nook Tablet forum (locked bootloader, like us) who had the idea of basically running a fat32 "img" that in the /data (ext4) partition to that would mount via a script and be user accessible? That would be possible I would think.
Click to expand...
Click to collapse
Yes you do have access to all of those things with root, but Moto has done so much customization to this thing, that would not be safe.
Yes, that is also something that lfaber06 and I have thrown around as well, the logistics of it need to be worked out for our phone, and the proper init scripts need to be put together.
Are you up for the task? I only ask because he and I are currently working on porting cm7 and cm9 to our phone, which is a huge task. I can help you out, but I just can't take on anymore projects for this phone at the moment, since I have 5 different things I am working on for us right now.
I am definitely down to help, still going to be a bit of a learning curve for myself. Still pretty new to linux/android.
unsivil_audio said:
I am definitely down to help, still going to be a bit of a learning curve for myself. Still pretty new to linux/android.
Click to expand...
Click to collapse
PM me, with as much info as you have about this, preferably any links that you have read, and I will help you develop a game plan, and what you will need to make this hack happen. You will have to do some research on your own, and I can help with the Linux/Android part, and help you figure out what you will need to do. I am also not sure on the what kind of speed to expect from something like this, so that will also be something to look into, since this will be a virtual disk file.

[DEV] Alternative solution for brocken data

Hi guys
Im really angry that lots of my friends got brocken emmc , I decided to make an alternative way til we have an fix way !
my alternative way is to make an partition on ext-sd and store system on it and swap data and system partitions on mmcblk0 then system will be on.ext-sd and data on mmcblk0p15 ! so we wont have any speed reductions and may some speed improvement ... people who have brocken data can use this to use their.phone and ignore brocken blovk 17 til we have a way to fix it !
we need a kernel dev and a recovery dev and a rom dev ; I can do recovery dev work but Im not a kernel dev , so I hope a kernel dev come and help in proccess
first we need to create an ext4 partiton in ext-sd like mmcblk1p3
then we need a modified qcom.fstab for kernel to mount system from mmcblk1p3 and mount data from mmcblk0p15
then we need a recovery.fstab which i can make ... it will allow us to format system and data from currect partitions
I think we need some changes in cm10.1 roms in board-confing.mk ( updateing data size )
if some devs help we can make an alternative way ..
hey devs please help to fix peoples devices ....
waiting for a kernel and rom dev
thanks in advance
regards
Alireza

[SOLVED] Completely format system data cache partitions[making all zeroes]

I know the obvious ans would be to use 4ext superwipe.
What I want is like re-writing those partitions with all memory locations set to zeroes. The 4ext full wipe only works like quick format in windows desktop.
Any ideas how to do it?
____________________
Solved. See post 17 for details.
pushpann said:
I know the obvious ans would be to use 4ext superwipe.
What I want is like re-writing those partitions with all memory locations set to zeroes. The 4ext full wipe only works like quick format in windows desktop.
Any ideas how to do it?
Click to expand...
Click to collapse
Had to search a bit, but found an article that explains how to do this. It links to 3 apps (havn't tested myself, just remember there's no going back), from the description the first one only works on SD card, the second one might (it does not mention which partitions it formats), and the last one seems to be removed.
I did not read the whole article, but I suggest you do that before doing anything.
Good luck.
pushpann said:
I know the obvious ans would be to use 4ext superwipe.
What I want is like re-writing those partitions with all memory locations set to zeroes. The 4ext full wipe only works like quick format in windows desktop.
Any ideas how to do it?
Click to expand...
Click to collapse
Hi,
A RUU will reset everything back to stock, and fix any partition issues.
Is that what you are after?
malybru said:
Hi,
A RUU will reset everything back to stock, and fix any partition issues.
Is that what you are after?
Click to expand...
Click to collapse
As he said, he wants it to be completely formatted, meaning no data can be recovered, which is like a hard full wipe - no way to restore.
RUU does format the data partition, but it only removes records of files, and the data itself is still available and possible to read (until new files will be written over it).
No! I dont want to get involved with RUU stuff.. I just want to completely wipe my phone.. Like complete formatting of the USB drives. All system and data partitions set to zeroes.
In simple words, if you do quick formating on pendrives, you can restore (some or all data before format, depends on what you've put on the drive after format ) using some Data Recovery tools.
What i believe is that recovery just wipes the memory addresses, without putting zeroes on all the memory locations. have been googling for this for almost a week, haven't got any clue yet!
pushpann said:
I know the obvious ans would be to use 4ext superwipe.
What I want is like re-writing those partitions with all memory locations set to zeroes. The 4ext full wipe only works like quick format in windows desktop.
Any ideas how to do it?
Click to expand...
Click to collapse
I would do it this way (this is something I came up with, and if it screws up anything, you are responsible) :
Write a script that reformat your nand rom and then dumps (creates) a huge file containing zeroes. Then reformat using 4ext and repartition.
I am curious, why exactly do you want to do this? The lack of results from Google would suggest that this is not something people would normally do.
JAM THAT THANKS BUTTON.
Happy to help.
I assume you're not going to use the phone after?
If you aren't going to use the phone after, one word. Sledgehammer.
If you are keeping the phone; create a file on the partition filled with rubbish (linux has a command for this). Make sure it fills the entire partition and then run mkfs.ext4 /dev/block/partition. Repeat a dozen times or create a script to do it for you.
It's easier than erasing the whole NAND disk and partitioning it. Mainly because you'll wipe the recovery partition and create an expensive paperweight. Which brings me back to sledgehammer.
Sent from my HTC
pushpann said:
No! I dont want to get involved with RUU stuff.. I just want to completely wipe my phone.. Like complete formatting of the USB drives. All system and data partitions set to zeroes.
In simple words, if you do quick formating on pendrives, you can restore (some or all data before format, depends on what you've put on the drive after format ) using some Data Recovery tools.
What i believe is that recovery just wipes the memory addresses, without putting zeroes on all the memory locations. have been googling for this for almost a week, haven't got any clue yet!
Click to expand...
Click to collapse
On my first commented I linked to an article which gives two ways to wipe your phone (set to zeroes and all). Here are the two apps:
https://play.google.com/store/apps/details?id=com.kovit.p.forevergone
https://play.google.com/store/apps/details?id=ch.ethz.infsyssec.sddroid
Try those to see if they format the Data partition.
Far_SighT said:
I would do it this way (this is something I came up with, and if it screws up anything, you are responsible) :
Write a script that reformat your nand rom and then dumps (creates) a huge file containing zeroes. Then reformat using 4ext and repartition.
I am curious, why exactly do you want to do this? The lack of results from Google would suggest that this is not something people would normally do.
JAM THAT THANKS BUTTON.
Happy to help.
Click to expand...
Click to collapse
Hmm.. My phone has become very laggy.. No matter what ROM flash, what firmware I flash.
DennisBold said:
I assume you're not going to use the phone after?
If you aren't going to use the phone after, one word. Sledgehammer.
If you are keeping the phone; create a file on the partition filled with rubbish (linux has a command for this). Make sure it fills the entire partition and then run mkfs.ext4 /dev/block/partition. Repeat a dozen times or create a script to do it for you.
It's easier than erasing the whole NAND disk and partitioning it. Mainly because you'll wipe the recovery partition and create an expensive paperweight. Which brings me back to sledgehammer.
Sent from my HTC
Click to expand...
Click to collapse
By hearing what you say, i kinda feel little scared to do these steps. Anyway thanks for the suggestion..
astar26 said:
On my first commented I linked to an article which gives two ways to wipe your phone (set to zeroes and all). Here are the two apps:
https://play.google.com/store/apps/details?id=com.kovit.p.forevergone
https://play.google.com/store/apps/details?id=ch.ethz.infsyssec.sddroid
Try those to see if they format the Data partition.
Click to expand...
Click to collapse
Those apps dont work.. By internal data they mean internal sdcard not system or data partition.
BTW just saw this app called lagfix. It says it will discard the unused blocks, but doesnot work on my phone.. Has anyone tried it? For me it's saying trim on system,data and cache not supported! DAMN
DennisBold said:
I assume you're not going to use the phone after?
If you aren't going to use the phone after, one word. Sledgehammer.
If you are keeping the phone; create a file on the partition filled with rubbish (linux has a command for this). Make sure it fills the entire partition and then run mkfs.ext4 /dev/block/partition. Repeat a dozen times or create a script to do it for you.
It's easier than erasing the whole NAND disk and partitioning it. Mainly because you'll wipe the recovery partition and create an expensive paperweight. Which brings me back to sledgehammer.
Sent from my HTC
Click to expand...
Click to collapse
Yeah, I had similar thoughts. I was going for repartition becasue then the whole of nandroid can be wiped in one go.
To clean the phone, sledgehammer / mowing the device with a car (or both, one after the other) are the best methods.
Here's one more idea. Create a pseudo nandroid backup with all of your nandroid partitions(/system /data /cache etc) filled with garbage/zeroes. Then restore that. And bam, the nandroid is hard formatted (after a quick format of course).
Like always, it's your phone. I am not responsible for anything that you do to it.
JAM THAT THANKS BUTTON.
Happy to Help.
pushpann said:
Hmm.. My phone has become very laggy.. No matter what ROM flash, what firmware I flash.
By hearing what you say, i kinda feel little scared to do these steps. Anyway thanks for the suggestion..
Those apps dont work.. By internal data they mean internal sdcard not system or data partition.
BTW just saw this app called lagfix. It says it will discard the unused blocks, but doesnot work on my phone.. Has anyone tried it? For me it's saying trim on system,data and cache not supported! DAMN
Click to expand...
Click to collapse
Tried it yesterday, it's meant for certain devices that did not use the TRIM command like they should (Many Nexus 7 tablets were slowed down by this issue), but it seems the Sensation does not need it (or at least our kernels do not support the command).
What seems as the only way to do so is to create many blank files and delete them (like many already said). you can create a large file and copy it a few times to the Data partition, which will fill it, and then delete it. using a normal file manager will work (or you can use "adb push" command to push the file a couple of times).
Far_SighT said:
Yeah, I had similar thoughts. I was going for repartition becasue then the whole of nandroid can be wiped in one go.
To clean the phone, sledgehammer / mowing the device with a car (or both, one after the other) are the best methods.
Here's one more idea. Create a pseudo nandroid backup with all of your nandroid partitions(/system /data /cache etc) filled with garbage/zeroes. Then restore that. And bam, the nandroid is hard formatted (after a quick format of course).
Like always, it's your phone. I am not responsible for anything that you do to it.
JAM THAT THANKS BUTTON.
Happy to Help.
Click to expand...
Click to collapse
You sure it does complete format while restoring nandroid? BTW i still am not sure how to fill system and data partitions with zeroes or garbage! Anyway thanks for the heads up
pushpann said:
You sure it does complete format while restoring nandroid? BTW i still am not sure how to fill system and data partitions with zeroes or garbage! Anyway thanks for the heads up
Click to expand...
Click to collapse
You shouldn't have to worry about formatting empty space. No one ever, except possibly computer forensics is going to want information from an empty phone. They have access to browsing history from Google, call records from your mobile provider and ban access details from your banks. They wouldn't need your phone. There are things that make it hard for the average person. Including mounting the NAND disk in a way that it can be opened like a normal disk drive, and then running the tools to restore data. If someone really wanted data it's possible but they will not go through all that for 500MB of bank details, porn or whatever people do with phones these days. If you're trying to hinder the police because you did something wrong, then you should just stop.
Theoretically it can be done through an android device but cross compiling tools to recover data is long and tedious to do. There is nothing so important that someone would spend hours creating tools for an Android device to restore data that may already be irrevocably gone. Not to mention the learning curve for new software. If you are worried, burn the device and buy something new. That is the general rule for sensitive data. Make sure it's gone before you move on.
It's safe to click "Format all partitions" and then erase your SD card and give your phone away.
If it helps, install Android on top. Choose something big. Most of your application data is stored on your SDCard FYI.
Lastly, if it's lag you are trying to fix. Go backwards with Android not forwards. JellyBean demands more than ICS and ICS demands more than GingerBread. Having the latest OS doesn't work for everyone. For example, Windows 8.1 doesn't work for me because there's no fastboot support without huge editing of system drivers. The same is true in Android. GingerBread stability may be more important than ICS or JB features, or JellyBean features may be more important. However don't expect lag free 4.2 or 4.3, our devices may work with it, but they were never intended to go above 4.1(Ville C2 updates stop there too I think) due to hardware limitations. Others may argue differently, but you should question the effort they're (including me) putting in with kernel and device tree upgrades. It's amazing work nonetheless but it basically shouldn't have to be done if the device were supported. Buy a new device if you want the latest and greatest. My Sensation has become a trophy for me to the amazing things you can do with one of HTCs first dual core phones. I don't expect it to work without some kinks and bugs or even fatal flaws but I still respect it for having running Sense 3.0 to 5.0 (yes I've tried it).
Sorry for the rant. I'm a little bit grumpy, but hope it helps explains why you can mostly erase and install a new version of android then throw the device away and be relatively safe.
There's probably going to be someone who reads all of this and thinks I'm crazy, to that guy or girl. Thanks for reading all of it!
Sent from my HTC
DennisBold said:
You shouldn't have to worry about formatting empty space. No one ever, except possibly computer forensics is going to want information from an empty phone. They have access to browsing history from Google, call records from your mobile provider and ban access details from your banks. They wouldn't need your phone. There are things that make it hard for the average person. Including mounting the NAND disk in a way that it can be opened like a normal disk drive, and then running the tools to restore data. If someone really wanted data it's possible but they will not go through all that for 500MB of bank details, porn or whatever people do with phones these days. If you're trying to hinder the police because you did something wrong, then you should just stop.
Theoretically it can be done through an android device but cross compiling tools to recover data is long and tedious to do. There is nothing so important that someone would spend hours creating tools for an Android device to restore data that may already be irrevocably gone. Not to mention the learning curve for new software. If you are worried, burn the device and buy something new. That is the general rule for sensitive data. Make sure it's gone before you move on.
It's safe to click "Format all partitions" and then erase your SD card and give your phone away.
If it helps, install Android on top. Choose something big. Most of your application data is stored on your SDCard FYI.
Lastly, if it's lag you are trying to fix. Go backwards with Android not forwards. JellyBean demands more than ICS and ICS demands more than GingerBread. Having the latest OS doesn't work for everyone. For example, Windows 8.1 doesn't work for me because there's no fastboot support without huge editing of system drivers. The same is true in Android. GingerBread stability may be more important than ICS or JB features, or JellyBean features may be more important. However don't expect lag free 4.2 or 4.3, our devices may work with it, but they were never intended to go above 4.1(Ville C2 updates stop there too I think) due to hardware limitations. Others may argue differently, but you should question the effort they're (including me) putting in with kernel and device tree upgrades. It's amazing work nonetheless but it basically shouldn't have to be done if the device were supported. Buy a new device if you want the latest and greatest. My Sensation has become a trophy for me to the amazing things you can do with one of HTCs first dual core phones. I don't expect it to work without some kinks and bugs or even fatal flaws but I still respect it for having running Sense 3.0 to 5.0 (yes I've tried it).
Sorry for the rant. I'm a little bit grumpy, but hope it helps explains why you can mostly erase and install a new version of android then throw the device away and be relatively safe.
There's probably going to be someone who reads all of this and thinks I'm crazy, to that guy or girl. Thanks for reading all of it!
Sent from my HTC
Click to expand...
Click to collapse
I dont wanna sell my phone and I know that my data isnt that valueable that anyone will try to read my data with hard efforts. My sensation used to perform awesome 2-3 months back, and now that I must have quick formatted my system and data partitions more than 1500 times, i think a full wipe may do some help for those nag n lag issues.
And about going back to GB? Man, Everyone feels GB is sad after using ICS/JB. If my phone doesnot stop lagging every second after I format these partitions, i think its time for a new phone!
Anyway thanks for such a detailed reply
pushpann said:
I dont wanna sell my phone and I know that my data isnt that valueable that anyone will try to read my data with hard efforts. My sensation used to perform awesome 2-3 months back, and now that I must have quick formatted my system and data partitions more than 1500 times, i think a full wipe may do some help for those nag n lag issues.
And about going back to GB? Man, Everyone feels GB is sad after using ICS/JB. If my phone doesnot stop lagging every second after I format these partitions, i think its time for a new phone!
Anyway thanks for such a detailed reply
Click to expand...
Click to collapse
The lag isn't from formatting. You can try ARHD ICS if you want. Or probably Sense 4+ with 4.1.2 but anything above that might not work out great.
Sent from my HTC
pushpann said:
I dont wanna sell my phone and I know that my data isnt that valueable that anyone will try to read my data with hard efforts. My sensation used to perform awesome 2-3 months back, and now that I must have quick formatted my system and data partitions more than 1500 times, i think a full wipe may do some help for those nag n lag issues.
And about going back to GB? Man, Everyone feels GB is sad after using ICS/JB. If my phone doesnot stop lagging every second after I format these partitions, i think its time for a new phone!
Anyway thanks for such a detailed reply
Click to expand...
Click to collapse
How old is your Sensation? I could well be that your nand is dying. In that case, repartition your phone and make /system and /data from parts seldom used (like /cache).
If you want data security, full encryption will keep noobs away.
Thanks for the replies guys!
Today i actually did the zeroing of the partitions with Nandroid method.. I download an app called dummy file creator and it created dummy files(files with zeroes all over it. after searching in internet it seemed legit method of fully zeroing out the memory locations) in data partition untill it ran out of memory. Then i copied those files to system partition too manually till it also became full(I had to do this manually because the app didnt support creating dummy files in system partition) and made nandroid of data and system separately then did almost a dozen time 4ext format and restoring the nandroid. Finally i formatted all the partitions and installed Codename Lungo ROM(CM10.1).
HELL YEAH! it feels FASTer. Not sure if its gonna last long.
pushpann said:
Thanks for the replies guys!
Today i actually did the zeroing of the partitions with Nandroid method.. I download an app called dummy file creator and it created dummy files(files with zeroes all over it. after searching in internet it seemed legit method of fully zeroing out the memory locations) in data partition untill it ran out of memory. Then i copied those files to system partition too manually till it also became full(I had to do this manually because the app didnt support creating dummy files in system partition) and made nandroid of data and system separately then did almost a dozen time 4ext format and restoring the nandroid. Finally i formatted all the partitions and installed Codename Lungo ROM(CM10.1).
HELL YEAH! it feels FASTer. Not sure if its gonna last long.
Click to expand...
Click to collapse
Just found something and wanted to add - for future reference - Android Tuner seems to be able to make the TRIM operation on all partitions on our sensation, in a much easier way.
pushpann said:
Thanks for the replies guys!
Today i actually did the zeroing of the partitions with Nandroid method.. I download an app called dummy file creator and it created dummy files(files with zeroes all over it. after searching in internet it seemed legit method of fully zeroing out the memory locations) in data partition untill it ran out of memory. Then i copied those files to system partition too manually till it also became full(I had to do this manually because the app didnt support creating dummy files in system partition) and made nandroid of data and system separately then did almost a dozen time 4ext format and restoring the nandroid. Finally i formatted all the partitions and installed Codename Lungo ROM(CM10.1).
HELL YEAH! it feels FASTer. Not sure if its gonna last long.
Click to expand...
Click to collapse
Can you guide me? i want to do that but i'm noob . how did you do that? pls help me
BSHD666 said:
Can you guide me? i want to do that but i'm noob . how did you do that? pls help me
Click to expand...
Click to collapse
hehe you found it:good:

[Completed] How easy/difficult it is to partition eMMC on android devices using partition apps?

There are a plethora of apps on the PlayStore that claim to actually "resize" your eMMC partitions. How well do they work? Can you just install it and change your say internal partition from 500MB to 1GB?
To the best of my knowledge, partition tables are kept well hidden and behind lots of complexities on various devices. The repartitioning methods are different on each device and too complex to try out (I know many on the MIUI forum who ended up bricking their devices or damaging their motherboards while trying to repartition).
Then how do these partition apps work?
prahladyeri said:
There are a plethora of apps on the PlayStore that claim to actually "resize" your eMMC partitions. How well do they work? Can you just install it and change your say internal partition from 500MB to 1GB?
To the best of my knowledge, partition tables are kept well hidden and behind lots of complexities on various devices. The repartitioning methods are different on each device and too complex to try out (I know many on the MIUI forum who ended up bricking their devices or damaging their motherboards while trying to repartition).
Then how do these partition apps work?
Click to expand...
Click to collapse
Member this is for the Junior and or new Members of XDA. You have been around long enough to know where to look or ask your questions.
Thread Closed.

A Simple Way to (kind of) Dual Boot an Android

This is just an idea. I tried it on my Nokia 6.1 (2018) (PL2) running Android 10, and it worked; so I thought it might work on other devices too. My device:
Android 10 Q
System-as-root
A/B slots
Released with Project Treble support (and hence has the fstab in the vendor partition)
DM-verity, force-encryption and disk quota disabled with this mod by Zackptg5.
It basically uses a single partition to store the contents of what I call two different userdata "profiles". Normally, you have one userdata partition on a device, and that stores one profile. Here, however, I used a subdirectory on the root of the userdata partition to store the contents of the second profile, and modified the fstab to correctly bind-mount it on /data. Bind-mounting made things simple in my opinion--I didn't have to go about actually repartitioning my storage. The reason this works is that any changes you make to your phone on the lines of installing and updating apps, downloading files, changing settings, etc. are all reflected only on the userdata partition. No other partition on an android phone is ever touched unless the system is updated. Hence, the userdata partition is the only partition you need to mess around with in order to have two profiles.
===================================​DISCLAIMER:
I am NOT sharing a solution. I am only sharing an idea for you to try and/or improvise on. It may work, it may not. I will not hold your hand; you will have to use your own knowledge and common sense. I am not responsible for anything that goes wrong on your device.
If you do not understand what is going on in this post, please do not try this.
There is a reason I'm not explaining all the terms I'm using here. I assume that if you, the reader, want to try this out, you a) have some knowledge and experience, and b) have the fire in your belly to research to learn more about what you don't understand.
===================================​
Now for the fun:
The first thing I did was to create a new mountpoint the userdata partition. This I made on what is the root filesystem of the device; on a system-as-root device, it would be on the root of the system partition, and on a non-system-as-root device, it would be on the root of the boot ramdisk. I named it userdata/. Accordingly, I edited my fstab.qcom (at etc/fstab.qcom on the vendor partition for my device) to mount the userdata partition on /userdata/ instead of /data/:
Code:
#<device> <mountpoint> <type> <options>
/dev/block/bootdevice/by-name/userdata /userdata <whatever whatever whatever> <you'd probably have to disable options like fileencryption, quota, check (verification), etc.>
and to mount the second profile's directory. Note that it is bind-mounted:
Code:
/userdata/userdata/ /data none bind
Now to switch between the two profiles, you'd switch between the original fstab and the one you just modified.
That is (most of) it. Some things I noticed:
The device would refuse to boot initially. What worked was to backup and wipe my data, boot, create the second profile's directory and copy the contents of the just-created userdata profile into the second profile's directory. In other words, I couldn't run a "first boot" on the second data profile--I had to copy an existing profile into the second profile. I really don't know why this happens.
I suspect that disk quota, filesystem encryption and verification will mess with this (or rather, the other way around). I can't be sure, because I have all three disabled.
Having a shared Internal Storage (/data/media/0/) is convenient. For this, I just bind-mounted that too:
Code:
/userdata/media/0/ /data/media/0/ none bind
This can also be used to easily achieve dual booting on an A/B device, as long as you don't use seamless updates. One ROM per slot can be installed, and the fstab.qcom on one of the vendor partitions can be configured to use the second profile. This way, there would be no need for an external SD card or additional partitions.
I'm pretty sure there will be other hurdles with other devices and other android versions. As I said, I'm just here to share an IDEA, and NOT a foolproof, one-size-fits-all solution. I hope this helps other people make their lives simpler. Please do share your notes on this thread if you manage to get it working on your device!
Its easy to have two roms on one device and its simple,just take a nandroid aof your current rum,now flash another rom an set it up,when u need the other rom just restore your nandroid and so on,i have 4 roms,all fine,lol.
But that's kinda inefficient, don't you think? If you just swap a single file instead of the whole data partition, it's much faster--it takes as long as rebooting + a few milliseconds.
But well, whatever suits you
Hey bro can u pls explain the second code line u mentioned???
varunrocks17 said:
Hey bro can u pls explain the second code line u mentioned???
Click to expand...
Click to collapse
/userdata/userdata/ /data none bind: (this is the line right?)
This bind-mounts the directory /userdata/userdata on /data. /userdata/userdata (directory /userdata under the userdata partition that we previously mounted) is the directory under which the contents of the alternative userdata partition are stored.
Bind-mounting is a means by which a folder can be treated as a device to mount (as opposed to a normal block device or partition). As the mount(8) documentation states, it is a way to "Remount part of the file hierarchy somewhere else."
By this mechanism, the /userdata/userdata folder is made to look like the entire userdata partition. In other words, when you access anything under /data/, you're in fact accessing /userdata/userdata/.
I did something similar to a Jellybean. That is, quite long time ago. Stock fw didn't support encryption. So I made a hack that used cryptsetup and vold.decrypt triggers. That way only framework had to restart. It probably is not that simple anymore...
Anyways, what I learned that it wasn't worth it, so I didn't release it back then. Back then there was a real space shortage and it wasn't wasted like nowadays....
Thanks for that userdata idea that's what I was messing around and. Creating multiple partitions for each rom ...
Btw one question :
Kernel intially mounts vendor then from vendor/etc/fstab.qcom all others are mounted ..?
Or kernel have the predefined vendor system and userdata partition locations ..??
I am really confused here ..
That's why my multi boot was bit messy..
aryankaran said:
Thanks for that userdata idea that's what I was messing around and. Creating multiple partitions for each rom ...
Click to expand...
Click to collapse
Glad I could help
aryankaran said:
Kernel intially mounts vendor then from vendor/etc/fstab.qcom all others are mounted ..?
Or kernel have the predefined vendor system and userdata partition locations ..??
Click to expand...
Click to collapse
On my system-as-root device treble-enabled device, the vendor partition is mounted by the kernel. There is a node in the kernel's device tree blob (dtb) that specifies the vendor mount. When the kernel is fully initialized, it has its own /dev filesystem, using which it mounts the vendor partition. I hope that part is clear.... not sure if I explained it nicely...
Once the vendor is mounted, /vendor/etc/fstab.qcom is read and all the other partitions are mounted from there.
Ok it means it's just the same scenario as it was till Android 7.1.2 that boot image mounts all partitions..
Just difference that kernel now mounts vendor and further processed by fstab ..

Categories

Resources