crobarcro
Posts: 3
Joined: Mon Jan 14, 2019 11:34 am

raspberrypi-bootloader error during apt-get upgrade after restore form backup, how to fix?

Thu Jan 17, 2019 1:39 pm

I recently restored a pi 3 from a backup. Before the incident that required the restore I had it booting from a USB SSD hard drive. To restore the operating system I simply copied the root directory of the SD card (using rsync -a with --delete-during) to the USB drive.

Next I tried `apt-get update` and `apt-get upgrade`. All went smoothly until I got an error like this:

Code: Select all

    Preparing to unpack .../raspberrypi-bootloader_1.20181112-1_armhf.deb ...
    /boot appears to be NOOBS recovery partition. Applying fix.
    Could not determine root partition
    dpkg: error processing archive /var/cache/apt/archives/raspberrypi-bootloader_1.20181112-1_armhf.deb (--unpack):
     subprocess new pre-installation script returned error exit status 1
    No diversion 'diversion of /boot/start.elf by rpikernelhack', none removed.
    No diversion 'diversion of /boot/start_cd.elf by rpikernelhack', none removed.
    No diversion 'diversion of /boot/start_db.elf by rpikernelhack', none removed.
    No diversion 'diversion of /boot/start_x.elf by rpikernelhack', none removed.
    No diversion 'diversion of /boot/fixup.dat by rpikernelhack', none removed.
    No diversion 'diversion of /boot/fixup_cd.dat by rpikernelhack', none removed.
    No diversion 'diversion of /boot/fixup_db.dat by rpikernelhack', none removed.
    No diversion 'diversion of /boot/fixup_x.dat by rpikernelhack', none removed.
    No diversion 'diversion of /boot/bootcode.bin by rpikernelhack', none removed.
    No diversion 'diversion of /boot/LICENCE.broadcom by rpikernelhack', none removed.
    Errors were encountered while processing:
     /var/cache/apt/archives/raspberrypi-bootloader_1.20181112-1_armhf.deb
    E: Sub-process /usr/bin/dpkg returned an error code (1)

How can I fix this error and complete the upgrade?

When I made the restore from the SD card to the USB drive I used an rsync exclude file like this:

