Change OS on the Fly

How to change the OS of your Raspberry Pi while it is running.

WARNING: This guide is incomplete

 

  1. Download Raspbian from https://www.raspberrypi.org/downloads/raspbian/
  2. Burn the image to a spare SD card
  3. Boot the Pi with it and SSH into it
  4. Download Ubuntu Core from http://cdimage.ubuntu.com/ubuntu-core/16/stable/current/ubuntu-core-16-pi3.img.xz
  5. Running  fdisk -l  and  fdisk -l ubuntu-core-16-pi3.img  shows that the raspbian boot partition  has only 63MiB while Ubuntu Core needs 128MiB here.

 

There are basically two ways of installing a noter OS while the RPi is running.

One is overriding the boot and root partitions and the other is to override the content of them. Overriding the content will result in a lot of artefacts let on the system but might be easier to implement and those artefacts can be removed in subsequent updates.

Overriding the partitions itself maybe even recreating is damn complicated while easy for the boot partition the root partition is of the EXT4 type that means it can’t be unmounted while its used. Now its not exactly fun nor possible to SSH into a machine stop the SSHD and other services which are using the partition basically locking yourself out and THEN shrinking the partition. So one way around this would be to use the boot process itself to shrink the partition while its not yet mounted this might work with the cmdline.txt on the /boot partition   however I’m not sure which tools are a viable running a simple which fdisk  gives /sbin/fdisk so thats on the root partition so not a viable during the boot process. A way around would probably be to use a custom initrd.img that supplies the needed tools and partitioning with that.

 

Basically the point where I don’t yet have a satisfying solution. If you do know a better way let me know.

 

 

Boot process

http://elinux.org/RPi_Software#Overview

 

LED meanings during boot process

Red LED on: Power OK

Red LED blink or off: Problem with Power

Green LED off: bootloader.bin not found. Make sure there is a FAT32 partition with that file on the sd card. It is interesting to not that the RPi does not use a MBR (Master Boot Record) instead the firmere (in the SoC or GPU?) looks for the first FAT32 partition and looks for the bootloader.bin file there. This means that no nasty placing to a specific disk sector has to be made the file can just be copied over which is nice.

Green LED blink 5 times periodically : bootloader.bin found. Problems with the next stage (missing or invalid?) start.elf.

Green LED blink 7 times periodically: kernel.img not found.

Green LED blink 2 times only once on startup: (fixup.dat or cmdline.txt or config.txt not found? / everything ok turning off led for later sd card access indicator?)

 

Helpful links

RPi boot error led blink codes: http://www.techradar.com/how-to/computing/how-to-fix-raspberry-pi-boot-problems-1310697/2

https://www.tummy.com/blogs/2007/07/30/reducing-the-size-of-your-root-partition/

Leave a Reply

Your email address will not be published.