Wednesday, 10 February 2016

Android 6 semi-adopted storage

How to split your SD card between adopted internal storage and portable external storage.

(see how-to instructions below)

The pain


Fed up of waiting on Motorola for the Marshmallow upgrade on my XT1072, and being short of internal storage, and being very fed up of having to move-to-sd apps after upgrade (along with occasional tricks such as deleting all data for drive, google+, chrome to scavenge extra memory when clear-cache wasn't enough) I decided to upgrade to CyanogenMod 13 to get Marshmallow that way.

I was really looking forward to being able to use my SD card as internal memory and have no more problems about storage.

What really happens is that with Marshmallow you cannot move-to-sd without adopting your SD card as internal. And then the only apps that will move-to-sd (now called Change) are those that could already move-to-sd.

And one of those apps that won't move-to-sd (even after the adoption of the SD card as internal storage) is Google Music.

Only now there is no SD card for Google Music to store the music on. So it stores it on the *internal* memory.

Whaaaat! My music collection is way bigger than my app collection, how does storing my music internally instead of some apps (all of which could move to SD anyway) help anything?

After messing abuot with Links2SD, Apps2SD, root shells and mount points, reading about volume manager and changing API's I decided that even loopback file fat32 systems in the adopted storage probably wouldn't work.

So I looked at re-partitioning an adopted storage card to shrink the adopted partition to make room for a fat32 partition.

In searching how to access the encrypted partition outside of Android (so that I could resize the file system within it) I came across these notes https://nelenkov.blogspot.co.uk/2015/06/decrypting-android-m-adopted-storage.html?view=flipcard I came across the sm command which can create a mixed or public or private volume.

Mixed turned out to be exactly what I was looking for!



How to split your card

WARNING: Before you do this, be sure to eject the card from the Settings/Storage & USB menu.

WARNING: Regardless of whether you split your card, or just adopt as encrypted, or even just re-format as FAT, it may not be good for the life of your card. It seems that some SD cards have long-life flash allocated to the first few blocks where the FAT is kept. Using a non-FAT file system, or having the FAT file system further down the device loses that benefit, possibly even altering the pre-shipped format could do that too. [http://events.linuxfoundation.org/sites/events/files/slides/fs-for-embedded-full_0.pdf]

I found how to partition my SD card to give 8G as internal storage to which all apps that can be moved will be moved and leave ~20GB as portable storage to hold music, etc.

First, you need adb working, and your SD card inserted and formatted as portable.

$ adb shell sm list-disks adoptable
disk:179,64

disk:179,64 is my SD card that can be made adoptable, I want 90% as external SD:

$ adb shell sm partition disk:179,64 mixed 90

Note: Your card may be listed with an underscore _ instead of a comma, e.g. disk:179_64 in which case, that is what you type.

This erases the entire SD card, and then gives me 90% as portable storage and the rest as adopted internal storage.

The partition table looks like this:
Number  Start   End     Size    File system  Name            Flags
 1      1049kB  57.5GB  57.5GB  fat32        shared          msftdata
 2      57.5GB  57.5GB  16.8MB               android_meta
 3      57.5GB  63.9GB  6369MB               android_expand


The fat32 partition is not encrypted and can be mounted on a computer (provided it can handle the new GUID partition table format).

I advise a reboot after setting the new music storage location this as Google Music may get the wrong idea about much space is available.

Rename the adopted storage. If it had the same name as the portable storage partition then it may prevent one of the partitions from being available over USB MTP.

For reasons I don't understand, my disk label gets set as some junk similar to this: 82^GM-^KM-^?N-q^Xa^Oo and although I can change this by inserting it into a computer: mlabel -i /dev/sdf1 :: if I put it back into my phone, it looks right until I soft-eject and re-insert it (from the menu) - and then the weird label is back.

I wonder if this can be avoided by swipe-dismissing the notice that a new SD card is discovered (which shows after the mixed partition is complete) instead of selecting it.

If you want apps to be installed on the adopted SD partition by default, then you need to choose the Migrate Data option from the menu:



For CM13 this seems to work as an alternative to my original suggestion below which required the phone to be rooted, but for stock it seems ineffective.


# You won't need this if you chose migrate data above
$ adb root pm set-install-location 2

to have apps installed on the storage by default where possible. It is very effective. (Location 1 means internal, and 0 means auto-choose, but I don't know on what criteria).

However that command requires you to have rooted your phone. I wish this could be set another way.

(If you want to root your XT1072, follow the top-post instructions here: http://forum.xda-developers.com/moto-g-lte/general/root-marshmallow-stock-rom-t3317859)

This lets you use USB devices as adopted/portable (if you are rooted):
$ adb shell sm set-force-adoptable true

144 comments:

  1. I tried that with a 128GB Sd on my lg Stylo, android 6 and the private volume keeps coming back as unmountable

    ReplyDelete
    Replies
    1. Does it work for you if you just use the UI to make it all-private? or if you execute:
      adb shell sm partition disk:179_64 private

      I'm wondering if "mixed" is causing your problem, or using a the"sm" command

      Delete
    2. When i try "mixed" my device shows the internal part as "Corrupted" and only the external part works... how could i fix that ?

      Delete
    3. the same for me i try with private 75

      Delete
    4. I'm trying to have this working too, SD 128Go everything seems to script correctly via the adb terminal but the result is always the same -> corrupted SD.

      Looking to find a solution as well. Thanks for this though, very usefull.

      Delete
    5. For anyone that is getting the corrupted error on their SD card when creating a mixed partition. Here is the solution.

      After you have partitioned the disk and while your SD card is corruped enter In the terminal the following:
      $> adb shell sm list-volumes all

      Which will list your volumes, for example:
      private mounted null
      public:179,1 mounted B5B1-140C
      private:179,3 unmountable null
      emulated mounted null

      Then enter the following replacing 179,3 with whichever disk numbers you are given:
      $> adb shell sm format private:179,3
      $> adb shell sm mount private:179,3

      Now your SD card in device storage should be properly mounted and your portable storage will still be there.

      This worked on my LG G5 and should work on the S7.

      Delete
    6. For anyone that is getting the corrupted error on their SD card when creating a mixed partition. Here is the solution.

      After you have partitioned the disk and while your SD card is corruped enter In the terminal the following:
      $> adb shell sm list-volumes all

      Which will list your volumes, for example:
      private mounted null
      public:179,1 mounted B5B1-140C
      private:179,3 unmountable null
      emulated mounted null

      Then enter the following replacing 179,3 with whichever disk numbers you are given:
      $> adb shell sm format private:179,3
      $> adb shell sm mount private:179,3

      Now your SD card in device storage should be properly mounted and your portable storage will still be there.

      This worked on my LG G5 and should work on the S7.

      Delete
    7. It does not work on Samsung Galaxy Tab S 8.4 IronRom 3.2 (MM 6.01) with adoptable patch installed. When trying to mount, it will continuously report:

      Error: java.lang.IllegalStateException: command 'X volume mount private:XXX 0 -1' failed with '400 X Command failed'

      where X is the number of the command (for that particular session) and XXX the "name of the disk".

      I noticed that "sm list-volumes all" shows the new private partition as unmountable, but with a name or whatever is the thing after:

      private:XXX unmountable (N:number, l:letter)

      I don't know what could be the problem...

      Delete
  2. Is there a more in depth guide to this (being a first timer when it comes to editing sd cards) or is it as simple as the above?

    ReplyDelete
    Replies
    1. If you have ADB working then it is as simple as that. But it will wipe any existing data on the card

      Delete
  3. Dear Sam, Thank you!!!
    It worked like a charm and I'm very happy I came here to read, after days spent googling for this issue!
    My problem was Plex for Android, same issue than Music for you.

    I have now a couple of little issues:

    1) Being a MacUser, I read my storage with Android File Transfer, that not recognizes the adopted part of the SD. Do you have any idea on how to solve this?

    2) The command "adb shell pm set-install-location 2" gives an error as result: "java.lang.SecurityException: Package android does not belong to 2000" and I have no idea on what it means and how to solve it!

    Well, this issues apart, this trick is gorgeous! Thanks again.

    ReplyDelete
    Replies
    1. I'm glad it worked well for you.

      1) Windows/Linux MTP recognizes the adopted storage and SD portion (but no longer the internal portion). Perhaps your Android File Transfer only recognizes the first MTP storage location? You may need to bring this up with the developers of Android File Storage.

      2) I think that may mean that you need to root your phone by installing super-su from recovery. Perhaps this link will help. http://forum.xda-developers.com/moto-g-lte/general/rooting-moto-g-2015-lte-xt1078-t3086069

      Delete
    2. 2) Fixed! My phone is rooted, bootloader unlocked and a third party custom ROM is installed. The root it wants is the ADB root. And it's simple: just writing "adb root" and then the command. So easy. Anyway, remember, this was necessary on a Mac. It can be useful for other mac users if you mention it in your blogpost.
      Thanks again.

      Delete
    3. Bigo72:
      1) Whichever internal storage it shows via MTP in your Android File Transfer seems to be the one set with the "Migrate Data" menu option of the internal storages. So if you click on the "Internal Storage" and choose "migrate data" from the menu, then that is the internal storage shown over USB MTP.

      That also affects the default installation location even though "pm get-install-location" returns 0[auto]

      Delete
    4. Sam, you are great! Thank you very much!!! It works. Fantastic.

      Delete
  4. WARNING: Before you do this, be sure to eject the card from the Settings/Storage & USB menu.

    ReplyDelete
  5. Rename the adopted storage. If it had the same name as the portable storage partition then it may prevent one of the partitions from being available over USB.

    ReplyDelete
    Replies
    1. Can we have 3 drives over USB MTP.
      We have to sacrifice either adopted or real internal storage for accessibility over USB MTP.

      Delete
  6. If I do this( LG G2 mini unlocked bootloader,root, running cyanogenmod 13) with a sd card,and then i insert another sd card in my phone(let's say a bigger one) will my internal storage stay the same? Or will i get bootloop from too little space in internal?

    ReplyDelete
    Replies
    1. No, nothing happens, you just loose everything was on the SD, which is not system, just apps and their files.

      Delete
  7. This is really interesting, i have been searching this recently. I just upgraded from lollipop on a Zenfone Selfie with CM13. What are the differences between doing this and using Link2SD ? I just want to get the best out of my SD Card, i have a 64gb class 10 uhs-1 ADATA and be able to run apps fully on my SD Card just as Link2SD is able to, so should i try this ? Thanks for the info

    ReplyDelete
  8. THANK YOU SO MUCH FOR THIS, MAN! Now I can use my SD to its FULLEST without worrying with my shitty 1,5gb of phone internal storage.

    ReplyDelete
  9. Hi Sam! I tried the CM13 snapshot on my S4 mini this weekend and decided to use my SD card (all of it) as internal storage. To my surprise the built-in file explorer only has access to the 8 GB internal flash (under /storage/emulated/0) but no access to the 64 GB SD card. I can see under Settings - Storage & USB that Android is storing application data on my SD card but it seems that Android will not let the user see those files and/or let the user put own files on the SD card. Can you confirm that /storage/emulated/0 is the built-in phone memory? Do you now any user accessible mount point for a SD card used as internal storage?

    ReplyDelete
    Replies
    1. Have you got its solution? Please share it, if you have got solution now.

      Delete
  10. Thank you, I've been searching for this too.
    I'm just wondering what impact has the adopted partition on nandroid backups ?
    Will backups run transparently or the recovery will see another partition that we will have to include in the backup ?

    ReplyDelete
    Replies
    1. Please, reply here, if you have got the answer to your question.

      Delete
  11. Sam, thank you for this tutorial. I have a question, if I did this method successfully and then decided to go to a bigger card (32gb to 64gb), how would I do it? Can I copy data over to the new card? What would be the process? Thanks.

    ReplyDelete
    Replies
    1. You can backup the data over USB to your PC, then put in the new card and set it up, then restore the data over USB

      Delete
    2. Worked great, Sam. Thanks again.

      Since I split the card internal Adoptable and External, is the card still encrypted?

      Delete
    3. The Adopted part is still encrypted, the other portable storage part can be accesses in other devices.

      Delete
  12. "set-install-location 2" and "Migrate data" are not the same.
    "Migrate data" moves media (photos, videos, apks, ...)
    "set-install-location 2" will probably set the default install location to partition internal

    ReplyDelete
    Replies
    1. They are not the same, but it seems to me that they both have the effect that I was after of making apps install onto the (adopted) SD partition.

      However I am not sure that it always works though, I wish I could "set-install-location 2" without rooting.

      Delete
    2. "set-install-location 2" will probably set the default install location to partition internal.

      By partition internal, do you mean: adopted storage?

      After executing "migrate data" and "set-install-location 2", I cannot see the "Change" option in Settings>>Apps>>"Say any game or user app". It shows every app is installed in internal storage.

      Does "set-install-location 2" has any effect on "Change"?

      Delete
  13. Thanks...works good...thank you.

    ReplyDelete
  14. Brilliant; thanks a ton, as this solved an enormous problem for me. My Shield tablet's 16gb of internal storage was ultimately inadequate for a gaming machine, but formatting an SD card for internal storage made for incredibly slow file transfers via USB and I had an issue with folders showing twice when connected to a PC. With a UHS-3 128gb card, I was able to nearly triple my internal storage and still retain the ability to stick the card into a fast reader and get very quick file transfers.

    I should note that Windows and ES File Explorer no longer seem to recognize the "normal" internal storage. However, Android's File Explorer does show Internal, adopted and SD storage, so I can tell it worked correctly.

    One question, though: when you suggest renaming the adopted storage, do you mean from the Windows File Explorer? I don't think it's necessary for me, as the names don't match, but I'd like to be sure.

    ReplyDelete
    Replies
    1. I don't mean from windows file explorer, from Android. It is only needed if they both have the same name

      Delete
  15. Hi, I adopted a 64gb card splitting 20 gb for apps and 40 to fat32.
    Now I changed rom and system not mounted adopted storage. I can see the partition using various partition tools under Android. But can't mount disk by the terminal (partition not listed).
    What can I do?

    ReplyDelete
    Replies
    1. Same here.
      My workaround: format SD card as portable in android or using Easeus Partition Wizard on computer, then follow the same procedure above.

      Delete
  16. Hi, I adopted a 64gb card splitting 20 gb for apps and 40 to fat32.
    Now I changed rom and system not mounted adopted storage. I can see the partition using various partition tools under Android. But can't mount disk by the terminal (partition not listed).
    What can I do?

    ReplyDelete
    Replies
    1. Repeat the process and lose everything on your card. :-(

      Delete
    2. You should have backed up the encryption key (/data/misc/vold )
      Once you restore those keys the adapted storage gets recognized automatically by android (has not been tested switching devices)

      Delete
  17. Hi, I was successful in splitting 64GB card on rooted XT1068 (Moto G 2014 2nd Gen). many thanks for the instructions.

    however when i try to do the same on non-rooted XT1541 (Moto G 2015 3rd gen) the "sm partition disk mixed" command hangs. if I interrupt and then disconnect and reboot the phone it comes up with adopted partition "corrupt" and portable one with a a set of weird characters in the partition name.

    does the phone need to be rooted for this procedure? is there a way to make it work on Moto G 2015 (3rd gen) ?

    Thanks!

    ReplyDelete
    Replies
    1. Were you sure to eject the card first?

      Delete
    2. Yes, the card was elected. I tried a couple of times, same result.

      Delete
  18. Would this be possible in Lollipop?

    I am waiting for Marshmallow update but amazon video wont let me pin to the sd card

    ReplyDelete
  19. Just a heads up, if you are rooted, you can grab any of the terminal programs from the play store and type the commands in on your phone -- no need to use adb. You do need to su to root first. Not sure why you don't have to be root if doing it from adb, but you do if you are using terminal. Anyhow, thanks for the article! The version of TWRP that is available for my phone doesn't understand adoptable storage, so this was a life saver.

    ReplyDelete
  20. Everytime an app on Adoptable Storage gets updated, its moves back to the Internal Storage, it's truly annoying.

    Also, everytime I restart my phone, the icons of all apps in Adopted Storage are gone from my home screen and I have to re-add them. Annoying as hell. Anyway to fix these two issues?

    ReplyDelete
    Replies
    1. You are right. My first tests were with cyanogenmod13 and I know they have a fix for the first problem

      Delete
    2. What would that fix be? :P

      Delete
    3. It is a fix so that if an app is updated, the updated app will be stored in the same location, instead of being moved back to internal.

      Delete
    4. Is this a fix to apply separately, if so where might I find it? Or is it a fix that would be in their recent roms?

      And how would I determine if "the fix is in"?

      Delete
    5. So whatabout this fix? Where is it? from CM or what??

      Delete
  21. but sam , i have an issue , a little
    now after moving an app to my adoptable storage , the app is lagging and not performing smoothly , could that be due to the card's speed , i have a Kingston class 6 , should i have class 10 or something to be faster and act like the internal storage ?
    thanks a lot for this tutorial btw , you are a life saver

    ReplyDelete
    Replies
    1. Yes, a slow memory card will cause this. It takes me longer to take each photo now.

      Delete
  22. thanks a lot, worked fine; s5 klte running cyanogenmod 13, 14-05-2016

    ReplyDelete
  23. Hey Sam, I'm trying to decide if internal of any mix is good for my purposes.

    Where I get my mind in knots is the scenario for the camera with my 32gb Moto X Pure and a 64gb uhs-I card where I adopt any amount of the 64gb.

    Apps like the Moto Camera (like Play music) can choose where to capture their stuff - internal or externalSD.

    But if I have adopted say 8gb of the SD, now the "internal" setting for the camera means that pictures will actually be stored exclusively either on the adopted 8gb or the externalsd proper. I believe I never again get to save images or videos into the phone's own 32gb storage.

    This seems like a waste of space and speed, doesn't it?

    ReplyDelete
    Replies
    1. If you have 32 GB internal storage, then forget this. Simply partition your whole SD card as portable.

      Delete
  24. ugh, typo-ed myself:

    For "now the "internal" setting for the camera means that pictures will actually be stored exclusively either on the adopted 8gb or the externalsd proper."

    Should be: "now the "internal" setting for the camera means that pictures will actually be stored exclusively on the adopted 8gb, and the "external" setting would store exclusively on the externalsd.

    ReplyDelete
    Replies
    1. Some apps store data in the same location that they are stored in which may be adopted SD or internal.
      Other apps will also store data in whichever of internal/adopted to chose to "migrate data" to.
      Yet other apps will also store data on the FAT32 SD card.

      If you want your camera to store data on the internal storage, then I think you need to "migrate data" back to internal storage. At 32G you have enough to do that.

      In my case I have 8G, with ~4G for my use, so I am running out of internal storage, hence the research behind the solution here.

      Delete
  25. This seemed to work really great! Thank you so much for the very helpful tutorial! Marshmallow should really just include this option for people by default, rather than requiring it to be all or nothing.

    However, it seems that many apps are still wanting to install to the actual internal storage, and only some of them (less than I would expect, and certainly less than I could do in the past with Link2SD - before upgrading to Marshmallow) are going to my adopted internal storage portion. I can't seem to find any way to move apps from one to the other either. Any ideas?

    ReplyDelete
    Replies
    1. Nope, no idea... move the apps that will and curse the apps that don't. Configure apps that can (like Play Music or Plex or Camera) to store on the SD card.

      My next phone will have 32GB or more.

      Delete
  26. Hi Sam, you are fantastic! Tank you!
    I noticed a thing, some apps like titanium or snap camera don't allow to write in external sd, titanium says no space, snap says mount usb storage.
    Probably the phone read the external storage under /storage/emulated/0, is there a way to change the mount location?

    ReplyDelete
    Replies
    1. Nope. Contact the authors and ask for an android 5/6 version.

      Delete
  27. Hi, firstly thanks worked great, stupid question though, how do I undo this? After completing this process I found out the phone I bought was for the wrong region and need to return it, so I want to get back my 32gb of regular memory on my sd card, any ideas?

    ReplyDelete
    Replies
    1. Yeah, just repartition it as normal. On your phone, something like:

      adb shell sm partition disk:179,64 public

      Or just repartition it from windows or whichever way you like best

      Delete
  28. Hi Sam, thank you for your guide.
    This worked well for me, except one thing, restoring the backup.
    I am using CM13, I did full backup with adb backup -all -apk -shared -f mybackup.ab. The file is around 6 GB. I have inserted a new micro sd card into my phone and made it adoptable the same way I did the first time. When I run adb restore mybackup.ab and confirm to restore, my phone reboots right away and I only have my wallpaper restored. Could anyone help me on this?

    ReplyDelete
  29. Hi Sam Liddicott, thanks for nice tutorial. I need your help and advice. I'm running unofficial version of cm13 rom on my years old device lenovo a706 which has only 900mb internal storage for app installation. I wanted to try tutorial explained by you but the problem in my case is there is no option for ejecting external sd card in my device running unofficial version of cm. So please help me how do i preceed with this tutorial.
    Thanks in advance...

    ReplyDelete
    Replies
    1. proceed as best you can..., wait at least 10 seconds at the point that you would have ejected and reboot as soon as possible after making the changes.

      Delete
  30. Hi Sam, My Moto g3 mobile is not accepting the sd card and while formatting it is giving an error : "command '13 volume partition disk:179,64 public' failed with '400 13 Command failed"
    Is there any solution to this problem?

    ReplyDelete
    Replies
    1. You are typing the command wrong. 13 is not part of the command.
      It should be something like:

      adb shell sm partition disk:179,64 mixed 90

      Delete
    2. I have the same problem (Error: java.lang.IllegalStateException: command '23 volume partition disk:179_64 mixed 90' failed with '400 23 Command failed'). The "23" was not part of the command I entered, and I tried several times, the number in question just keeps on changing. I've uploaded a screenshot ( https://drive.google.com/open?id=0B-fOkxwop6V8a3VkY3QxeGVrZzQ ), since I don't know what to do about it; I am rooted (CM13 on Moto G 2015, with root turned on for apps and ADB in dev options) and other root apps (eg. Titanium Backup) work normally, and I've tried the exact same command with the USB connection set variously to "charge only" and "file transfer" mode, but still the same. Any ideas?

      Delete
    3. Followup: I did a clean wipe and reflashed CM13 completely, still the same ( https://drive.google.com/open?id=0B-fOkxwop6V8TXlndWV0bWpleEU ). I'm out of ideas right now…

      Delete
  31. I can't express in words how much this post just made my day. ::virtual hug:: Seriously though, thank you so much for writing this up - worked flawlessly on my GS5 running a CM13 nightly.

    ReplyDelete
  32. Dude, thank you so much. My issue was with my sons Moto G (2015) and Spotify, if he downloaded all his playlists for offline it would be 10GB. He couldn't do it and have all the apps installed he wanted. It was one or other, external SD or adopted.
    If I could buy you a Guinness, I would!

    ReplyDelete
  33. Worked for me. But most icons of apps in Adopted storage disappear in my home screens. Apps still working.

    ReplyDelete
    Replies
    1. Just add them back to your home screen.

      Delete
  34. This comment has been removed by the author.

    ReplyDelete
  35. Thank you so much for this article.

    Is it possible to cherry-pick which apps get stored into internal and which ones go to adopted SD partition?

    ReplyDelete
  36. Thank you so much for this article.

    Is it possible to cherry-pick which apps get stored into internal and which ones go to adopted SD partition?

    ReplyDelete
    Replies
    1. Never mind, I just found the option to move apps manually inside storage & usb, it seems to work like in kit kat

      Delete
    2. By going to settings>>Apps>>AppName ?
      I couldn't find the change option in my phone.

      Delete
  37. Hi Sam! Thank you for this article.
    I have question about it: after choosing "Migrate Data" on my Huawei Honor4C I found that free memory of Internal storage is 0.00 B.
    Is it normal, or how I can fix it ?
    Screenshot - http://puu.sh/qojNd/5375bfd78b.png

    ReplyDelete
    Replies
    1. I never heard of that before. Did you reboot it after the partition before using it? Maybe that would help. Otherwise I don't know.

      Delete
  38. You're amazing man! Thank you so much Sam! Have been looking for a solution or an alternative to link2sd for while and nothing seemed to work but this worked like a charm..

    ReplyDelete
  39. I am using an Samsung Galaxy on5. I have adb running correctly. no errors.

    i type:

    adb shell (which loads adb)

    sm partition disk:179,32 private

    It comes back with a blank response. I have tried by unmounting the sd card first, having it mounted, rebooting my phone, etc. nothing works. when i type:

    sm list-disks adoptable

    there is none listed but when i type

    sm list-disks

    disk:179,32 comes up

    force adoptable doesn't work either. it always come back blank immediately

    shell@on5ltemtr:/ $ sm partition disk:179,32 private
    shell@on5ltemtr:/ $

    any ideas? thanks!

    ReplyDelete
    Replies
    1. using a samsung evo 64GB sd card

      Delete
    2. If you have no adoptable disks, then you cant make a mixed adoptable disk.

      I don't know why you would not have an adoptable disk if you are using Android 6.

      Delete
    3. I tried using the 64 GB Evo SD i have and also just a crappy 2 GB i have

      sm list-disks adoptable does nothing. just sends back a blank command line

      Maybe it has to do with the Samsung on5. may there is a different punctuation that i am not using correctly?

      Delete
    4. I'm having the same issue with a Samsung Galaxy Tab S. Commands are all accepted fine, but the partition command returns immediately and has no effect. It doesn't even format the card. Nothing. I've tried with the card unmounted or mounted. Doesn't matter. I've tried several different cards. None work. Using sm format works fine so adb is there and talking to the device. Also showing adoptable shows nothing and setting adoptable true seems to have no effect.

      Any help would be greatly appreciated.

      Delete
    5. I'm quite new into this, but I heard that Samsung deactivated this function. Maybe it helps using "sm set-force-adoptable true"?
      Normally the partition command doesn't return anything, right? So in your case it looks like it runs without dropping an error...
      As far as I know, the partitioning command doesn't format the new partitions. This can be achieved with "sm format [volume]".
      I hope I got you right?

      Delete
  40. Hello. I tried this on my phone and it works. The problem is that the Internal part doesn't work, it shows as corrupt, but external works. Also if I format the whole card like internal it still shows corrupt, when I format it as external it works normal. Any help?
    Thanks!

    ReplyDelete
  41. This lets you use USB devices as adopted/portable (if you are rooted):
    $ adb shell sm set-force-adoptable true

    What difference will this make? Before executing this command, we cannot set usb as adoptable. After executing, we can make usb adoptable, is this the difference?

    ReplyDelete
    Replies
    1. After this command, apps will be installed by default to adopted if possible. It saves you from having to move them after installing

      Delete
  42. How can I determine if an app is installed in adopted or internal storage? I've renamed each adopted part of memory card as "Adopted". I see each app as "stored in internal storage" by clicking on App Info.

    ReplyDelete
  43. This comment has been removed by a blog administrator.

    ReplyDelete
  44. Have the note 7 is an tried this commands and nothing happens I guess samsung blocked this??

    ReplyDelete
  45. Tried on Asus Zenfone 2 Laser and it works well. Thanks

    ReplyDelete
  46. Thanks so much, Sam. Worked for my Moto G3. I wasn't able to use adoptive storage with Spotify, and with such a modest internal memory there was very little room for apps without it. Great solution.

    Did take a second attempt. The first time, after rebooting, I was prompted to set up the new SD card, which included reformatting it. This did not have the desired outcome. Second time I ignored that prompt, then went to manually initiate the migration. Moto seems to make a big deal of needing to format memory to use it as adoptive, but that doesn't seem to happen in this procedure.

    Was slightly confused with steps 7 & 8 as listed on Stack Exchange. Take it you are referring to the same thing, but call it different -- SD Card (internal) in one and adopted storage in the other.

    Many thanks.

    ReplyDelete
  47. Hi Sam! I have done a mixed sd card following your (excellent) guide on a Moto E Condor.
    Now the problem is that I don't find a camera app and a gallery app that works with this setup. Any suggestion? What app do you use?

    ReplyDelete
    Replies
    1. My MotoG native camera app has the option to save photos on the SD card. I'm surprised if yours doesn't. Check again carefully.

      I drag a control wheel from the left and scroll the wheel and click on the icon for the SD card.

      Delete
    2. Moto E doesn't have that option but also with other camera apps the problem is that they can't see the SD card anymore after the mixed setup, and they crashes.
      Anyway that smartphone wasn't mine and I decided to format the SD as portable only.
      Thank you.

      Delete
  48. Hi sometimes I've got a problem with my adopted SD card (can't save files on in, can't take any picture, my music library is not visible in Google Music - but I still see all other files and SD card in general in ES File Manager.
    The only solution for that is to make a reboot, but after some time it still happens.

    I've made a 32 GB SD card split via
    "adb shell sm partition disk:179_64 mixed 50"

    When I try to recreate mounting scripts in Link2SD I get an error:
    "mount: '/dev/block/vold/179:66'->'/data/sdext2': No such file or directory"
    WHY it states 176:66 as my card is shown (after adb command "adb shell sm list-disks adoptable") as 179:64

    Can someone help me to set proper mount script or any other solution to use SD card flawlessly?

    ==after command "adb shell sm list-volumes all"== I get sth like that, there is no 179_66 at all.

    private:179_67 mounted 8ff4b0ce-da85-46fa-82f4-599645be5735
    private mounted null
    public:179_65 mounted 399B-14F0
    emulated unmounted null
    emulated:179_67 mounted null

    ReplyDelete
  49. So far so good. I have a 128gb Class 10 SDXC card and have it split 55/45 in favour of portable storage, as I read the adoptable storage should be less than the adoptable. My Galaxy Tab S 10.5 sees both partitions as "SD Card" so I renamed the adoptable partition. My data exported with no problems so, fingers crossed, it should work as planned.

    Thanks for such a straightforward guide. Samsung really dropped the ball with this one.

    ReplyDelete
    Replies
    1. Life On ESA - Any help/pointers on the commands you tried? I tried this with my Galaxy Tab S 10.5... Nothing happened at all. The sm partition command for me does absolutely nothing. I'm not sure what's going on with it. I don't get any errors but it doesn't seem to make any difference. Tried exactly as above. Tried several different memory cards. Nothing. Trying to use a sandisk extreme, but tried several different cards. No luck.

      Delete
    2. Gone Fishin' - Sorry chum I just followed the instructions to the letter and it worked out exactly. One thing I did notice though - when I first connected the tab and ran the "adb shell sm list-disks adoptable" command, it was just returning blank. It was only when I deleted the tab's windows drivers, rebooted and installed again that it actually gave me the disk:179,32 (was what mine was) so I could move on to the next stage. And, as I said, after it ran (leave it to finish, it may seem that it isn't doing anything) both the adoptable and external storage showed as "SD Card", so I had to rename the adoptable partition. Other than that, there's nothing else really to report back.

      Delete
  50. In lolipop my sd card as changed to portable after marshmallow updates my sd card shows unsupported i tried to format but command filure error plz help me to solve this i need step by step process to done it thanks in advance!!!!!!

    ReplyDelete
  51. My charge connector fail in Galaxy S2, but i use adb on network. Great. But for "adb root pm set-install-location 2" don't work, then i enabled terminal and execute "su" and then "pm set-install-location 2". All ok now

    ReplyDelete
    Replies
    1. NOTE: jajaja, all of terminal Cyanogenmod 13...

      Delete
    2. i think what it's possible build apk with this

      Delete
  52. PLease any clear process to revert this? my cm13 rom start to acting weird, my phone could´t resist even 5 min on, so i have to flash emergency... my surprise i can´t use my sd like before, please help, any idea? thanks in advance

    ReplyDelete
    Replies
    1. Format your card in android y voila: revert!

      Delete
  53. Hi...!!!
    Very Good information on this blog can you help me where is Buy 16GB Memory Card

    ReplyDelete
  54. hi, could you make a tutorial video about this? :P still don't know what's adb

    ReplyDelete
    Replies
    1. Android Debug Bridge. It's command line stuff. You have to have ADB enabled in the developer options.

      Delete
  55. This comment has been removed by the author.

    ReplyDelete
  56. Thanks sam! This is really great.

    But i notice that the USB OTG don't work anymore since i done it.

    Does anyone here have any workaround for that problem?

    ReplyDelete
  57. When I enter "adb shell sm partition disk:179_64 mixed 93", it gives me an error: "Error: java.lang.IllegalStateException: command 'xx volume partition disk:179_64 mixed 93' failed with '400 xx Command failed'". xx=any number.

    ReplyDelete
    Replies
    1. Oh, nvm, forgot to eject microSD.

      Delete
  58. Thanks for having this, you answered a question I had. Another question comes to mind: is adopted storage actually encrypted, or is it just a devmapper/LVM partition, or come to think of it, encrypted LVM? TIA

    ReplyDelete
  59. I tried this solution and it does work well, thanks a lot!

    However, I have to warn you that it seems to me the SD card is easily damaged or corrupted if using this way. I have 3 failures already and all of them show exactly the same problem. The card became unreadable on encrypted Android partition, and second partition(eFAT) also became unrecognized in Android, but eFAT part can be read in Windows system(so I can get the data out, that's good). But the card itself becomes "Read-Only" and cannot be formatted at all in Windows system. In Android system, the card became totally invalid and couldn't be detected(so there is no way to format it or do something). I tried a cheap card, then a good Lexar card and a high end Samsung card(all 64G), no difference. After using a while, all of them failed like this.

    My phone is Moto X Pure, original Marshmallow ROM.

    ReplyDelete
    Replies
    1. Yes, I had a similar problem with a Sandisk 64GB card. Worked fine for 3 months.And all of a sudden , poof! Dead card.

      Delete
  60. I really enjoyed reading your article.

    ReplyDelete
  61. by mistake i did a factory reset and didn´t do a backup of the .key file located at /data/misc/vold, now my tablet say that the sd card is not supported, is there a way to get the .key file back? or mounting the sd card to get the file without formatting the sd

    ReplyDelete
  62. Thanks for sharing these great quotes.
    This is a fantastic website, You can also visit on comparemunafa and buy best Latest mobile price list

    ReplyDelete
  63. It's work flawlessly. Thank you very much.

    ReplyDelete
  64. In the present era, the Android operating system is dominating the smartphone industry, as a result more and more businesses are gearing up towards Android Application Development.
    showboxdownloadsapp.com

    ReplyDelete
  65. With all options say my always "error: device not found" and i cannot execute any adb command on muy chuwi hi12...Any help?

    ReplyDelete
  66. hi Sam
    i tried everything you told but in my device HTC one m8 shows my sd card is corrupted and when i use adb command to determined volumes it shows like that

    private:179,35 unmountable null
    private mounted null
    public:179,33 unmountable null
    emulated mounted null

    could you please help me? i really need it becuse my device has 16 Gb internal Storage and it is no enough

    ReplyDelete
  67. how can i rename partitions?

    ReplyDelete
    Replies
    1. Go to adopted sd card and then you have on right up corner three dots, touch on it and you will see "rename" option.

      Delete
  68. Who knows, whether this method works on Nougat 7.1.1? I ask this because, I have made adoptable storage but I can't all apps install on it. For example, Chrome and Whatsapp does not have options for change storage location while Viber has...

    ReplyDelete
  69. Hi and thank yo before,
    I partitioned my sd cars using this commands :
    adb shell
    sm list-disks
    sm set-force-adoptable true
    sm partition disk:179,128 mixed 50
    sm set-force-adoptable false

    and it worked fine, I just did a factory reset because after partitioning, phone once in a while be restarted. after factory reset now I can't see the 40% attached to internal memory befor. Please help

    ReplyDelete
  70. Hi thanks for this it is great! I have only one issue. Now if I try to write TO the sd partition of the sd card (e.g. copy a file from internal memory, or from my pc via wifi) it crashes the explorer or just stops. The file will appear with 0bytes and that´s it. Weirdly, I can delete files and copy FROM the sd partition. I am going to try formatting it but wondered if anyone else has had this issue or knows a workaround? (Vodafone Smart Ultra 6 = ZTE). Otherwise this works a dream!

    ReplyDelete
    Replies
    1. oh and both my internal and external are named as SDCARD and I can´t figure out any way of changing that. Though it doesn´t appear to have caused any issues (unless the aforementioned issue is a consequence!).

      Delete
    2. FURTHER EDIT - I CAN copy from wifi connection to the INTERNAL partition, and then from the internal to the SD, but cannot copy straight to SD. Weird!

      Delete
  71. Nice post http://www.selfcarinsurance.com

    ReplyDelete
  72. hi

    I did everything as explained as this was also exactly the solution I was looking for, however, there is a problem using the partitions. I tried it with a htc One M8.

    The partition succeeded, I typed:

    adb shell sm partition disk:179,32 mixed 60

    Gives me two corrupted sd card entries in the storage menu, one listed under internal storage, one under removable storage. Great, so now I want to set up each partition... and there it goes wrong: when I click set up partition in the storage menu of android, it formats the whole drive as either internal or removable (I have to choose either), no matter from which partition I start the process. Damn, gone partitions. Any solutions? Can I maybe format it from the adb terminal? When I type


    adb shell sm list-volumes all, I get:

    platform-tools>adb shell sm list-volumes all
    private:179,35 unmountable null
    private mounted null
    public:179,33 unmountable null
    emulated mounted null

    ...

    ReplyDelete
  73. Hello. I wrote in my phone that the format is not supported. You do not know what to do with that.
    I have xperia z1. Thank you

    ReplyDelete
  74. It does not work for a htc one M8, it's blocked by htc I'm pretty sure. If you google it, it doesn't seem to work for anyone on that phone.

    ReplyDelete