FlightAware Discussions

Upgrading to a new Raspberry PI - without losing Ranking & Data

How can I upgrade to a new Pi (4), without losing ranking in the feeder stats and also retain data ?

Until now, any upgrades I have done, resets everything, is there any way to migrate preserving info. ?

Create a new microSD card for your new Pi and then follow these instruction and all will continue uninterrupted.


Also see https://github.com/wiedehopf/graphs1090

Towards the bottom of the page there is a how to backup and restore graphs.

Read this before you re-image the original card.

Thank you for the tips

Add “piaware-config feeder-id (your ID)” at the bottom of /boot/piaware-config.txt, remove the SD-card from the old rpi, stick it in the new one, you’re good to go. You will find your feeder-ID on your FA feeder page under “Site information” as “Unique Identifier”.


If the old card is a regular SD, not a micro-SD, you’ll need to copy it sector-by-sector to a new micro-SD. You can also do this anyway, even if both cards are the same physical size, because it will allow you to keep both rpis as fallbacks to each-other. You will need an SD-to-USB adapter and a regular USB stick for this:

  1. Log in as pi on your old rpi and run
    sudo su -
    apt-get update
    apt-get upgrade
    nano /boot/piaware-config.txt
    Add “piaware-config feeder-id (your ID)” at the bottom of the file. Hit Ctrl-O, enter, Ctrl-X. Run
    shutdown -h now
  2. Install raspbian on the new micro-SD card.
  3. Boot your new rpi with it.
  4. Log in on the new rpi as pi and run:
    sudo su -
    apt-get install dd
    dmesg -w |grep sd:
  5. Stick your old SD into the new rpi with the USB adapter. The dmesg output will tell you that it was identified as sdX, where X is a letter. It will almost certainly be sdb.
  6. Press Ctrl-C to get back your prompt, then run
    dd if=/dev/sdX of=oldcard.img bs=4M status=progress
    where X is the letter that you got from dmesg. When it’s done, the file /root/oldcard.img will be an exact image of your old card.
  7. Remove your old card and put a formatted USB-stick in the new rpi. It doesn’t matter if it contains data, but it must have at least as much free space as the entire size of the old SD-card. Run
    dmesg |grep sd
    and make note of the last sdX. It will likely be sdb again. The last line of the output will also show you the partitions on the stick as “sdX: sdX1 sdx2” etc.
  8. Run
    fdisk -l /dev/sdX (that’s a minuscule L, not a digit one; the same applies also further down)
    You will see one or more partitions, the same as in 7, with their numbers, sizes and types. Make note of the big one, probably sdX2, then run
    mount /dev/sdXN /mnt
    where X is the disk letter and N is the partition number, e.g. mount /dev/sdb2 /mnt . Check that everything went well with
    df -h
    This should show /dev/sdXN mounted on /mnt. Make a note of the free space on it.
  9. Run
    ls -lh oldcard.img
    and make sure that the size of oldcard.img is smaller than the free space on /mnt as shown by the df command above. If it is, proceed with
    cp -va oldcard.img /mnt/
    md5sum oldcard.img
    md5sum /mnt/oldcard.img
    The two md5 hashes should be identical. If they are, do
    shutdown -h now
  10. Put the old SD-card back in the old rpi and boot it. Remove the USB stick from the new rpi and put it in the old one. Boot the old rpi. Log in as pi and run
    sudo su -
    apt-get install dd
    dmesg |grep sd
    The last sdX is the USB stick. Using X as the letter that you just got from dmesg and N as the number that you used with the mount command in step 8, do
    mount /dev/sdXN /mnt
    df -h
    You should see the USB-stick mounted on /mnt
    ls -l /mnt/
    You should see oldcard.img .
  11. Run
    dmesg -w |grep sd
    Remove the new SD-card from the new rpi and put it in the old rpi with the SD-to-USB adapter. At the bottom of your running dmesg output you will see how it was labelled, probably sdc. Make a note of this and pay attention, or else you’ll ruin everything you’ve done so far and have to start all over again from 1. Press Ctrl-C to get your prompt back.
  12. Run
    apt-get install dd
    dd if=/mnt/oldcard.img of=/dev/sdY bs=4M status=progress
    where Y is the letter you got from dmesg is step 11.
    umount /mnt
    When this is done, you can pull out and put away the USB-stick. You still have an image of your old SD-card on it in case you’d need it in the future. Your new SD-card will now be an identical copy of your old one and you could just pull it out, stick it in your new rpi, and be done. However, in order to to do things properly you have another couple of things left to do.
  13. If your new SD-card is bigger in capacity, i.e. size in GB, than your old one, you should resize its data partition and filesystem to take advantage of the space. In that case, still using the letter from step 11 for Y, do
    fdisk /dev/sdY
    This will show you partitions and free space. The big, last and perhaps even only one partition is your data partition. Write down on paper its number, start and end sectors and type. For example, if you see something like
    Device Boot Start End Sectors Size Id Type
    /dev/sdc1 8192 352900 344709 168.3M c W95 FAT32 (LBA)
    /dev/sdc2 360448 30253055 29892608 14.3G 83 Linux
    sdc2 is your data partition and you need to note “partition 2, start 360448, end 30253055, type 83”. Now you will delete that data partition and then re-create it with the same start sector. Hit d, give the correct partition number when asked and hit enter. Then press n to create a new partition, say p for primary when asked, and give the partition number and first sector exactly as they were before. When asked for the last sector, just press enter to accept the default. If you are asked anything about removing signatures, say no. Now press p again to list the partitions and check the type of the new partition that you have just created. If it is not exactly the same as before, e.g. “83 Linux” or “c W95 FAT32 (LBA)” or whatever you had, press t to toggle the type, give the correct partition number, then give the original code, e.g. 83, and press enter. Press p again and compare what you have now to what you had originally. Everything should be exactly the same except the “End” sector, which should be a higher number than before. If that is the case, press w to write the new partition table. If it is not, press q to quit fdisk without making any changes, then start again on this point 13 when you have figured out what you did (or what I instructed) wrong.
  14. When the data partition of the new card has been grown, the filesystem on it has to be grown too. Still using the same Y letter and N number as in steps 12 and 13, run
    partprobe /dev/sdY
    resize2fs /dev/sdYN
    Then take out the new SD-card and put it in the new rpi.
  15. If you have come so far, you have two raspberrys with two identical systems. You can use either of them at any time, but you should not boot both at the same time. To be able to do the latter, shut down the old rpi, boot and log onto the new rpi, and change its hostname:
    nano /etc/hostname
    If it has a static IP-address, change that too. Depending on whether the old rpi was a piaware image or add-on and on when you installed it, you will need to do one of the following:
    nano /etc/dhcpcd.conf
    nano /etc/network/interfaces
    and change the IP-address of both the wired and the wireless interfaces to some new free address. As an aside: having two live interfaces on the same network, e.g. wired on and wifi on, tends to create routing problems and serves no purpose. If that is your setup, just turn one of the two interfaces completely off.

All this might look terribly complicated at first sight, but it’s really nothing, just a bit of data copying back and fro so that you can get your new rpi up and running without having to install and configure everything from scratch, while also keeping your old rpi as a fallback in case you’d need it.

Having done 15, you will be able to boot both rpis at the same time. The one that happens to have the ADS-B dongle on it will feed data to FA. dump1090 on the other one will complain in the logs that it can’t find the dongle and exit, leaving the rpi and its CPU free for anything else you might want to use it for. Just don’t run both rpis at the same time with ADS-B dongles and antennas on both of them.