Switching from a Raspberry 2/3 to a Raspberry 4

Hi all,

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

Your 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.bak to copy the contents of your boot partition (/path/to/boot should be something like /media/user/boot)
  • Fire up gparted to remove the boot partition, free up about 250MB on the left of the card, and create a new partition filling those 250MB named boot on the left.
  • :warning: The new boot partition must be a ‘Primary partition’ formatted to fat32 named boot.
  • Apply the changes to your SD, wait for it to complete and finally move back the contents of the original boot partition with 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!



Thanks a lot for that tutorial, I tried to do that migration but failed because of the boot partition size issue that I wasn’t aware of…

My partition is 200MB large, and it still fails to update the kernel, and for now I didn’t find a way to enlarge it properly using gparted (it doesn’t want to enlarge my boot partition)…

Then you should try to copy your boot files, and use gparted to remove and recreate a larger boot partition.

gparted wouldn’t let me resize the boot partition either (a libsomething error if I remember correctly). Closely follow this page of the tutorial to do it. I’ve read that the boot partition should at least be 250MB. Mine is 270MB and it worked.

1 Like

Thanks for the tutorial.
a switch from an ARM board to a Raspberry 4 will me not that easy i gues… i plan to set up a new installation on a new SD card an will try to import the backups of the YH system and all apps step by step…

But what about all the settings for the router? if you connect a new board the the network it will get a new IP right? Is there a way to transform the the setting from the old board to the new borad?

You probably can configure your DHCP to assign a fixed (local) IP to your board. Then you can just use the previous board IP for the new one.
Or you can change your NAT redirection to use the new IP.