Install Halium 9 to recovery and external storage on Redmi Note 8 (ginkgo) to allow Dual Booting.
As with any OS operations, there is a chance of loosing data, or even bricking your phone. Back up any important data before starting. I will not be held responsible for anything.
There are prebuilt images in the releases. If you are using those, you can skip sections 3 & 4. Make sure to pick the right image for your case. Use the mmcblk1
if you are installing to the microsd card, and sda
if you are installing to usb-otg.
- You can use either a microsd card or usb-otg drive. It should be at least 10GB.
- Download a working vendor partition for your halium version. I used V11.0.9.0.PCOMIXM.
- Extract the vendor.img file from the archive, either by flashing it (not recommended) or by using brotli and dat2img.
- Format your drive and create two partitions. The first has to be the exact size in MB as the vendor image. The second should be at least 8GB. Note: the order matters!
- Flash the vendor image to the first partition. You can use
dd
or ubuntu'sDisks
, as follows:- Open Disks.
- Select the drive.
- Select the first partition.
- Unmount it if needed (by pressing the
stop
button). - Press the
gear
button and selectRestore Partition Image
. - Choose your vendor partition image.
- Flash your system image:
- If installing Ubports:
- Download the ubports image for ginkgo from gitlab ci.
- Flash the system image to the second partition on your drive using the same steps as above.
- If the partition and the image are not the same size, you might need to fix the file system.
- If installing Droidian:
- Download the latest droidian image for your device (api 28 for halium 9) from droidian-images.
- Extract
data/rootfs.img
from the archive and place it at the root of the second partition on the drive. - Open a terminal in the second partition on the drive, and run the follows (the equivalent of installing the GSI):
- If installing Ubports:
# resize rootfs
e2fsck -fy rootfs.img
resize2fs -f rootfs.img 8G
# install udev rules
wget https://gitlab.com/ubports/porting/community-ports/android9/xiaomi-redmi-note-8t/xiaomi-ginkgo-willow/-/raw/master/overlay/system/lib/udev/rules.d/70-willow.rules # or your devices udev rules
mkdir m
sudo mount rootfs.img m
sudo mv 70-willow.rules m/etc/udev/rules.d/70-willow.rules
sudo umount m
# halium initramfs workaround,
# create symlink to android-rootfs inside /data
ln -s /halium-system/var/lib/lxc/android/android-rootfs.img android-rootfs.img
- Boot to any working system on your mobile device with the external storage plugged in.
- Open
/dev
in a terminal (e.g.adb shell
) and note your external storage partitions' names (e.g/dev/sda1 & /dev/sda2
for usb-otg and/dev/mmcblk1p1 & /dev/mmcblk1p2
for microsd).
- Download source and dependancies (this will also start building the default image).
sudo apt install android-tools-mkbootimg bc bison build-essential ca-certificates cpio curl flex git kmod libssl-dev libtinfo5 python2 unzip wget xz-utils git
git clone https://gitlab.com/ubports/porting/community-ports/android9/xiaomi-redmi-note-8t/xiaomi-ginkgo-willow
cd xiaomi-ginkgo-willow
git clone https://gitlab.com/ubports/community-ports/halium-generic-adaptation-build-tools build-tools
./build-tools/build.sh -b "build"
- If you get the
yylloc
error: rungrep -rn "YYLTYPE yylloc"
in the kernel directory (build/downloads/kernel-xiaomi-willow
) and to all occurences other thandtc-lexer
add theextern
keyword. - Go to the kernel directory
cd build/downloads/kernel-xiaomi-willow
. - Run
grep -rn by-name/vendor
and replace all occurences with the path to your drive's first partition under/dev/block
. E.g. for external storage, replace
vendor {
compatible = "android,vendor";
dev = "/dev/block/platform/soc/1d84000.ufshc/by-name/vendor";
mnt_flags = "ro,barrier=1,discard";
fsmgr_flags = "wait,slotselect,avb";
status = "ok";
};
With
vendor {
compatible = "android,vendor";
dev = "/dev/block/sda1"; // replace here
mnt_flags = "ro,barrier=1,discard";
fsmgr_flags = "wait,slotselect,avb";
status = "ok";
};
- Go back to the
xiaomi-ginkgo-willow
directory. - Edit the file
deviceinfo
- For Ubports, replace the path of
systempart=
with the path of the second partition on your drive (e.g.systempart=/dev/sda2
). - For Droidian, remove the
systempart=
from the commandline, and adddatapart=
with the path to the second partition on your drive (e.g.datapart=/dev/sda2
).
- For Ubports, replace the path of
- Build the image by running
./build-tools/build.sh -b "build"
- You will find the output
boot.img
anddtbo.img
images atbuild/tmp/partitions
.
- Download android image kitchen (source code) and extract it.
- Download the latest twrp image for your device with the same android version as halium. I used twrp-3.6.2_9-0-ginkgo.img.
- Move it to the directory of andraid image kitchen.
- Unpack it by running
./unpackimg.sh twrp-3.6.2_9-0-ginkgo.img
- Delete the ramdisk, and rename the
split_img
folder. - Copy the
boot.img
we created in the previus section and unpack it too:./unpackimg.sh boot.img
- Copy the files back from the renamed
split_img
folder. - Replace the
twrp-3.6.2_9-0-ginkgo.img-cmdline, twrp-3.6.2_9-0-ginkgo.img-kernel, twrp-3.6.2_9-0-ginkgo.img-ramdisk.cpio.gz
files with the files from the boot image. Replacetwrp-3.6.2_9-0-ginkgo.img-recovery_dtbo
with thedtbo.img
we created in the previus section. Delete all the other files from the boot image (starting withboot.img
). - Repack the image:
./repackimg
- The new image,
image-new.img
, is your halium9-recovery-external-storage image!
Note: if you downloaded an image from the releases instead of building, use it in place of image-new.img
.
- Flash the newly created image to recovery using fastboot:
fastboot flash recovery image-new.img
or boot it directly:fastboot boot image-new.img
. - Reboot to recovery:
fastboot reboot recovery
- Your halium OS should boot without touching your primary OS! Note: if you have driver problems (e.g. the screen doesn't turn on) you can try rebooting to bootloader and then booting to recovery again to make sure nothing is left over from the newer android OS.