I have a micro SD card adopted by an Android phone as internal storage extension. While being adopted it was partitioned/formatted by the phone with two ext4 partitions: android_meta and android_expand, which is easily decryptable in a Linux laptop using the key under /data/misc/vold. I'd like to free up some space on the card for an "external" aka "portable" partition for music storage etc, ideally using that Linux laptop: the idea is to shrink android_expand somehow. How do I do that? E.g. GParted won't let me do it - if that's just 'cos it's encrypted can I perhaps decrypt it, write it back onto the card, move/resize it as necessary using GParted or the like and then encrypt and write it back again? Thanks in advance!
Asked
Active
Viewed 325 times
1
-
Your question here has two issues... One is that the phone will not recognize two partitions on the SD card (one encrypted and one "external") it just won't work in a normal phone (you might be able to do some root access trickery, but I can't guarantee it). Your best bet is likely going to be to insert it into the phone, copy off all the data, then "forget" that SD card and reformat it as external storage. – acejavelin May 15 '23 at 18:00
-
@acejavelin that'd deprive me of the internal storage expansion though, right? I need them both. If my phone (a Samsung A3 2017) natively supported Adoptable Storage feature perhaps I'd be able to dual partition my card with "sm" and have the phone adopt one of them (exactly that worked for lots of phones with MM 6 and Nougat 7), but seems like Samsung decided to mask that feature and the only patch unmasking it that I know kills sm and the phone partitions entire card as adoptable. – dandreye May 15 '23 at 18:07
-
1Dual partitioning thread: https://forum.xda-developers.com/t/tool-utility-win-linux-auto-formatting-sdcard-to-internal-and-sdcard-storage.3583875 – dandreye May 15 '23 at 18:13
-
The point it is that to my knowledge you cannot resize a partition encrypted in this manner. – acejavelin May 15 '23 at 18:38
-
Can I maybe manually create a similar but smaller one (instead of existing autocreated one) and make it look same to the phone, so that it doesn't notice the change? – dandreye May 15 '23 at 18:46
-
You could try to create an "empty" partition of the size in want and see if the phone will just handle it, but those older Samsungs are not great dealing with encrypted (adopted storage) volumes. – acejavelin May 15 '23 at 20:54
-
I tried a few variants of that earlier and it looks like the "New SD card inserted" dialog offering to choose between Internal or Portable totally disregards whatever's on the card and just repartitions it from scratch with entire space allocated to a single partition of my choice. Wrt Encryption, I wasn't expecting it to get encrypted at all as the Adoptable Storage patch I'm using is supposed to disable it, but it still seems to get encrypted somehow. Interestingly it's perfectly accessible in TWRP despite encryption, and only needs decrypting when plugged into a different device. – dandreye May 15 '23 at 21:18
-
One more idea: what if I use a smaller card at first, and then use some cloning SW like CloneZilla that can migrate the internal partition(s) created on it on to a bigger one w/o analysing them and so disregarding their encryption? I'll then want it to clone android_meta and android_expand into the upper part of the target card as Windows likes its FAT partition to go first. – dandreye May 15 '23 at 21:20
1 Answers
0
Android 6.0 Adoptable Storage is FDE encrypted
Android 7.0-8.1 does not support Adoptable Storage for FBE encrypted devices
Android 9+ Adoptable Storage is FDE and/or FBE encrypted
this for FDE encrypted Adoptable storage only
you can partition mixed from sm
Split external SD card partially into adoptable storage and portable storage
to backup files use gnu tar
with selinux flag
Can't access my phone memory suddenly after using SD card as internal memory

alecxs
- 4,034
- 3
- 16
- 34
-
thanks so much: that really helps explain my issues around it with Android 8. Will it be any different if I turn that encryption off? The patch unmasking Adoptable Storage feature in my phone was supposed to turn it off but it doesn't seem to be able to do it as encryption is there. – dandreye May 16 '23 at 08:19
-
I don't have any there: they're all under / (this is SM-A320FL) and neither of them has such parameter. The patch I'm using appends ",encryptable=userdata" behind any occurence of "voldmanaged=sdcard:auto" it comes across, which I understand is mandatory for the card to be considered an Adoptable Storage candidate (and not for its immediate encryption during adoption) based on this: https://source.android.com/docs/core/storage/config#adoptable_storage – dandreye May 16 '23 at 10:07
-
SM-A320FL is FDE regardless of the android version, so no need to disable encryption – alecxs May 16 '23 at 11:52
-
But when I plug the card into Linux it won't open unless I decrypt it using dmcrypto and the key under /data/misc/vold. Meanwhile TWRP opens it just fine somehow... – dandreye May 16 '23 at 12:13
-
TWRP does the same as you manually do in linux, it decrypted adoptable storage with /data/misc/vold so no need to disable encryption at all – alecxs May 16 '23 at 13:38
-
Aha clear now (and thank you for explaining that /data is encrypted by Samsung encryption, hence differently). Now back to the point: you advise using sm to create a mixed partition card. My experience with sm so far: SM-A320FL running 8 does nothing upon entering "sm partition..." - it just returns the prompt in <1s and there are no changes whatsoever on the card (btw same on SM-A310F running 7). I only got it working properly on SM-G965F running 10 so far and even that one crashes at the end of the process albeit producing a seemingly well partitioned card. Stock ROM implied. – dandreye May 16 '23 at 18:00
-
Meanwhile my sm seems to get broken by the famous Adoptable Storage patch once I flash it: sm starts returning Killed on whatever options I try running it with. But even if it survived the patch it would've likely behaved same as w/o the patch anyway. That's what made me research cloning the card to a bigger one in that separate thread, which doesn't see to work either... – dandreye May 16 '23 at 18:05
-
your question suggest that adoptable storage is supported. if you can use
private
it should work formixed
too, but I have no experience – alecxs May 16 '23 at 18:05 -
Adoptable Storage is supported indeed (purely due to the patch) and it's capable of partitioning entire card as adoptable (I guess that's what private is), but sadly not mixed... I'm unsure it even uses sm for its partitioning functionality. – dandreye May 16 '23 at 18:07
-
if you don't rely in encryption use Link2SD instead. instead of 2nd partition it's possible to loop mount a file into /data/sdext2 – alecxs May 16 '23 at 18:13
-