Multibooting Linux and Android¶
Warning
All data on your tablet will be erased. Back up anything important before continuing.
If you think you made a mistake, do not reboot the tablet. Ask for help in the support group first.
Run the commands one by one, in order.
What you need¶
- Xiaomi Pad 6 (pipa) with an unlocked bootloader.
- A computer with
adbandfastbootinstalled. - A USB cable to connect the tablet to your computer.
twrp.img, used to boot into TWRP temporarily.parted, used to manage the storage partition layout.- A Linux image file for the distro you want to install.
Before you start¶
- Backup your important Android data.
- Make sure Android can boot normally with USB debugging enabled.
- Make sure
adbandfastbootcan detect the device. - Put
twrp.img,parted, and the Linux image in the same folder on your computer for easier access. - Keep your Fastboot Stock ROM nearby in case you need to restore the device.
Basic idea¶
This guide uses the tablet's A/B slot system to keep Android and Linux separate.
- Slot A is used for Android.
- Slot B is used for Linux.
With this setup, you can switch between Android and Linux by changing the active slot. Android stays on one slot, while Linux is installed and booted from the other slot.
To switch from Android to Linux, rooted Android users can use Boot Control to change the active slot.
To switch from Linux back to Android, use:
sudo qbootctl -s a
You can also use the qbootctl GUI.
Step 1: Prepare Android¶
- Make sure USB debugging is enabled.
- Reboot into bootloader mode by holding Volume Down + Power.
- Confirm the device is detected:
fastboot devices
Step 2: Repartition storage¶
This step prepares space for Linux on the tablet storage.
-
Boot TWRP temporarily:
The TWRP image file may have a different name depending on who packaged it. In the linked download above, the file is named
boot-rmux.img, so that is the name used in the example below.fastboot boot boot-rmux.img -
After TWRP boots, push
partedto the tablet:adb push parted /tmp/parted -
Start an adb shell:
adb shell -
Make
partedexecutable:chmod +x /tmp/parted -
Start
parted:/tmp/parted /dev/block/sdaBefore this, your shell prompt will usually look like
pipa:/ #. If the command works, you will enter the interactivepartedprompt, so the prompt changes from the normal shell to(parted).You should see something like this:
GNU Parted 3.2 Using /dev/block/sda Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) -
Use
printto check the current partition layout before making changes:printThis prints the partition table for the internal storage. You will see the disk size at the top, followed by a list of partitions with columns such as
Number,Start,End,Size, andName.You are looking for the partition named
userdata. On pipa, this is usually the last partition in the table, often partition34.Example:
Model: SKhynix HN8T15DEHKX075 (scsi) Disk /dev/block/sda: 253GB Sector size (logical/physical): 4096B/4096B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags ... 34 11.1GB 253GB 242GB userdataIn this example,
userdatais partition34, and it uses most of the remaining internal storage.Compare the
Endvalue ofuserdatawith the total disk size shown at the top. Here, the disk size is253GB, and theuserdatapartition also ends at253GB, which means the layout is still close to the default one.If your
userdatapartition ends much earlier than the total disk size, or if the partition number and layout look very different from the example, the tablet was likely repartitioned before. Double-check the partition table carefully before making any changes.Warning
Double-check the partition numbers and sizes before applying any change. A wrong command can erase Android or make the tablet unbootable.
-
Delete the existing
userdatapartition first.On a mostly stock pipa layout,
userdatais usually partition34, so the command is often:rm 34You may see a warning like this:
Warning: Partition /dev/block/sda34 is being used. Are you sure you want to continue? Yes/No? yes Error: Partition(s) 34 on /dev/block/sda have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. before making further changes. Ignore/Cancel? ignoreRead the warning first and make sure you are deleting the correct partition. In this case, if you are sure that partition
34isuserdata, it is usually safe to answeryesand thenignore. This happens because the partition is still in use by the running environment, even though the partition table change itself was written. -
Create two new partitions in the free space:
- one partition for Android
- one partition for Linux
Choose a split point. This value is used twice: as the end of the Android
userdatapartition, and as the start of the Linux partition.Examples:
173GBgives Linux about80GB153GBgives Linux about100GB
Then create the Android
userdatapartition first:mkpart userdata ext4 11.1GB 153GBThen create the Linux partition:
mkpart linux ext4 153GB 253GBAfter making new partitions, the result will look something like this:
Number Start End Size File system Name Flags ... 34 11.1GB 153GB 142GB ext4 35 153GB 253GB 100GB ext4Warning
Run the
mkpartcommands one by one in the(parted)prompt. Double-check the start and end values before pressing Enter. A wrong value here can overlap partitions or leave Android without enough space. -
Name the new partitions.
On a mostly stock layout, the recreated Android partition will usually be
34, and the new Linux partition will usually be35.First, name partition
34asuserdatafor Androidname 34 userdataThen name partition
35for Linux. You can uselinuxor another simple name if you prefer.name 35 linuxAfter naming the partitions, the result will look something like this:
Number Start End Size File system Name Flags ... 34 11.1GB 153GB 142GB ext4 userdata 35 153GB 253GB 100GB ext4 linux -
Exit
parted, then leave the adb shell.First, quit the
(parted)prompt:quitThis will return you to the normal shell prompt, which usually looks like
pipa:/ #.Then exit the shell:
exitReboot the tablet:
adb rebootLet the tablet boot back into Android to make sure the new partition layout is still usable before continuing.
Step 3: Install Linux¶
Before continuing, choose a Linux distro for pipa. Some available projects include:
- postmarketOS - pmOS for pipa
- void-linux-pipa - Another Void Linux for pipa
- pipa-alarm - alarm (Arch Linux ARM) for pipa
- armtix-xiaomi-pipa - ARMtix (Artix Linux ARM) for pipa
- pipa-fedora-builder-43 - Another Fedora for pipa
Choose one and download it. Make sure the downloaded files include boot.img and root.img.
-
Power off the tablet, then boot it into bootloader mode by holding Volume Down + Power.
-
Make sure the tablet is detected in fastboot mode.
fastboot devices -
Flash the boot image to slot
b.fastboot flash boot_b boot.img -
Flash the rootfs image to the Linux partition.
fastboot flash linux_partition root.imgReplace
linux_partitionwith the Linux partition name you created earlier in Step 2, such aslinuxor another name you chose in poin9. -
Clear the
dtbopartition in slotb.fastboot erase dtbo_b -
Reboot the tablet out of bootloader mode.
fastboot rebootAfter this, the tablet should boot into Linux. Check the distro link you chose earlier for details about its desktop environment, first boot experience, and any distro-specific setup steps. Distros with a desktop environment should boot straight into it after the first startup. Otherwise, you will likely land in a text console and need to continue setup from there.
Note
Linux installation is now complete. Once you have confirmed that Linux boots correctly, use the Android boot instructions from Basic idea to switch back to slot a.
Step 4: Post install maintenance¶
Some important Tips for keeping your dual-boot install stable.
- Disable any OTA updates on Android, as they are flashed to the slot Android sees as inactive, which is where you just installed Linux.
- Be careful when using tools to manually switch Boot slots! Especially qbootctl on Linux is known to eventually brick your system. Take care and double check before switching slots or, if you want to be extra careful, only switch using fastboot.