[Galaxy S II Original Android Development] laptopu:
This is really strange, I'm up and running now but I think there was a period of migration by android system. I'll explain if this helps others what happened to me.

I was running unofficial LOS 14 with non emulated storage on a 1gb system - 6gb data - rest storage with TWRP 3.0.2-1. I went from unofficial to experimental nightly then immediately official nightly at the start of the week. I then saw a thread about the best modems come up, I was on xxLQ6 but I saw there was one for my specific provider 3 UK so I flashed this, no problems. I had no problems before but I thought let's try to see if this will give me any more battery life.

All this was running fine for a day or two so I thought I'd take the plunge to emulated storage. I flashed [MENTION=2222292]rINanDO[/MENTION] emulated TWRP but then I started running into problems because his guide was on an earlier page I thought let's start without migrating. [MENTION=3964850]Weib67[/MENTION] posted a guide that missed the backup and restore steps which I thought wouldn't be a problem as I'm starting from scratch totally wiping my internal storage. No disrespect intended, but this guide is possibly what started screwing with problems to begin with and the only guide that should be followed is [MENTION=2222292]rINanDO[/MENTION]'s guide as a backup and restore is essential to set the correct markers for storage to use the device.

Here's where I'm not quite sure what happened next. I edited the storage.xml file to remove the line referenced earlier in this thread. I was rebooting between system and recovery trying to examine partitions. It wasn't long after I had booted into android (hence part of the reason why I think some system migration goes on, more to come on this bit in a moment) that I then rebooted into recovery and it stuck on the TWRP logo, effectively soft bricking my device. I then found a stock rom online and used Heimdall on Ubuntu to flash this and an original PIT to get me back to stock which worked.

I then found it really quite tricky getting the phone back to a custom recovery as it's surprisingly long ago now that we were talking about other recoveries. Since most people are now on custom recoveries I think it's easy to forget how hard it can be to get custom recovery. I ended up using Heimdall to flash one of [MENTION=4141005]Lanchon[/MENTION]'s ISOREC kernels and I tried flashing TWRP and the kernel but for some reason I couldn't get into recovery, I kept getting the yellow triangle on start. I ended up getting an old Philz recovery and using this and the ISOREC kernel I was able to boot into Philz. I then flashed the emulated TWRP and had my recovery but I couldn't mount internal storage and the repit script wouldn't work as it couldn't access the storage partition.

I ended up flashing a PIT file and selecting repartition on Heimdall to get me to a 1gb system/6gb data partition, back into recovery, wipe to format these partitions, then I was able to install latest Lineage OS nightly (I got it before it was pulled from downloads online). Then I was able to flash the repit file to give me max data min SD card. Again this file is linked earlier in the post but I hadn't noticed it changed = to _ in the filename which caused another problem so I had to manually edit that.

Next I did a backup of non emulated storage which came up as 0MB but when I did the restore and enabled migration you can see from the script why the restore is so important to set the right flags for emulated storage. Then I installed opengapps, enabled root zip, reflashed TWRP as I was getting paranoid at this point, booted into system.

Here's an interesting bit which is part 2 of why I think a migration process happens during android system, and why my post last night about my PC not seeing emulated storage and the camera trying to access the internal 10mb storage partition left on non emulated storage. I tried selecting phone storage on the camera and it was still saving to the 10MB non emulated partition. Then I changed the storage to external SD card and back. It suddenly said I could have about 11,000 photos so I thought yes, I must be on emulated storage now. Then I tried accessing the DCIM folder and it wasn't saving anything to it. Then my camera stopped saving. I'd had a couple of drinks by this point, I was fed up and I went to bed. Here's the next bit though - I left the phone on.

At some point overnight everything obviously settled. Suddenly the storage now reports it's emulated in file manager. My PC sees it as internal shared storage. It survived several reboots. I can boot into recovery or system with no problem. The one last thing I had to do was use triangle away which didn't work within the system as there's no supersu installed, it said it had to reboot into a 'special mode'. I was really nervous about this - was it going to soft brick me again? Would it overwrite TWRP? What it actually did was boot into ODIN and did the work from here. It worked and I got rid of the yellow triangle.

So I'm back up and running. There's all kinds of files on my desktop from different PIT's, stock roms, custom recoveries as believe me when your phone goes down and doesn't come back straight away you get desperate! I hope by writing this info here it will help others avoid the problems I had.

The things I've learned from this:

1. Stock rom can usually recover most problems, but it's a pita to get back to a custom recovery

2. NEVER follow another person's guide if the dev has written steps to follow when installing their software, the dev really knows best

3. Sometimes it's better to walk away and leave your device for a bit whilst it settles

4. Heimdall on Ubuntu (or whatever your version of Linux is) is surprisingly good these days especially if you use the GUI frontend, it didn't need me to install any custom drivers

5. Don't panic, and write up about what's happened so others don't repeat your mistakes :D