Code: Select all

    /proc/*
    /sys/*
    /dev/*
    /boot/*
    /tmp/*
    /run/*
    /mnt/*
    /media/*
    
    .bash_history
    /etc/fake-hwclock.data
    /var/lib/rpimonitor/stat/
But after this, I wasn't sure whether I needed to copy /boot, but decided to copy it over with `sudo cp -r /boot/* /media/usbdrive/boot/`.

Following this I set up my cmdline.txt and fstab etc to use the usb drive again instead of the SD after initial boot.

Some other things that might be relevant are

1) output of fdisk -l

Code: Select all

    pi@raspberrypi:~ $ sudo fdisk -l
    Disk /dev/ram0: 4 MiB, 4194304 bytes, 8192 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 4096 bytes
    I/O size (minimum/optimal): 4096 bytes / 4096 bytes
    
    
    Disk /dev/ram1: 4 MiB, 4194304 bytes, 8192 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 4096 bytes
    I/O size (minimum/optimal): 4096 bytes / 4096 bytes
    
    
    Disk /dev/ram2: 4 MiB, 4194304 bytes, 8192 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 4096 bytes
    I/O size (minimum/optimal): 4096 bytes / 4096 bytes
    
    
    Disk /dev/ram3: 4 MiB, 4194304 bytes, 8192 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 4096 bytes
    I/O size (minimum/optimal): 4096 bytes / 4096 bytes
    
    
    Disk /dev/ram4: 4 MiB, 4194304 bytes, 8192 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 4096 bytes
    I/O size (minimum/optimal): 4096 bytes / 4096 bytes
    
    
    Disk /dev/ram5: 4 MiB, 4194304 bytes, 8192 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 4096 bytes
    I/O size (minimum/optimal): 4096 bytes / 4096 bytes
    
    
    Disk /dev/ram6: 4 MiB, 4194304 bytes, 8192 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 4096 bytes
    I/O size (minimum/optimal): 4096 bytes / 4096 bytes
    
    
    Disk /dev/ram7: 4 MiB, 4194304 bytes, 8192 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 4096 bytes
    I/O size (minimum/optimal): 4096 bytes / 4096 bytes
    
    
    Disk /dev/ram8: 4 MiB, 4194304 bytes, 8192 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 4096 bytes
    I/O size (minimum/optimal): 4096 bytes / 4096 bytes
    
    
    Disk /dev/ram9: 4 MiB, 4194304 bytes, 8192 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 4096 bytes
    I/O size (minimum/optimal): 4096 bytes / 4096 bytes
    
    
    Disk /dev/ram10: 4 MiB, 4194304 bytes, 8192 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 4096 bytes
    I/O size (minimum/optimal): 4096 bytes / 4096 bytes
    
    
    Disk /dev/ram11: 4 MiB, 4194304 bytes, 8192 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 4096 bytes
    I/O size (minimum/optimal): 4096 bytes / 4096 bytes
    
    
    Disk /dev/ram12: 4 MiB, 4194304 bytes, 8192 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 4096 bytes
    I/O size (minimum/optimal): 4096 bytes / 4096 bytes
    
    
    Disk /dev/ram13: 4 MiB, 4194304 bytes, 8192 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 4096 bytes
    I/O size (minimum/optimal): 4096 bytes / 4096 bytes
    
    
    Disk /dev/ram14: 4 MiB, 4194304 bytes, 8192 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 4096 bytes
    I/O size (minimum/optimal): 4096 bytes / 4096 bytes
    
    
    Disk /dev/ram15: 4 MiB, 4194304 bytes, 8192 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 4096 bytes
    I/O size (minimum/optimal): 4096 bytes / 4096 bytes
    
    
    Disk /dev/mmcblk0: 14.9 GiB, 15931539456 bytes, 31116288 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disklabel type: dos
    Disk identifier: 0x0004e623
    
    Device         Boot   Start      End  Sectors  Size Id Type
    /dev/mmcblk0p1         8192  3279296  3271105  1.6G  e W95 FAT16 (LBA)
    /dev/mmcblk0p2      3279297 31116287 27836991 13.3G  5 Extended
    /dev/mmcblk0p5      3284992  3350525    65534   32M 83 Linux
    /dev/mmcblk0p6      3350528  3491839   141312   69M  c W95 FAT32 (LBA)
    /dev/mmcblk0p7      3497984 31116287 27618304 13.2G 83 Linux
    
    
    Disk /dev/sdb: 117.4 GiB, 126035288064 bytes, 246162672 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disklabel type: gpt
    Disk identifier: 909F2695-EDB4-4CDE-A258-7EE27E75BD77
    
    Device     Start       End   Sectors   Size Type
    /dev/sdb1   2048 246162638 246160591 117.4G Linux filesystem
    
    
    Disk /dev/sda: 230.5 GiB, 247510073344 bytes, 483418112 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disklabel type: dos
    Disk identifier: 0x00030033
    
    Device     Boot Start       End   Sectors   Size Id Type
    /dev/sda1  *     2048 483409919 483407872 230.5G 83 Linux

2) my fstab

Code: Select all

    pi@raspberrypi:~ $ cat /etc/fstab
    proc            /proc           proc    defaults          0       0
    /dev/mmcblk0p1  /boot           vfat    defaults          0       2
    #PARTUUID=d96b7723-01  /boot           vfat    defaults          0       2
    #PARTUUID=d96b7723-02  /               ext4    defaults,noatime  0       1
    # The USB SSD  drive
    PARTUUID=712ae4a6-73d8-4aca-9ec6-b6e507c95f74  /                 ext4    defaults,noatime                            0       1
    # another USB flash drive
    UUID=978cc26c-be1f-4318-b4c3-6b0448333b02      /media/usbflash0  ext4    defaults,nofail,noatime  0       0
    # a swapfile is not a swap partition, no line here
    #   use  dphys-swapfile swap[on|off]  for that
3) contents of `/boot` (on the usb drive, I copied this from sd card, should I have?)

Code: Select all

    pi@raspberrypi:~ $ ls /boot/
    bcm2708-rpi-0-w.dtb  bcm2708-rpi-b-plus.dtb  bcm2709-rpi-2-b.dtb  bcm2710-rpi-cm3.dtb  defaults                 os        recovery7.img     recovery.elf                recovery.img  riscos-boot.bin
    bcm2708-rpi-b.dtb    bcm2708-rpi-cm.dtb      bcm2710-rpi-3-b.dtb  BUILD-DATA           INSTRUCTIONS-README.txt  overlays  recovery.cmdline  RECOVERY_FILES_DO_NOT_EDIT  recovery.rfs
4) contents of sd card boot partition

Code: Select all

    pi@raspberrypi:~ $ sudo mkdir /media/sdboot
    pi@raspberrypi:~ $ sudo mount /dev/mmcblk0p6 /media/sdboot/
    pi@raspberrypi:~ $ ls /media/sdboot/
    bcm2708-rpi-0-w.dtb  bcm2708-rpi-b-plus.dtb  bcm2709-rpi-2-b.dtb  bcm2710-rpi-cm3.dtb  cmdline.txt       cmdline.txt.usb  COPYING.linux  fixup.dat     fixup_x.dat  kernel7.img  LICENCE.broadcom  os_config.json  start_cd.elf  start.elf
    bcm2708-rpi-b.dtb    bcm2708-rpi-cm.dtb      bcm2710-rpi-3-b.dtb  bootcode.bin         cmdline.txt.orig  config.txt       fixup_cd.dat   fixup_db.dat  issue.txt    kernel.img   LICENSE.oracle    overlays        start_db.elf  start_x.elf
3) my cmdline.txt in the sd card boot partition

Code: Select all

  pi@raspberrypi:~ $ cat /media/sdboot/cmdline.txt
    dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=PARTUUID=712ae4a6-73d8-4aca-9ec6-b6e507c95f74 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait splash plymouth.ignore-serial-consoles max_usb_current=1

wh7qq
Posts: 1231
Joined: Thu Oct 09, 2014 2:50 am

Re: raspberrypi-bootloader error during apt-get upgrade after restore form backup, how to fix?

Sat Jan 19, 2019 6:34 pm

Probably the least painful approach is to save your existing SD card as is and get a fresh one and burn the most recent OS on it. You an then transfer your important data to the new card. It sounds like you have a mismatch between your backups and the upgrades and if the versions don't all match up perfectly, the result is a painful mess. Best just to go with an all new distro rather than trying to salvage the old one.

Return to “Troubleshooting”