I recently switched my YNH server from a RasPi 2 to a RasPi 4 (and it feels amazing). I am running YNH on an SD card (haven’t put the boot partition on an external drive). Here is a quick guide if you plan to do the same, as it is not as easy as switching the cards.
I assume that you are running Linux on a different computer.
It is important to back your system up first if you want to do this, as many things could go wrong, running around with micro SD cards.
- First, make a system and app backup from yunohost, in order to be able to replicate your system if you have to build a new instance from scratch.
- Then, make a full copy of your SD card, so that you can restore it as new if all goes wrong: plug your card on your Linux running PC and run
dd status=progress if=/dev/mmcblk0 of=/path/to/file.img
(I guess you can also run it directly from yunohost, but don’t write on the SD as you would run out of space)
Just try to wing it
You can try to plug your SD in your new RP4 and power it up, but it will probably not boot, and the green LED should flash 4 long and 4 short flashes. This means your board in incompatible with the OS on the card (Raspberry Pi Documentation)
That’s because the new Raspberry needs a bigger boot partition than the older models. So, prepare yourself as it is gonna get a bit dirty…
Make a larger boot partition
boot partition should be around 50MB large (run
lsblk | grep boot on your server to check). The goal is simple: you want the partition to be around 250MB large.
You can do this using gparted. You should have 2 partitions on your SD:
boot, a small one, and a large one filling up the rest of the SD. Select the large one, right click and choose Resize. Free up about 200MB on the left of the partition and click OK.
Then, select the
boot partition and expand it to the right of those 200MB. Your partition should be about 250MB large. Click OKand apply the changes.
This will take a long time, but if it works you can jump to the update (last section).
If the boot partition could not be extended
This happened to me:
gpartred could not modify the
boot partition. In that case, you will have to:
- Restore the image on your SD card (if it seems modified) with
dd status=progress if=/path/to/file.img of=/dev/mmcblk0
- mount the boot partition of the SD card on your computer
cp -r /path/to/boot boot.bakto copy the contents of your
/path/to/bootshould be something like
- Fire up
gpartedto remove the boot partition, free up about 250MB on the left of the card, and create a new partition filling those 250MB named
booton the left.
bootpartition must be a ‘Primary partition’ formatted to
- Apply the changes to your SD, wait for it to complete and finally move back the contents of the original
cp -r boot.bak /path/to/boot.
Update the kernel and bootloader
When all is done, you have your SD card, which is your original system with an extended
boot partition. Put the card in your older RPi, boot it up, open a terminal as root and execute
apt install --reinstall raspberrypi-bootloader raspberrypi-kernel
Wait for the update to finish,
shutdown -h now your board, put the SD in your new RP4 and enjoy!