0

I want to try to replace Raspbian by Alpine on my Raspberry Pi Zero W, without having physical access to it. I am wondering whether the following procedure would work:

  • While Raspbian is running:
    • Replace the files in /boot with the files from the /boot partition of Alpine.
    • Add files in /boot to automate the Alpine installation.
  • Reboot into Alpine

I am not sure however that it is safe to replace the files in /boot while Raspbian is still running. According to 'lsof' there seem to be no files open, but that does of course not guarantee that indeed the files in /boot are not used anymore after the boot process is finished (incl shutdown/reboot). Does anybody know?

2
  • figure out how to run from memory only. note that loading a stock image from the nets will likely result in loss of your remote access so you will want to customize and provide the image. you'd have to unmount the sd, connect to a source for a raw image and overwrite the sd with the new image. all is possible to setup as root. don't know if anyone bothered to make a setup for it though.
    – Abel
    Jan 30 at 13:59
  • As per my answer, you don't need to run from memory to replace the stuff in the boot partition, there's no point -- you can delete everything there, unmount it, and destroy the partition formatting if you want, it doesn't matter at all once the OS is running. Running from memory is an option when you go to replace the root fs, which is much more challenging.
    – goldilocks
    Jan 30 at 15:14

1 Answer 1

2

I am not sure however that it is safe to replace the files in /boot while Raspbian is still running.

None of the files in the boot partition are used after the kernel has finished loading, so yes, you can do whatever you want with it as long as you are aware that will potentially affect whether it boots at all next time.

The only reason for that partition to be mounted at all is to simplify upgrades of the kernel, firmware, etc.

The hard part about this procedure is how you plan to replace the userland (ie., the stuff in the much bigger second partition). That's another question, the short answer to which is to install enough of a system (eg., the base Alpine install, which I would guess is only a few GB) in a new toplevel directory, leave a link to the toplevel of the root fs, then chroot in and do what you need to do. I would avoid a situation where you need to maintain network connectivity for that; since you cannot, you are going to have to plan and rehearse that part carefully.

If you are not sure what everything in that last paragraph refers to, keep in mind you have a very high chance of failure here, unfortunately, and you would likely be leaving the machine unbootable.

1
  • Thanks! For the Alpine userland I only a few hundred MB and I always leave enough space on the SD card to create / increase partitions for situations like this. The Alpine installation is pretty easy and can be scripted, but indeed it will be critical to get the network connectivity correct.
    – BFly
    Jan 31 at 13:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.