Petitboot and multiple OSes on the same disk (Android + Linux)

Post Reply
mad_ady
Posts: 9049
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 595 times
Been thanked: 573 times
Contact:

Petitboot and multiple OSes on the same disk (Android + Linux)

Post by mad_ady »

Hello all!

Here is my quick guide on getting Android and some other OSes on the same disk (in my case EMMC, but tobetter and his colleagues made Android work on HDD as well). I used an N2+ for my tests, but should work the same way for C4, HC4, N2 (and other future petitboot-enabled boards).

Before we begin - make sure you update petitboot to the latest version (Exit to shell -> pb-update).

If you install Android, go ahead and install it normally on your target disk (by following the Android instructions). It needs to be the first OS installed because it uses some data in unpartitioned space, at fixed offsets. Once Android is booting correctly (with or without petitboot), you can start this guide.

You'll need access to a Linux computer (can be a different Odroid system too) that can run gparted (for simplicity). In my example I'm using an x86 computer, so some things may need tweaking:

On the host PC make sure kernel boots with loop.max_part=16 (or some arbitrary number). You can edit /etc/default/grub.conf and set it - for instance:

Code: Select all

GRUB_CMDLINE_LINUX_DEFAULT="loop.max_part=16"
Apply with sudo update-grub2 and reboot the host. Check that it's applied with:

Code: Select all

$ cat /proc/cmdline
Now, download the image you want to append to your EMMC (or disk). In my case it was ubuntu 20.04 from @tobetter: http://ppa.linuxfactory.or.kr/images/ra ... 218.img.xz

Code: Select all

$ cd Downloads
$ unxz ubuntu-20.04-server-odroidn2plus-20201218.img.xz
$ file ubuntu-20.04-server-odroidn2plus-20201218.img 
ubuntu-20.04-server-odroidn2plus-20201218.img: DOS/MBR boot sector; partition 1 : ID=0x83, start-CHS (0x0,32,33), end-CHS (0x20,194,34), startsector 2048, 524288 sectors; partition 2 : ID=0x83, start-CHS (0x20,194,35), end-CHS (0x7b,85,33), startsector 526336, 1455047 sectors
$ sudo losetup `losetup -f` ubuntu-20.04-server-odroidn2plus-20201218.img 
Start gparted (as root). We want to see loop devices, so...

Code: Select all

$ losetup | grep img
/dev/loop12         0      0         0  0 /home/adrianp/Downloads/ubuntu-20.04-server-odroidn2plus-20201218.img   0     512
$ sudo gparted /dev/loop12 /dev/sdb
This will show both the original image partitions and the target disk/emmc (/dev/sdb in my case).


Shrink Android's second partition, without moving it (it should have the same starting point). In the new free space after the second partition I created an extended partition. Next, copy over the partitions from the loop device and paste them in the extended partition. You can add multiple OSes, but make sure each partition has a distinct UUID. Here are the steps detailed:

1. This is how the Android default partition layout looks like (voodik's Lineage 17):
Image
2. Resize the second partition, without moving its start location:
Image
Image
3. Create a new extended partition in the unallocated space at the end:
Image
4. Switch back to the loop device with your OS to flash
Image
5. Copy/paste the partitions to the extended partition. You can resize the rootfs at this step.
Image
6. Apply
Image

Take a look at the boot scripts and make adjustments if necessary (so the kernel can see the rootfs). Check boot.ini or boot.scr in sdb5 and etc/fstab in sdb6. If they all use uuids you should be good to go.:

Code: Select all

$ sudo mount /dev/sdb5 /media/test
$ sudo mount /dev/sdb6 /media/test2
In my case I didn't have to make any changes.

Plug back the storage in your Odroid and boot. Petitboot should show you all the OSes
Image
Note - in order not to mess up Android, you should make sure that no linux installation ever tries to update u-boot, since it might overwrite things specific for Android...
Good luck!

Edit: it's similar to what tobetter described here: https://medium.com/@tobetter/installing ... 7bcaef0545, only it's done manually.
These users thanked the author mad_ady for the post (total 3):
tobetter (Wed Dec 30, 2020 10:04 pm) • istanbulls (Thu Dec 31, 2020 12:58 am) • loredin (Mon Jan 11, 2021 6:47 am)

User avatar
istanbulls
Posts: 442
Joined: Tue May 14, 2019 10:18 pm
languages_spoken: Turkish
ODROIDs: ODROID; N2, C4, XU4, N2+, CH4
Location: Istanbul-Turkey
Has thanked: 276 times
Been thanked: 65 times
Contact:

Re: Petitboot and multiple OSes on the same disk (Android + Linux)

Post by istanbulls »

Thanks for this Well explained, useful tutorial.
I installed 4-5 operating system on HC4 using a similar method.

My problem-question is for N2-SSD.
I cannot install Android on SSD, because the spi key must be in emmc for the first installation of Android, Android needs it.
So how do I install Androit OS on SSD!

mad_ady
Posts: 9049
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 595 times
Been thanked: 573 times
Contact:

Re: Petitboot and multiple OSes on the same disk (Android + Linux)

Post by mad_ady »

Grrr, I can't find it, but tobetter (or maybe odroid?) posted a how-to install Android to SSD a week or two ago. The problem is, it currently works only with Hardkernel's Android, not (yet) with voodik's build.
I can't find the link (maybe it should be sticky in the Android section?), maybe @tobetter can help...
These users thanked the author mad_ady for the post:
istanbulls (Thu Dec 31, 2020 5:10 am)

loredin
Posts: 38
Joined: Sat Dec 26, 2015 12:17 am
languages_spoken: english, french, german
ODROIDs: xu4;n2
Has thanked: 7 times
Been thanked: 0
Contact:

Re: Petitboot and multiple OSes on the same disk (Android + Linux)

Post by loredin »

Are there any specific instructions to get android (maybe specific version of android) working with petitboot ?

User avatar
tobetter
Posts: 7118
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: Many
Location: Paju, South Korea
Has thanked: 380 times
Been thanked: 1044 times
Contact:

Re: Petitboot and multiple OSes on the same disk (Android + Linux)

Post by tobetter »

loredin wrote:
Mon Jan 11, 2021 6:02 am
Are there any specific instructions to get android (maybe specific version of android) working with petitboot ?
No, if you have flashed the latest version of Android it will work out of box. Also the Petitboot has to be the latest version, 20201222.
These users thanked the author tobetter for the post:
loredin (Tue Jan 12, 2021 3:20 am)

mad_ady
Posts: 9049
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 595 times
Been thanked: 573 times
Contact:

Re: Petitboot and multiple OSes on the same disk (Android + Linux)

Post by mad_ady »

If you follow my instructions make sure you boot Android after flashing it so it can complete the selfinstall before resizing its data partition.
These users thanked the author mad_ady for the post:
loredin (Tue Jan 12, 2021 3:20 am)

Post Reply

Return to “Projects”

Who is online

Users browsing this forum: stuart264 and 2 guests