Various devices do not load after the update

Hi.

Over the past year, the following models of my devices failed to boot at least once after updating:

  • Hap ac


  • Hap ac lite


  • hAP ac 2


  • LHG LTE


  • LHGG LTE6


  • Chateau LTE6

After booting via netinstall everything works.
Some of these devices are not nearby - and this process caused a lot of pain.

What could be the problem, how to avoid it?
Please answer and advise.

I use the following script for automatic updating. I call it twice, to update the OS and firmware.

:local telegramBotToken "XXX"
:local telegramChatID "XXX"
:global updChannel "stable"
/system package update
set channel=$updChannel
check-for-updates
:delay 15s;
:if ([get installed-version] != [get latest-version]) do={
   :local telegramMessage "$[/system identity get name]: Upgrading RouterOS on router, from $[/system package update get installed-version] to $[/system package update get latest-version] (channel:$[/system package update get channel])"
   /tool fetch http-method=get url="https://api.telegram.org/bot$telegramBotToken/sendMessage?chat_id=$telegramChatID&text=$telegramMessage&parse_mode=html&disable_web_page_preview=True"
   :log info ("Upgrading RouterOS on router $[/system identity get name] from $[/system package update get installed-version] to $[/system package update get latest-version] (channel:$[/system package update get channel])")
   :delay 15s;
   install
} else={
   :log info ("No RouterOS upgrade found, checking for HW upgrade...")
   /system routerboard
   :if ([get current-firmware] != [get upgrade-firmware]) do={
      :local telegramMessage "$[/system identity get name]: Upgrading firmware on router, from $[/system routerboard get current-firmware] to $[/system routerboard get upgrade-firmware]"
      /tool fetch http-method=get url="https://api.telegram.org/bot$telegramBotToken/sendMessage?chat_id=$telegramChatID&text=$telegramMessage&parse_mode=html&disable_web_page_preview=True"
      :log info ("Upgrading firmware on router $[/system identity get name] from $[/system routerboard get current-firmware] to $[/system routerboard get upgrade-firmware]")
      :delay 15s;
      upgrade
      :delay 180s;
      /system reboot
   } else={
      :log info ("No Router HW upgrade found")
   }
}

Not really an answer, but rather observation: all the mentioned devices have only 16MB flash. Which is tight for recent ROS versions (specially v7). So perhaps your script should check free flash space and bail out if free space is less than, say, 600kB (or something, I’ve no idea what would be safe margin). And perhaps the same check shoukd be performed before issuing reboot after allegedly successful upgrade (you actually should check logs before assuming upgrade went fine).

Thanks. Will check and try.

I get free space this way.
Can anyone recommend a more elegant way, without going overboard?

:local freeSpace 0
:local resources [/system resource print as-value];
:foreach key,value in=$resources do={
    if ($key = "free-hdd-space") do={
        :set $freeSpace ($value / (1024 * 1024))
    }
}
/log info $freeSpace

And please tell me where and how to find out the required space for the update RouterOS 7?

AFAIK there is no official information about it. ROS updater is supposed to check free space before applying update … but from forum reports one can get a feeling that it’s not conservative enough and sometimes goes ahead while it should bail out. Some reports showed that 7.16 consumes anywhere between 50kB and 75kB more than 7.15.3 … and I’m not sure if ROS updater actually takes this into account.

Okay. Thank you.
And how do you know the total space needed for the update?
Or at least approximately with a reserve - how much space is needed?

Due to lack of better info … by experimenting and observation.

Thank you.
I added a free space check to the script.
So far 3 MB.
I suspect that this will be a different value for different platforms.

:local identityName [/system identity get name]
:local telegramMessage false
:local telegramBotToken "XXX"
:local telegramChatID "XXX"
:local currentFreeSpace 0
:local needFreeSpaceMB 3
:local resources [/system resource print as-value];
:foreach key,value in=$resources do={
   if ($key = "free-hdd-space") do={
     :set $currentFreeSpace ($value / (1024 * 1024))
   }
}
if ($currentFreeSpace >= $needFreeSpaceMB) do={
   :global updChannel "stable"
   /system package update
   set channel=$updChannel
   check-for-updates
   :delay 15s;
   :if ([get installed-version] != [get latest-version]) do={
      :local telegramMessage "$identityName: Upgrading RouterOS on router, from $[/system package update get installed-version] to $[/system package update get latest-version] (channel:$[/system package update get channel])"
      /tool fetch http-method=get url="https://api.telegram.org/bot$telegramBotToken/sendMessage?chat_id=$telegramChatID&text=$telegramMessage&parse_mode=html&disable_web_page_preview=True"
      /log info $telegramMessage
      :delay 15s;
      install
   } else {
      /log info "No RouterOS upgrade found, checking for HW upgrade..."
      /system routerboard
      :if ([get current-firmware] != [get upgrade-firmware]) do={
         :local telegramMessage "$identityName: Upgrading firmware on router, from $[/system routerboard get current-firmware] to $[/system routerboard get upgrade-firmware]"
         /tool fetch http-method=get url="https://api.telegram.org/bot$telegramBotToken/sendMessage?chat_id=$telegramChatID&text=$telegramMessage&parse_mode=html&disable_web_page_preview=True"
         /log info $telegramMessage
         :delay 15s;
         upgrade
         :delay 180s;
         /system reboot
      } else {
         /log info "No Router HW upgrade found"
      }
   }
} else {
   :local telegramMessage "$identityName: Not enough free space for the update!"
   /tool fetch http-method=get url="https://api.telegram.org/bot$telegramBotToken/sendMessage?chat_id=$telegramChatID&text=$telegramMessage&parse_mode=html&disable_web_page_preview=True"
   /log error $telegramMessage
}