Showing posts with label android. Show all posts
Showing posts with label android. Show all posts

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

Tuesday, 14 December 2010

I finally got a new phone

I've been using an old HTC TytnII (Kaiser) with Android 2.2 forced into it - but it doesn't quite work right.

I've been holding out for something good with a build in keyboard but they all cost around 400 quid! Forget that!

I finally got an Orange San Francisco (which is really a branded ZTE Blade) on sale at 85.00 with another £14.00 off with my phone fund, so it cost me £70 which is very good.

It also came with a "free" £55 ghastly plastic "LTD brand" watch which must be worth all of 99p - it's like those nice metal citizen watches you used to be able to get, only made out of white plastic.

If I wore my jeans halfway down my thighs, had those weird white shoes that get your feet wet and my hair plastered to my face with grease it would look real nice - only I don't; and if I wear it people will think I'm a refugee.

My phone is now running Modaco's customized ROM - seems to be Android 2.2 although I thought I'd installed the custom 2.1

So what makes the ZTE Blade worth getting?
  1. 1. good hackability (HTC make the best phones but they lock the bootloaders - idiots)
  2. 2. the screen is the same resolution 800x480 as the Dell Streak which was my next favourite.
  3. 3. almost all the features of the £400.00 phones with less than 25% of the price. What's missing? just missing a case - no trouble - £3 on ebay
Warnings

Orange is the only brand in the UK where if you get a fault with something you buy online you can't take it back to a shop - yes, Orange retail is a different company - but they are very helpful.

Took ages and 2 attempts to get my sim registered properly (a necessary pre-cursor to getting a replacement phone).

My £10 credit still hasn't come through, I as chasing that today and got a text saying it could take 5 working days! perhaps they are waiting for an inter-departmental cheque to clear?

And then I need to merge with my old number... or maybe just use up the credit and ask for a new 3G SIM on my old account.



The San Francisco from Orange in grey offers a range of great mobile features such as free Christmas gift on pay-as-you-go, 3-megapixel camera, 3G+, Android v2.1. Available on pay as you go and pay monthly contract from Orange