switchboot.sh
#1
Hi All,

I am not much of a programmer, but I think I can finally contribute something to this great community. Cool

From my point of view, the most eagerly anticipated feature of the Pinephone must be its future ability to boot into several operating systems without having to swap memory cards. Some users already reported that their phone cases started crack from repeatedly opening and closing them - which proves the point that the current design is not ideal.

Two months ago, the development of the "Pineloader" was announced, promising OS selection via a menu at startup, but it has not become available yet. This is why I decided to put my own effort into a solution (Did someone say I am allowed to tinker with my phone?).

The result is a script file called switchboot.sh which is available for download here:

http://www.99computing.co.uk/download/Pi...irlist.php

It assumes that you have Ubuntu Touch in your phone's internal memory and Mobian on an SD card (more operating systems may follow later).

All you need to do is copy this file into both OSs. For simplicity and easy access, I suggest

/home/phablet  in the "userdata" partition of Ubuntu (you can use the Jumpdrive mode by pressing Volume Up at boot time until the LED turns green, then connect to your pc) and

/home/mobian  in the "rootfs" partition of Mobian (use your PC card reader)

Now you can open the terminal app (recommended: open a fresh instance if you have been doing other things before) and type in

sudo bash switchboot.sh

Your phone will take about one minute to shut down and restart in the opposite OS. That's it, plain and simple.

If you want to restart your phone without switching, just do it the normal way.

What is the secret?

With some experimenting, I found out that Mobian will not start if it cannot find the file Image.gz in its boot partition. This does not even have to be deleted. I just renamed it so that Mobian wil not recognise it. When the phone fails to boot from the SD card, it reverts back to its internal memory. If you later want to use the SD card again, the file just needs to be renamed back. The the script simply does the renaming for me.

I have several plans how it can be improved and possibly made into an app. But please bear with me, I am on a learning curve. Blush

In the meantime, please feel free to download the file, to comment here and tinker with it yourself. All I ask is share your findings so that we can work on it together.

Have fun!
  Reply
#2
there seems to be a lot of work in it that's pointless. it can be simplified by doing something like:

mkdir -p /media/mmcblk0p1
mount /dev/mmcblk0p1 /media/mmcblk0p1

if [ -f /media/mmcblk0p1/Image.gz ]; then
mv /media/mmcblk0p1/Image.gz /media/mmcblk0p1/Image.gz._
else
mv /media/mmcblk0p1/Image.gz._ /media/mmcblk0p1/Image.gz
fi

shutdown -r now
  Reply
#3
(07-12-2020, 01:15 PM)hiimtye Wrote: there seems to be a lot of work in it that's pointless. it can be simplified by doing something like:

Thanks. I am a bit busy for a couple of days but will look at this and other planned improvements later in the week.

As I said, I am on a learning curve. The last time I did this kind of batch programming was back in the early 90s under DOS.
  Reply
#4
hey, no worries, I just know that cleaner code is easier to debug, so getting out the clutter benefits everyone Smile
  Reply
#5
Very useful, thanks!

I wrote mobian-pinephone-phosh-20201113.img to my sd card and the boot structure is different.

Instead of /media/mmcblk0p1/Image.gz, boot depends on /media/mmcblk0p1/extlinux/extlinux.conf

Renaming extlinux.conf disables sd card mobian boot.
Reverting to extlinux.conf switches back to mobian boot on the sd card.

Adjust the code accordingly and you can switch back and forth as before.

p-boot (https://xnux.eu/p-boot/) seems more elegant / flexible but looks rather more daunting in terms of configuration.
Pinephone v1.2 UBports CE. Adelaide, Australia using Amaysim SIM (Optus network, VoLTE enabled) with Mobian SD card. VoLTE working also with Felix / Vodafone AU and Aldimobile / Telstra AU.
Manjaro Plasma Mobile on EMMC.
  Reply
#6
Hi,

Has anyone tried this on a recent version of mobian? Renaming /media/mmcblk0p1/extlinux/extlinux.conf does stop mobian from booting, but the OS on my EMMC (Arch in my case) still doesn't boot, and I still have to pull the SD card. Any ideas?

Thanks
  Reply
#7
(12-22-2020, 08:12 AM)moodroid Wrote: Hi,

Has anyone tried this on a recent version of mobian? Renaming /media/mmcblk0p1/extlinux/extlinux.conf does stop mobian from booting, but the OS on my EMMC (Arch in my case) still doesn't boot, and I still have to pull the SD card. Any ideas?

Thanks

@moodroid

Good question as I noticed the same thing. Trick for me is to long press the off button to turn the phone off. Then short press it to restart phone - it then boots into the other OS rather than being stuck on the Pine64 logo. It can take a few seconds to start, though. I just did the test from Mobian SD card to UBports on eMMC to update UBports. I then switched back to Mobian that is my daily driver.
Pinephone v1.2 UBports CE. Adelaide, Australia using Amaysim SIM (Optus network, VoLTE enabled) with Mobian SD card. VoLTE working also with Felix / Vodafone AU and Aldimobile / Telstra AU.
Manjaro Plasma Mobile on EMMC.
  Reply
#8
FYI for Manjaro Phosh changing /boot.scr to something else disables boot from the boot partition on the SD card. This disables SD card boot and you can boot the OS on the eMMC.

Rename back to /boot.scr to boot back from the SD card.
Pinephone v1.2 UBports CE. Adelaide, Australia using Amaysim SIM (Optus network, VoLTE enabled) with Mobian SD card. VoLTE working also with Felix / Vodafone AU and Aldimobile / Telstra AU.
Manjaro Plasma Mobile on EMMC.
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)