Letās make for example microSD (or eemmc or ssd) > = 16G with 3 OS
sudo su
apt install mc parted kpartx
export MYSD=/dev/sdz; export MYSDp=$MYSD # !!!Replace sdz to yoor SD device!!!
parted $MYSD p
### Make sure it's the right device here!!! All previos data on it will be lost!!! ###
umount "$MYSDp"* # If not all parts are umount, free from use and repeat.
Selection other devices if you work on rock pi
All partitions of select device are must no use by worked system !!!
#export MYSD=/dev/nvme0n1;export MYSDp="$MYSD"p # SSD
#export MYSD=/dev/mmcblk0;export MYSDp="$MYSD"p # microSD in 4.x kernel OS
#export MYSD=/dev/mmcblk1;export MYSDp="$MYSD"p # EMMC in 4.x kernel OS or microSD in 5.x
#export MYSD=/dev/mmcblk2;export MYSDp="$MYSD"p # EMMC in 5.x kernel OS
SD markup commands
# All other strings from here may be copy-paste to terminal window
# and wait for the end of execution
umount "$MYSDp"*
dd if=/dev/zero of=$MYSD bs=1M count=16;sync
parted $MYSD mktable gpt;sync
parted $MYSD mkpart idbloader ext2 64s 8063s i;sync # "i" at end is needed
parted $MYSD mkpart uboot ext2 16384s 24575s;sync
parted $MYSD mkpart trust ext2 24576s 32767s;sync
LASTSECT=$(fdisk -l $MYSD|awk '{ print $3 }'|tail -n1)
parted $MYSD mkpart ubuntu_BOOTUBT ext2 $(($LASTSECT+1))s $(($LASTSECT+2048*256))s
# "ubuntu_BOOTUBT" is partition name. It need for info. I'm write here OS name and label.
sync;mkfs.ext2 -FL BOOTUBT "$MYSDp"4;sync # BOOTUBT is partition label
LASTSECT=$(fdisk -l $MYSD|awk '{ print $3 }'|tail -n1)
parted $MYSD mkpart none ext2 $(($LASTSECT+1))s $(($LASTSECT+2048*256))s
# at the end of prev string "256" in partition size in MB. Change possible
sync;mkfs.ext2 -FL none "$MYSDp"5;sync
LASTSECT=$(fdisk -l $MYSD|awk '{ print $3 }'|tail -n1)
parted $MYSD mkpart libre_STORAG ext4 $(($LASTSECT+1))s $(($LASTSECT+2048*256))s
sync;mkfs.ext4 -FL STORAG "$MYSDp"6;sync # temporary part for libreelec
LASTSECT=$(fdisk -l $MYSD|awk '{ print $3 }'|tail -n1)
parted $MYSD mkpart boot_LIBRE ext2 $(($LASTSECT+1))s $(($LASTSECT+2048*512))s
sync;mkfs.ext2 -FL LIBRE "$MYSDp"7;sync
LASTSECT=$(fdisk -l $MYSD|awk '{ print $3 }'|tail -n1)
parted $MYSD mkpart armbian_BOOTARMB ext2 $(($LASTSECT+1))s $(($LASTSECT+2048*256))s
sync;mkfs.ext2 -FL BOOTARMB "$MYSDp"8;sync
LASTSECT=$(fdisk -l $MYSD|awk '{ print $3 }'|tail -n1)
parted $MYSD mkpart armbian_ROOTARMB ext4 $(($LASTSECT+1))s $(($LASTSECT+2048*8192))s
# at prev string 8192 is partition size in MB. Change possible
sync;mkfs.ext4 -FL ROOTARMB "$MYSDp"9;sync
LASTSECT=$(fdisk -l $MYSD|awk '{ print $3 }'|tail -n1)
parted $MYSD mkpart ubuntu_ROOTUBT ext4 $(($LASTSECT+1))s $(($LASTSECT+2048*4096))s
sync;mkfs.ext4 -FL ROOTUBT "$MYSDp"10;sync
parted $MYSD t 4 boot t 8 boot p
#Partitions comletehttps://dl.armbian.com/rockpi-4b/Bionic_legacy_desktop
Everything should look like this:
Disk /dev/mmcblk1: 15,7GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 32,8kB 4129kB 4096kB idbloader
2 8389kB 12,6MB 4194kB uboot
3 12,6MB 16,8MB 4194kB trust
4 16,8MB 285MB 268MB ext2 ubuntu_BOOTUBT boot, esp
5 285MB 554MB 268MB ext2 none
6 554MB 822MB 268MB ext4 libtre_STORAGE
7 822MB 1359MB 537MB boot_LIBREELEC
8 1359MB 1627MB 268MB ext2 armbian_BOOT boot, esp
9 1627MB 10,2GB 8590MB armbian_ROOTFS
10 10,2GB 14,5GB 4295MB ext2 ubuntu_ROOTUBT
How to install uboot
Idbloader is starting from 64 sectors, uboot from 16384, trust from 24576. The first partition of the system begins with 32768 sectors. We can assume that all uboot partitions occupy sector from 64 to 32768. You can flash partitions individually, or all at once.
Individually:
cd to dir with files, e.g. cd /usr/lib/u-boot-rockpi4b/ on radxa linux OS , then
dd if=rockpi4b-rk-idbloader.img of="$MYSDp"1;dd if=rockpi4b-rk-uboot.img of="$MYSDp"2;dd if=rockpi4b-rk-trust.img of="$MYSDp"3;sync
All at once, several options, choose any suitable:
dd if=rockpi4b-ubuntu-bionic-minimal-20190104_2101-gpt.img of=$MYSD skip=64 seek=64 count=$((32768-64));sync # from full image OS
dd if=/dev/mmcblk0 of=$MYSD skip=64 seek=64 count=$((32768-64));sync # from other device
dd if=first16M_of_My_MMC0.img of=$MYSD skip=64 seek=64;sync # from backup
I backup the first 16 megabytes. This includes the device partition table and the entire uboot.
dd if=/dev/mmcblk0 of=first16M_of_My_MMC0.img bs=1M cunt=16;sync # make backup
Next copy files to $MYSD and configure
Copy radxa ubuntu files
Download ubuntu from radxa site and unpack.
Go to dir with img and stay there until the end of the installation ubuntu!
Replace path to own in next string!
cd /mnt/dataSSD/img
export DISTR=rockpi4b-ubuntu-bionic-minimal-20190104_2101-gpt.img
mkdir /mnt/1 /mnt/2 /mnt/3 /mnt/4
kpartx -arv $DISTR # look to number at "loop" end
mount /dev/disk/by-label/BOOTUBT /mnt/1
mount /dev/disk/by-label/ROOTUBT /mnt/2
mount /dev/mapper/loop0p4 /mnt/3
# replace number at "loop" end if not equal that show in previos kpartx command
mount /dev/mapper/loop0p5 /mnt/4
#Š”opy files, make changes and make files for the future.
rm -r /mnt/1/*; rm -r /mnt/2/*
cp -a /mnt/3/* /mnt/1; cp -a /mnt/4/* /mnt/2
sed -i "s%\(root=.*\)%root=${MYSDp}10%g" /mnt/1/extlinux/extlinux.conf
export EXTSH=/mnt/2/usr/local/sbin/return_my_root_to_extlinux.sh
echo '#!/bin/bash' > $EXTSH
echo sudo sed -i "s%root=PARTUUID=B921B045-1DF0-41C3-AF44-4C6F280D3FAE%root=${MYSDp}10%g" /boot/extlinux/extlinux.conf >> $EXTSH
chmod +x $EXTSH
sed -i 's/# UNCONFIGURED FSTAB FOR BASE SYSTEM//g' /mnt/2/etc/fstab
echo "LABEL=BOOTUBT /boot ext2 defaults 0 2" >> /mnt/2/etc/fstab
rm /mnt/2/etc/FIRST_BOOT
# Check configs
cat /mnt/1/extlinux/extlinux.conf
cat /mnt/2/etc/fstab
cat $EXTSH
### install ssh trough chroot, run the next 5 lines **manually** if necessary
#chroot /mnt/2
#echo 'nameserver 8.8.8.8' > /etc/resolv.conf
#apt update
#apt install -y ssh
#exit
umount /mnt/1 /mnt/2 /mnt/3 /mnt/4
rmdir /mnt/1 /mnt/2 /mnt/3 /mnt/4
kpartx -dv $DISTR
# end copy ubuntu
Copy armbian files
Download official armbian and unpack.
Go to dir with img and stay there until the end of the installation armbian!
Replace path to own in next string!
cd /mnt/dataSSD/img
export DISTR=Armbian_20.02.0-rc0_Rockpi-4b_bionic_legacy_4.4.210_desktop.img
mkdir /mnt/1 /mnt/2 /mnt/3
kpartx -arv $DISTR # look to number at "loop" end
mount /dev/disk/by-label/BOOTARMB /mnt/1
mount /dev/disk/by-label/ROOTARMB /mnt/2
mount /dev/mapper/loop0p1 /mnt/3 # replace number at "loop" end if not equal that show in previos kpartx command
#Š”opy files, make configs
rm -r /mnt/1/*; rm -r /mnt/2/*;
cp -a /mnt/3/boot/* /mnt/1; cp -a /mnt/3/* /mnt/2; rm -r /mnt/2/boot/*
mkdir /mnt/1/extlinux
export EXTCFG=/mnt/1/extlinux/extlinux.conf
echo 'LABEL Armbian' > $EXTCFG
echo ' LINUX /Image' >> $EXTCFG
echo ' INITRD /uInitrd' >> $EXTCFG
echo ' FDT /dtb/rockchip/rk3399-rockpi4b.dtb' >> $EXTCFG
echo ' APPEND root=LABEL=ROOTARMB rootflags=data=writeback rw console=uart8250,mmio32,0xff1a0000 console=tty0 no_console_suspend consoleblank=0 fsck.fix=yes fsck.repair=yes net.ifnames=0' >> $EXTCFG
mv /mnt/1/boot.scr /mnt/1/boot.scr.bak
echo 'LABEL=ROOTARMB / ext4 defaults,noatime,nodiratime,commit=600,errors=remount-ro 0 1' > /mnt/2/etc/fstab
echo 'LABEL=BOOTARMB /boot ext2 defaults 0 2' >> /mnt/2/etc/fstab
echo 'tmpfs /tmp tmpfs defaults,nosuid 0 0' >> /mnt/2/etc/fstab
# Check configs
cat /mnt/1/extlinux/extlinux.conf
cat /mnt/2/etc/fstab
umount /mnt/1 /mnt/2 /mnt/3
rmdir /mnt/1 /mnt/2 /mnt/3
kpartx -dv $DISTR
# end copy armbian
Default login: root password: 1234
Copy libreelec files
Download LE made by @balbes-150 and unpack.
Go to dir with img and stay there until the end of the installation LE!
Replace path to own in next string!
cd /mnt/dataSSD/img
export DISTR=LibreELEC-ARM-ALL.aarch64-9.80-devel-20200304135927-569f834-rk3399.img
mkdir /mnt/1 /mnt/2 /mnt/3
kpartx -arv $DISTR # look to number at "loop" end
mount /dev/disk/by-label/LIBRE /mnt/1
mount /dev/disk/by-label/STORAG /mnt/2
mount /dev/mapper/loop0p1 /mnt/3 # replace number at "loop" end if not equal that show in previos kpartx command
#Š”opy files, make configs
rm -r /mnt/1/*; rm -r /mnt/2/*;
cp -a /mnt/3/* /mnt/1
mkdir /mnt/1/extlinux
export EXTCFG=/mnt/1/extlinux/extlinux.conf
echo 'LABEL LibreELEC' > $EXTCFG
echo ' LINUX /KERNEL' >> $EXTCFG
echo ' FDT /dtb/rockchip/rk3399-rock-pi-4.dtb' >> $EXTCFG
echo ' APPEND boot=LABEL=LIBRE disk=LABEL=STORAG console=tty0 no_console_suspend consoleblank=0 quiet coherent_pool=2M cec.debounce_ms=5000' >> $EXTCFG
mv /mnt/1/boot.scr /mnt/1/boot.scr.bak
# Check configs
cat /mnt/1/extlinux/extlinux.conf
umount /mnt/1 /mnt/2 /mnt/3
rmdir /mnt/1 /mnt/2 /mnt/3
kpartx -dv $DISTR
# end copy armbian
For ssh entrance need ssh enable from startup dialog.
ssh login: root default password: libreelec
After executing all the previous commands, the device with 3 OS is ready. You can change the boot order using parted. The first partition with the boot flag will be loaded. For example, āparted $MYSD t 4 boot pā will change the boot flag to partition 4 and display the current table. Because earlier, on the 4th partition there was a boot flag, it will be removed and the next time armbian will boot.
If you set the boot flag to LE, then there parted to change the load can be called through ssh. I did not see the terminal plugin there.
Actions after the first start of radxa ubuntu
default login: rock password: rock
Donāt install rockchip-fstab !!!
sudo su
apt update && apt upgrade
apt install rockchip-overlay rockpi4b-rk-u-boot-latest rockpi4-dtbo # On the first question of confirmation of installation, press 'y', on the second question of the bootloader, press 'n' !!!
apt install ssh parted mc nano kpartx gdisk linux-base linux-4.4-latest
return_my_root_to_extlinux.sh
# check configs
cat /boot/extlinux/extlinux.conf
cat /etc/fstab
If ever a new kernel is installed during an apt upgrade, then always use return_my_root_to_extlinux.sh to restore the correct path to rootfs!
If you have a console cable
If you have a console cable, you can select the partition to boot at startup.
After starting, press Cttl-C many times until the load stops and the message "=> " appears. Then we enter for example:
sysboot mmc 1:b any 0x500000 /extlinux/extlinux.conf
and then will be booted 11 (b hex) partition from microsd. 1 here it is microSD , 0 will be emmc ā¦ wise with these 0 1 2 in different places - you wonāt figure it out without a bottle ;)))
I made an image according to this scenario.The size of the packed 2G file, unpacked 16G, so it does not need to be unpacked beforehand. Flash either through etcher or
unpigz -c multibot_1.img.gz | dd of=/dev/<yuor media> bs=4M status=progress; sync
then
parted /dev/<your media> p
if a message appears, you need to fix the increase in size.