
<!-- Markdown Monster Content -->
# Install ubuntu touch on oneplus 6 

## Goal & issues:
> Install ubuntu touch & Android on oneplus6. Mainly targeting ubuntu touch for daily use(not really dual-boot)
>
> Issues: fix for dead boot/reboot from ubuntu touch (see bottom). 
> - simple install of silo-boot (see bottom) with android 9. 
> - Ubports_installer check 2 'wipes' and connect phone later.
> - Oneplus 6T from T-mobile (!risk: system update -> update local -> to android 9)
> Date: 10/27/2021
>
> Reference: <a href="https://github.com/ubports-oneplus6/documentation" target="_blank">Outdated documentation</a> & <a href="https://snapcraft.io/ubports-installer" target="_blank">ubports-installer video tutorial</a> & <a href="https://oneplus.gadgethacks.com/how-to/unlock-bootloader-your-oneplus-6-0185473/" target="_blank">Unlock bootloader</a> & <a href="https://github.com/ubports-oneplus6/documentation/issues/14" target="_blank">fix ref.</a>


## Fresh install?
### Prerequisites:
> All you data could be wiped!! Backup your data!!
>
> In Android of Oneplus 6: <a href="https://oneplus.gadgethacks.com/how-to/unlock-bootloader-your-oneplus-6-0185473/" target="_blank">Unlock bootloader</a>
> - Settings->About phone --> Build number to Enable Developer Options --> Enable OEM unlocking --> Enable Advanced Reboot (optional) , so you can boot into Fastboot Model (i.e. bootloader)
>
> Laptop: install ubports_installer  and adb tools.
>
> Ex: Ubuntu laptop with Snap
> - `sudo apt install android-tools-adb android-tools-fastboot`
> - `sudo adb start-server`
> - `adb devices` # list devices `adb shell` # open a shell on android device 
> - `sudo snap install ubports-installer` # may install lastest versions
> - `snap info ubports-installer` # show channels
> - `sudo snap refresh ubports-installer --channel=0.8.9/stable` # check info.


### 1. Flash Android 9 os with `potential` dualboot (Ubuntu + Android), based on <a href="https://github.com/ubports-oneplus6/documentation" target="_blank">Outdated documentation</a>

> - Laptop: download files based on step 1 in <a href="https://github.com/ubports-oneplus6/documentation" target="_blank">Outdated documentation</a>
> >- Download 2 versions of twrp in your laptop (ubuntu) :<a href="https://eu.dl.twrp.me/enchilada/twrp-3.4.0-3-enchilada.img.html" target="_blank">twrp-3.4.0-3-enchilada.img</a> and  <a href="https://eu.dl.twrp.me/enchilada/twrp-3.3.1-2-enchilada.img.html" target="_blank">twrp-3.3.1-2-enchilada.img</a>[optional]
> >- Download Android OS 9: <a href="https://otafsg1.h2os.com/patch/amazone2/GLO/OnePlus6Oxygen/OnePlus6Oxygen_22.O.34_GLO_034_1909112343/OnePlus6Oxygen_22_OTA_034_all_1909112343_dd26.zip" target="_blank">OnePlus6Oxygen_22_OTA_034_all_1909112343_dd26.zip</a>
> 
> - Phone: If not on 'fastboot', power off and press power button + volume up -> fastboot
> - if fastboot shows it is unlocked, then unlock by `fastboot oem unlock`. Select unlock.
> - Now boot into TWRP recovery with the command `fastboot boot twrp-3.4.0-3-enchilada.img`, once on on the main screen, you should see your phone in `adb devices` on your PC.
> - Move OxygenOS 9 zip file to your device with `adb push OnePlus6Oxygen_22_OTA_034_all_1909112343_dd26.zip /sdcard`
> - In TWRP go to install and choose OnePlus6Oxygen_22_OTA_034_all_1909112343_dd26.zip. Swipe to confirm flash and wait, it will take a few minutes. Note that this will install it to your other slot, it won't affect whatever Android system you're currently running.
> - Choose system from TWRP reboot menu, don't install the TWRP app!
> - Once it's done, go to the reboot menu and pick `bootloader`, then hit `reboot`. You should be in the bootloader - on a black screen with START in green letters like before, however you're now on the other slot (the one you just installed Android 9 to).

### 2. Install ubuntu by using official installer: <a href="https://snapcraft.io/ubports-installer" target="_blank">ubports-installer video tutorial</a>
> Phone: Make sure it is in bootloader screen
>
> Laptop: open software: Ubports_installer (current 0.8.9 stable).
> - 1) When installer starts, do not connect the phone to pc. Instead, manually select the device (oneplus 6). (if you connect the phone, installer may complain the phone is not supported)
> - 2) Connect the Oneplus 6 when installer shows 'install' (see <a href="https://snapcraft.io/ubports-installer" target="_blank">ubports-installer video tutorial</a>). Notice, when the prompts asks whether to wipe personal data and others. **Do Check all of the 2 options** Otherwise, you will get error on permission (if get error, click error page link and search to find solutions)>
> - 3) If *good*: you should get no error; Otherwise, search error message or refer to below trouble fix.
### 3. Fix for dead-loop of boot after power off/on
> Cause: possible issue is related to race condition. Fix: (acknowledge from the forum) one-time installation of a file;
> - laptop: download file: <a href="https://gitlab.com/ubports/community-ports/android9/oneplus-6/oneplus-enchilada-fajita/-/raw/d2d51a9d160fcb52f145d235e663ff5dd39ca6bf/overlay/system/etc/init/lxc-android-config.override?inline=false" target="_blank">lxc-android-config.override</a>
> - Phone: boot to `fastboot` (i.e. by pressing power button +volume up) and then connect to laptop, then select to `recovery mode` (i.e. by pushing volume down key), wait until ubuntu recovery screen appearss
>
> - Laptop: make sure you can do `adb devices` to see the phone, then run `adb push lxc-android-config.override /system_root/etc/init` and make sure no error comes out.
> - Phone: from the screen, select `reboot`. Phone should then reboot to Ubuntu touch. If phone is powered off but not on later, just manually power it on and wait < 20 seconds to see ubuntu welcome screen.



### Questions/issues?
> Switch back to Android?  <a href="https://github.com/ubports-oneplus6/documentation#switching-back-to-android" target="_blank">this may or may not break some ubuntu touch setup</a>
> - Power off the device, hold volume up and power to enter bootloader mode.
> - Run `fastboot getvar current-slot`, this will tell you which slot ubuntu touch is installed to.
> - Switch slots, if your current slot is a then run `fastboot --set-active=b`, if it's b use `--set-active=a`.
> - `fastboot reboot`

> Reboot does not *reboot*? 
> - This is normal even after you finish step 3. When phone is off, just manually power it on.
> - Still dead in boot? 
> > - Try above step: **switch back to Android**, then select `wipe/erase all the data`, 
> > - Then reboot to `fastboot`, and follow steps 1&2 to re-flash android 9 & install ubuntu touch

> New simple installation? no dual boot (<a href="https://github.com/ubports-oneplus6/documentation/issues/14" target="_blank">ref.</a>)
> - For op 6 of *global version* (not from T-mobile), just copy android 9 rom to op6 and then do 'system update' using `local update`
> - Then reboot into android 9, enable developer option, enable usb debugging, enable oem unlocking, enable advanced reboot option (to boot into `bootloader`)

> Appendix: what about==**oneplus 6T**== 
> - follow the same tutorial but with different version in overall with modification:
> > 1) Notice, if it is by T-mobile, one needs first to get unlock code. See <a href="https://www.xda-developers.com/oneplus-6t-unlock-bootloader-root/" target="_blank">here</a>
> > 2) Then, after you can do `fastboot oem unlock`, you follow similar steps like oneplus 6
> > 3) If get error from the ubports installer, make sure you check the 2 wipes (i.e. wipe personal data and the below one). 
> > 4) T mobile version, do *NOT* directly downgrade to andorid 9 using rom. You may get incompatible error (phone is bricked). 


<!-- End Markdown Monster Content -->
