Community discussions

MikroTik App
 
semaja2
newbie
Topic Author
Posts: 39
Joined: Wed Sep 08, 2021 3:50 pm

GUIDE: Running Netinstall Server on a Tik

Mon Sep 26, 2022 12:40 pm

Hi All,

Wasn't sure where to best post this, but hopefully someone will find use of it :)

With the implementation of containers in ROSv7 it opened a whole world of abilities for a Tik, and for anyone that needs to do bulk netinstalls or remotely perform a netinstall in the field (eg. a Tik AP connected to a RB5009) then this might just be useful

Essentially I have bundled the Linux netinstall-cli into a container along with qemu-i386 to allow running the binary on alternate CPUs (eg. ARM/ARM64)

In my testing I was able to do this from a RB4011, and plan to test further with other devices that are capable of running containers (eg. RB5009/NetPower etc)

https://hub.docker.com/r/semaja2/mikrotik-netinstall

Steps
The below steps will create a container linking to ether5, and set netinstall to load the routeros-mipsbe-6.48.6.npk NPK file
  • Enable containers and install package (refer wiki)
  • Create folder images under disk1
  • Upload npk files to images folder
  • Create veth interface
    /interface veth add address=192.168.88.6/24 gateway=192.168.88.1 name=veth1
  • Create bridge
    /interface bridge add name=dockers
  • Add veth and physical port to bridge
    /interface bridge port add bridge=dockers interface=veth1/interface bridge port add bridge=dockers interface=ether5
  • Create mount to contain npk files
    /container mounts add dst=/app/images name=images src=/disk1/images
  • Create enviroment set, and specify npk file to use
    /container envs add key=NETINSTALL_NPK name=NETINSTALL value=routeros-mipsbe-6.48.6.npk
  • Create container
    /container add remote-image=semaja2/mikrotik-netinstall:latest envlist=NETINSTALL interface=veth1 logging=yes mounts=images workdir=/app
After starting the container you can monitor via the logs of the host Tik
[admin@MikroTik] /container> /log/print where topics~"container"
18:42:50 container,info,debug Version: 7.5(2022-08-30 09:34:59)
18:42:50 container,info,debug client: DC:2C:6E:68:XX:XX
18:42:50 container,info,debug sendFile 4877676
18:43:17 container,info,debug Using server IP: 192.168.88.6
18:43:17 container,info,debug Use Netmask: 255.255.255.0
18:43:17 container,info,debug Starting PXE server
18:43:17 container,info,debug Waiting for RouterBOARD...
18:43:17 container,info,debug Discovered RouterBOARD...
18:43:17 container,info,debug Formatting...
18:43:17 container,info,debug Sending package routeros-mipsbe-6.48.6.npk ...
18:43:17 container,info,debug Ready for reboot...
18:43:17 container,info,debug Sent reboot command
Last edited by semaja2 on Mon Sep 26, 2022 3:20 pm, edited 1 time in total.
 
User avatar
Znevna
Forum Guru
Forum Guru
Posts: 1347
Joined: Mon Sep 23, 2019 1:04 pm

Re: GUIDE: Running Netinstall Server on a Tik

Mon Sep 26, 2022 3:11 pm

Congrats! but the link posted right before the Steps section asks for a login for some reason.
This works: https://hub.docker.com/r/semaja2/mikrotik-netinstall
 
semaja2
newbie
Topic Author
Posts: 39
Joined: Wed Sep 08, 2021 3:50 pm

Re: GUIDE: Running Netinstall Server on a Tik

Mon Sep 26, 2022 3:21 pm

Congrats! but the link posted right before the Steps section asks for a login for some reason.
This works: https://hub.docker.com/r/semaja2/mikrotik-netinstall
Thanks for that, I have updated the post, looks like I copied the management URL
 
tangent
Forum Guru
Forum Guru
Posts: 1351
Joined: Thu Jul 01, 2021 3:15 pm
Contact:

Re: GUIDE: Running Netinstall Server on a Tik

Thu Sep 29, 2022 2:37 am

Nice; now we just need a native ARM build of netinstall from MikroTik. (Request already put in as SUP-89685, but reposting to add more votes might help.)

Instead of passing the name of a file in as an environment variable and mapping the storage for same in from a volume, I think it would be simpler to set the container image up generically, looking for something like "routeros.npk". Then you have the end user create their own local container images using yours as a base:

FROM semaja2/mikrotik-netinstall:latest
COPY routeros-mipsbe-6.48.6.npk /routeros.npk

That gets you a local image which you export to a tarball and scp up to the ARM router and start without any parameters, because everything's baked inside. If you need to change the version of RouterOS, you change the Dockerfile, rebuild, and redeploy.
 
semaja2
newbie
Topic Author
Posts: 39
Joined: Wed Sep 08, 2021 3:50 pm

Re: GUIDE: Running Netinstall Server on a Tik

Thu Sep 29, 2022 6:35 am

From my testing there is actually no need for a native ARM build (besides being a nice to have)

This container actually uses qemu to run the x86 code on both ARM and ARM64 platforms (testing was done on a RB4011)

From an image perspective, I originally included the npk files but due to limited space on the tiks I broke this out into a seperate container (mikrotik-netinstall-bundle)

So if you have lots of storage, you can pull semaja2/mikrotik-netinstall-bundle:7.5-6.48.6 which will run Netinstall v7.5 and have all the npks for RouterOS 6.48.6

However what you suggested is a great way around it as well, however you would want to copy the npk to the /app/images path as this is where the container expects them
 
tangent
Forum Guru
Forum Guru
Posts: 1351
Joined: Thu Jul 01, 2021 3:15 pm
Contact:

Re: GUIDE: Running Netinstall Server on a Tik

Thu Sep 29, 2022 8:26 am

there is actually no need for a native ARM build

…says the guy with a gig of flash. 🤓

Those wanting containers for several CPU types on smaller routers will appreciate not having to pay the cost of a CPU emulator.
 
User avatar
Znevna
Forum Guru
Forum Guru
Posts: 1347
Joined: Mon Sep 23, 2019 1:04 pm

Re: GUIDE: Running Netinstall Server on a Tik

Thu Sep 29, 2022 8:36 am

Nobody sane runs containers on internal flash.
 
holvoetn
Forum Guru
Forum Guru
Posts: 5403
Joined: Tue Apr 13, 2021 2:14 am
Location: Belgium

Re: GUIDE: Running Netinstall Server on a Tik

Thu Sep 29, 2022 8:45 am

While you do have a valid point for some remote contexts it may be the only alternative (running from flash during this "rescue" operation) to recover a neighboring device.
Or get in the car and be away for most of the day (or longer).
 
semaja2
newbie
Topic Author
Posts: 39
Joined: Wed Sep 08, 2021 3:50 pm

Re: GUIDE: Running Netinstall Server on a Tik

Thu Sep 29, 2022 8:56 am

Those wanting containers for several CPU types on smaller routers will appreciate not having to pay the cost of a CPU emulator.
I will let you now how I go forcing it into smaller devices, but largely anything with an ARM CPU will be fine doing this x86 emulation from a CPU perspective, the netinstall process is not very CPU intensive

From a storage perspective I did try to strip out some parts of the container, but if anyone has recommendations on how to reduce the footprint further I am happy to take advice or pull requests

For a break down:
  • Netinstall binary = 32.98MB
  • qemu binary = 4.25MB (I might be able to optimise this more)
  • debian base image = 28.66MB (maybe another base container could reduce this)
 
tangent
Forum Guru
Forum Guru
Posts: 1351
Joined: Thu Jul 01, 2021 3:15 pm
Contact:

Re: GUIDE: Running Netinstall Server on a Tik

Thu Sep 29, 2022 9:01 am

Nobody sane runs containers on internal flash.

This one is functionally read-only. It shouldn’t materially shorten the lifetime of the host router.
 
semaja2
newbie
Topic Author
Posts: 39
Joined: Wed Sep 08, 2021 3:50 pm

Re: GUIDE: Running Netinstall Server on a Tik

Thu Sep 29, 2022 11:31 am

After a bit of early testing, we now have the base container down to 5.35MB compressed (including the qemu part) so after we add netinstall the container comes to 38.72MB compressed

As a result I am successfully able to run the netinstall container on a Netpower16P :shock: and perform a netinstall onto a RB2011

However this did come with various limitations (eg. nothing could be in the files) so once it was loaded, I could then add the npk file

This version is available for testing if you want to try as well, simply use semaja2/mikrotik-netinstall:development instead of latest
 
User avatar
Znevna
Forum Guru
Forum Guru
Posts: 1347
Joined: Mon Sep 23, 2019 1:04 pm

Re: GUIDE: Running Netinstall Server on a Tik

Thu Sep 29, 2022 12:38 pm

I've read a bit about "distroless" containers but I have no experience yet with containers sadly outside my encounter with MikroTik containers and the few containers I've tested from docker hub.
 
semaja2
newbie
Topic Author
Posts: 39
Joined: Wed Sep 08, 2021 3:50 pm

Re: GUIDE: Running Netinstall Server on a Tik

Thu Sep 29, 2022 12:42 pm

There is probably potential for further optimisations, however we are reaching a point where there is little gains left (we talking 6MB from the distro now) the biggest space consumer is the actual net install binary at 50MB plus a npk file which is usually 10-15MB

I would say if you have a device with minimum 256MB RAM the new version is possible, the only way to get around less ram is for the tik to have proper storage of some sort (I’ll see if I can find my self a tik with 128MB RAM and a USB port)
 
96robert9
just joined
Posts: 1
Joined: Mon Dec 05, 2022 3:11 pm

Re: GUIDE: Running Netinstall Server on a Tik

Mon Dec 05, 2022 3:18 pm

Hello,

i follow the instalation guide but with no sucses...

I alwais get :
importing remote image: semaja2/mikrotik-netinstall, tag: latest
error parsing manifests

Setup:
Mikrotik RB4011GS+
ROS: 7.6 (firmware 7.6)

Also in tutorial there is mising Registry URL.

Thanks.
 
semaja2
newbie
Topic Author
Posts: 39
Joined: Wed Sep 08, 2021 3:50 pm

Re: GUIDE: Running Netinstall Server on a Tik

Sat Dec 10, 2022 1:26 pm

Can you post the output of the routers logs? I just did a test on a RB4011 with 7.6 and it worked without issue, potentially you ran into space issue?

The registry URL was not included as its assumed the base config from the MikroTik documentation was followed
/container/config/set registry-url=https://registry-1.docker.io 
https://help.mikrotik.com/docs/display/ROS/Container
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3250
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: GUIDE: Running Netinstall Server on a Tik

Thu Feb 09, 2023 8:49 pm

Can you share the Dockerfile file you originally used to build this?
 
tangent
Forum Guru
Forum Guru
Posts: 1351
Joined: Thu Jul 01, 2021 3:15 pm
Contact:

Re: GUIDE: Running Netinstall Server on a Tik

Thu Feb 09, 2023 8:56 pm

 
User avatar
Larsa
Forum Guru
Forum Guru
Posts: 1041
Joined: Sat Aug 29, 2015 7:40 pm
Location: The North Pole, Santa's Workshop

Re: GUIDE: Running Netinstall Server on a Tik

Thu Feb 09, 2023 9:33 pm

Thanks for the pointer, was just about to ask for it too!
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3250
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: GUIDE: Running Netinstall Server on a Tik

Thu Feb 09, 2023 10:46 pm

Very cleaver approach using QEMU. Yeah totally works on RB5009 at least.

Although using newer ramdisk feature might be good in instructions. Or I guess with ROSE, the RouterOS images could be an NFS mount now too.
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 19099
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: GUIDE: Running Netinstall Server on a Tik

Thu Feb 09, 2023 11:13 pm

Nobody sane runs containers on internal flash.
If you dont have an arm64 device, MT is ready to sell you one, so you have to ditch all other MT products.....................
Everything is geared towards screwing anyone else...............

In terms of limitations.......................
Another reason to put zerotrustcloudflare tunnel as an option package for ALL devices.
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3250
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: GUIDE: Running Netinstall Server on a Tik

Fri Feb 10, 2023 12:12 am

When life gives you lemons, you make containers.
 
r00t
Long time Member
Long time Member
Posts: 672
Joined: Tue Nov 28, 2017 2:14 am

Re: GUIDE: Running Netinstall Server on a Tik

Fri Feb 10, 2023 3:00 am

Clever workaround using container with QEMU!
But it's sad to know that if Mikrotik really wanted, they could just release <100kb .npk package with netinstall server for pretty much any architecture out there...



but they don't
 
semaja2
newbie
Topic Author
Posts: 39
Joined: Wed Sep 08, 2021 3:50 pm

Re: GUIDE: Running Netinstall Server on a Tik

Fri Feb 10, 2023 3:03 am

Having netinstall as a npk would be a dream, but also I suppose getting ROSv7 actually stable for real usage is still a priority they should focus on... (BGP :vomit:)

If there is serious interest in this container I will look to maintain and update it so it works better with the newer container features etc


PS. Running this in flash is unlikely to cause serious damage to the flash since it is largely a read only container, and would generally be run adhoc as needed (most people enable graphing and burn more flash writes then this could)
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: GUIDE: Running Netinstall Server on a Tik

Mon Feb 27, 2023 1:10 pm

 
holvoetn
Forum Guru
Forum Guru
Posts: 5403
Joined: Tue Apr 13, 2021 2:14 am
Location: Belgium

Re: GUIDE: Running Netinstall Server on a Tik

Thu Mar 14, 2024 11:57 pm

Follow up on this ...

How to provide 2 npk files via environment variable ?
Trying to netinstall mAP Lite (lab test) using container on AX3. routeros passes but how to get the required wireless package as well transferred ?
Both files are present in images

Simply adding both files with a space (there it is again :o ) in ENV doesn't work.
 
tangent
Forum Guru
Forum Guru
Posts: 1351
Joined: Thu Jul 01, 2021 3:15 pm
Contact:

Re: GUIDE: Running Netinstall Server on a Tik

Fri Mar 15, 2024 5:29 am

Unlike Docker, RouterOS’ container feature doesn’t have a shell to preinterpret the command line, breaking it up by spaces, modulo quoting rules and such.

You’re going to need to rebuild the container from source, which then lets you pass the list of NPKs as an array.

Alternately, the container could be built with a shell inside to expand a glob pattern like /mount/point/*.npk so that whatever list of files are present in the volume mounted in gets sent to the other router by netinstall.
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3250
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: GUIDE: Running Netinstall Server on a Tik

Fri Mar 15, 2024 5:36 am

Simply adding both files with a space (there it is again :o ) in ENV doesn't work.
Assuming the extra-package or wifi-qcom-* are in /app/images... You should be able to cheat with a space, but you'd need the full path.
so
NETINSTALL_NPK = routeros-arm-7.15beta6.npk /app/images/wifi-qcom....npk

The reason that should work is this code that enforce the single NPK, but if you add the /app/images path to other packages AFTER just the main package name... it should work.
if [[ $(uname -m) =~ (i[1-6]86|amd64) ]]; then
    exec /app/netinstall-cli $NETINSTALL_ARGS "-a" $NETINSTALL_ADDR /app/images/$NETINSTALL_NPK
else
    exec /app/qemu-i386-static /app/netinstall-cli $NETINSTALL_ARGS "-a" $NETINSTALL_ADDR /app/images/$NETINSTALL_NPK
fi
*You can edit the entrypoint.sh inside the container is likely another approach using /container/shell (likely changing entrypoint to "/bin/tail -f /dev/null") & manually edit the netinstall-cli command line above to do what you want with/without the ENV vars. This isn't a long term fix, since rebuilding as @tangent notes is best.
 
tangent
Forum Guru
Forum Guru
Posts: 1351
Joined: Thu Jul 01, 2021 3:15 pm
Contact:

Re: GUIDE: Running Netinstall Server on a Tik

Fri Mar 15, 2024 5:55 am

It's probably best if someone — ideally, @semaja2; I have no desire to take over this container's maintenance — rebuilt this container along the glob pattern scheme I suggest, since ROS 7 does seem to be increasingly broken back up again. Of my several MT devices here at home, half run with at least two NPKs.
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3250
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: GUIDE: Running Netinstall Server on a Tik

Fri Mar 15, 2024 7:00 am

rebuilt this container along the glob pattern scheme I suggest, since ROS 7 does seem to be increasingly broken back up again.
Yeah, the multiple package is a problem in publish image, esp after the "wireless split". I use this container, so approach with QEMU is great and works fine on ARM RB1100AHx4.

But I do modify it so the NETINSTALL_NPK takes an array, but again you have to have to Docker tool chain. And it's a process to go from some Dockerfile mods to a working on RouterOS. Before even getting to netinstall part. ;)
#!/bin/bash
set -e
NETINSTALL_ADDR="${NETINSTALL_ADDR:="192.168.88.1"}"
ROSARCH="${NETINSTALL_ARCH:="arm"}"
PKGS="${NETINSTALL_NPK:="routeros"}"
ROSVER="${NETINSTALL_VER:="7.12.1"}"
NPKLIST=$(for i in $(ls `for p in $PKGS; do echo "/app/images/$p-$ROSVER-$ROSARCH.npk"; done`); do echo $i; done)
NPKARG="${NPKLIST//$'\n'/ }"
echo $PKGS
echo $NPKLIST
echo $NPKARG
exec /app/qemu-i386-static /app/netinstall-cli -b -r -a $NETINSTALL_ADDR $NPKARG
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3250
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: GUIDE: Running Netinstall Server on a Tik

Fri Mar 15, 2024 7:11 am

; I have no desire to take over this container's maintenance
Now I do think you can use the container as-is if you do something like this:
/container env set key=NETINSTALL_NPK name=netinstall value="routeros-7.15beta6-arm.npk /app/images/zerotier-arm-7.15beta6.npk /app/images/wifi-qcom-ac-7.15beta6-arm.npk"

Spaces should be allowed in the env settings. It just netinstall-cli needs to the full path for the packages. The first one is apended to "/app/image" in the built-in script. But since that's the last arg, if you add more to NETINSTALL_NPK, with spaces, and the need full path... this should work from DockerHub version.
 
tangent
Forum Guru
Forum Guru
Posts: 1351
Joined: Thu Jul 01, 2021 3:15 pm
Contact:

Re: GUIDE: Running Netinstall Server on a Tik

Fri Mar 15, 2024 7:42 am

This is what I meant about there being no shell to premasticate the command line for you. For containers that don't pass CMD or ENTRYPOINT through a shell, this gets sent as a single string to the container's entrypoint.

This container does happen to pass things through a shell, specifically via its entrypoint.sh script, but study what happens when you expand $NETINSTALL_NPK.

I don't see how you can do it with NETINSTALL_ARGS, either, unless netinstall is uncommonly tolerant about the ordering of flags vs arguments in its command line parser.

No, it is best if this container is rebuilt to explicitly allow this, as a first-class feature.
 
holvoetn
Forum Guru
Forum Guru
Posts: 5403
Joined: Tue Apr 13, 2021 2:14 am
Location: Belgium

Re: GUIDE: Running Netinstall Server on a Tik

Fri Mar 15, 2024 8:15 am

I see something resembling an error but it doesn't really say so.
Then I see version 7.5 (netinstall version used for this container ?)
But nothing further. No waiting. Nada. Or is it waiting there ?? I will check futher later on. First some work to do :lol:
/container envs
add key=NETINSTALL_NPK name=NETINSTALL value="routeros-7.15beta6-mipsbe.npk /app/images/wireless-7.15beta6-mipsbe.npk"
 07:07:26 container,info,debug /entrypoint.sh: line 8: [: /app/images/routeros-7.15beta6-mipsbe.npk: binary operator expected
 07:07:26 container,info,debug Version: 7.5(2022-08-30 09:34:59)
I was hoping this container approach could solve my problem of having to keep that old 2008 laptop around for my netinstall actions... but I don't have the experience to rebuild this whole container thing from scratch.
 
tangent
Forum Guru
Forum Guru
Posts: 1351
Joined: Thu Jul 01, 2021 3:15 pm
Contact:

Re: GUIDE: Running Netinstall Server on a Tik

Fri Mar 15, 2024 8:45 am

Then I see version 7.5 (netinstall version used for this container ?)

Yup. The container hasn't been updated since September 2022. One must wonder if @semaja2 is even among us any more.

 07:07:26 container,info,debug /entrypoint.sh: line 8: [: /app/images/routeros-7.15beta6-mipsbe.npk: binary operator expected

This is the sort of thing I meant in my reply to @Amm0. You can't have multiple file names on the right side of the "test -f" expression on line 8 in entrypoint.sh.

I don't have the experience to rebuild this whole container thing from scratch.

It's not super-difficult, if your needs are simple. Edit Dockerfile to suit — including updating the "7.5" version number at the top — and entrypoint.sh, then say "docker build ."

The pool is deep, if you want to dive in. I normally wrap things up with a Makefile to let me say things like "make image" instead.
 
semaja2
newbie
Topic Author
Posts: 39
Joined: Wed Sep 08, 2021 3:50 pm

Re: GUIDE: Running Netinstall Server on a Tik

Fri Mar 15, 2024 10:52 am

I am still around, and suprised to see the thread spring to life as I figured it wasn’t of interest to many others

I’ll try to dig up the project and update to latest version and see if I can get it to just add every npk from the folder to simplify
 
tangent
Forum Guru
Forum Guru
Posts: 1351
Joined: Thu Jul 01, 2021 3:15 pm
Contact:

Re: GUIDE: Running Netinstall Server on a Tik

Fri Mar 15, 2024 11:57 am

It's your most popular repo on Docker Hub, with 306 pulls. Those stats aren't unique users, but clearly someone cares about what you've produced.
 
semaja2
newbie
Topic Author
Posts: 39
Joined: Wed Sep 08, 2021 3:50 pm

Re: GUIDE: Running Netinstall Server on a Tik

Sun Mar 17, 2024 9:39 am

Fair point I had not looked at the pull numbers, also thought netinstall had been integrated into ROS by now :P

I have built a new version of the container under semaja2/mikrotik-netinstall:dev which will work with both old and new methods

I do not have my test environment setup anymore, so if anyone can test that would be great and Ill replace the latest tag with it :) hopefully

Old:
- Configure the `NETINSTALL_NPK` environment variable with the name of the NPK to install

New:
- Do not set NETINSTALL_NPK
- Requires NETINSTALL_ARCH to be set (eg. arm64)
- Requires NETINSTALL_VER to be set (eg. 7.14.1)
- Set NETINSTALL_PKGS to a list of packages to install (eg. "routeros container etc") if not set will default to routeros

Additionally you can simply define NETINSTALL_ARGS now to include other options such as "-b" to remove branding "-r" to reset config "-s <script>" to load a script etc
 
holvoetn
Forum Guru
Forum Guru
Posts: 5403
Joined: Tue Apr 13, 2021 2:14 am
Location: Belgium

Re: GUIDE: Running Netinstall Server on a Tik

Sun Mar 17, 2024 11:02 am

Awesome !!

Quick test from AX3 with container package and external USB to mAP Lite, it works ! 8)
/container mounts
add dst=/app/images name=images src=/usb1/images
/container
add envlist=NETINSTALL interface=veth1 logging=yes mounts=images root-dir=usb1/netinstall workdir=/app
/container config
set registry-url=https://registry-1.docker.io tmpdir=usb1/pull
/container envs
add key=NETINSTALL_ARCH name=NETINSTALL value=mipsbe
add key=NETINSTALL_VER name=NETINSTALL value=7.15beta6
add key=NETINSTALL_PKGS name=NETINSTALL value="routeros wireless"
add key=NETINSTALL_ARGS name=NETINSTALL value=-r
Comments/clarifications:
- NETINSTALL_ARCH = the architecture TO BE netinstalled
- NETINSTALL_VER = version TO BE netinstalled
- NETINSTALL_PKGS = packages without any bloat, versions, whatever...
because you construct your file names from these parameters ... (2 tries before I saw in the logs what was wrong on my end :lol: )

I even used NETINSTALL_ARGS with -r to test the resetting part, works as well (could also see from log the correct command was being used).

Personal remark: I would not do that constructing of filename, tempting as it may be. Use the full filenames as given.
If for some reason (as already has been the case in the past) Mikrotik decides to change the naming convention of those files, we're stuck again because of that part.
Couldn't get passed that now since you do expect values in those arguments.

But ... VERY good job, sir !!

PS I see now the container setup itself is not part of that export ? Has that always been the case ? Or is it a bug in 7.15b6 ?
 
User avatar
patrikg
Member Candidate
Member Candidate
Posts: 224
Joined: Thu Feb 07, 2013 6:38 pm
Location: Stockholm, Sweden

Re: GUIDE: Running Netinstall Server on a Tik

Sun Mar 17, 2024 11:15 am

How about to check to Mikrotik the version.

Like something like this and download the npk automatically.
#!/bin/bash
echo Mikrotik Versions of firmware.
echo Ver 6
echo long-term = $(curl -s http://upgrade.mikrotik.com/routeros/NEWEST6.long-term | cut -f1 -d' ')
echo stable = $(curl -s http://upgrade.mikrotik.com/routeros/NEWEST6.stable | cut -f1 -d' ')
echo testing = $(curl -s http://upgrade.mikrotik.com/routeros/NEWEST6.testing | cut -f1 -d' ')
echo development = $(curl -s http://upgrade.mikrotik.com/routeros/NEWEST6.development | cut -f1 -d' ')
echo
echo Ver 7
echo long-term = $(curl -s http://upgrade.mikrotik.com/routeros/NEWEST7.long-term | cut -f1 -d' ')
echo stable = $(curl -s http://upgrade.mikrotik.com/routeros/NEWEST7.stable | cut -f1 -d' ')
echo testing = $(curl -s http://upgrade.mikrotik.com/routeros/NEWEST7.testing | cut -f1 -d' ')
echo development = $(curl -s http://upgrade.mikrotik.com/routeros/NEWEST7.development | cut -f1 -d' ')
echo
echo "Ver > 7.12"
echo long-term = $(curl -s http://upgrade.mikrotik.com/routeros/NEWESTa7.long-term | cut -f1 -d' ')
echo stable = $(curl -s http://upgrade.mikrotik.com/routeros/NEWESTa7.stable | cut -f1 -d' ')
echo testing = $(curl -s http://upgrade.mikrotik.com/routeros/NEWESTa7.testing | cut -f1 -d' ')
echo development = $(curl -s http://upgrade.mikrotik.com/routeros/NEWESTa7.development | cut -f1 -d' ')
Last edited by patrikg on Sun Mar 17, 2024 12:20 pm, edited 3 times in total.
 
holvoetn
Forum Guru
Forum Guru
Posts: 5403
Joined: Tue Apr 13, 2021 2:14 am
Location: Belgium

Re: GUIDE: Running Netinstall Server on a Tik

Sun Mar 17, 2024 11:17 am

My view:
like the real netinstall where you need to specify which version to use, I wouldn't automate it.
It's the user's responsibility to provide the correct version to be used.
Sometimes you may have to use other versions then latest, stable, latest testing, ...
 
semaja2
newbie
Topic Author
Posts: 39
Joined: Wed Sep 08, 2021 3:50 pm

Re: GUIDE: Running Netinstall Server on a Tik

Sun Mar 17, 2024 11:24 am

Part of the issue with downloading the images during runtime would be generally the network the container is attached to would be isolated and only directly connected to the target device, as such would require reasonable amount of config to ensure it could actually download the images.

The current method should allow you to have a large folder of npk files, and simply adjust the variables as needed

In theory someone might be able to wrap up a nice RouterOS script to extract the variables, and download the npk files at the RouterOS level instead?

The source code for the container is also available at https://github.com/semaja2/mikrotik-netinstall so happy if you want to fork to add extra features, or if there is a bug/limit can also send a pull request for me to review
 
semaja2
newbie
Topic Author
Posts: 39
Joined: Wed Sep 08, 2021 3:50 pm

Re: GUIDE: Running Netinstall Server on a Tik

Sun Mar 17, 2024 11:32 am

Quick update, I noticed a huge container size increase with the new version, appears the linux netinstall binary itself is quite large now days, so have released some older versions of netinstall

Eg. 7.14.1 is 55.7MB, 6.49.13 is 36.8MB

The older version may be more useful to those running on very limited disk space, however they may need further testing
 
User avatar
patrikg
Member Candidate
Member Candidate
Posts: 224
Joined: Thu Feb 07, 2013 6:38 pm
Location: Stockholm, Sweden

Re: GUIDE: Running Netinstall Server on a Tik

Sun Mar 17, 2024 12:30 pm

Quick update, I noticed a huge container size increase with the new version, appears the linux netinstall binary itself is quite large now days, so have released some older versions of netinstall

Eg. 7.14.1 is 55.7MB, 6.49.13 is 36.8MB
Have you tested to upx the netinstall-cli ?
To shrink the size down before deploy into container.
Trying that now to see how many bytes to shrink down in total.

Funny facts:
-rwxr-xr-x 1 patrik users 55748164  8 mar 14.35 netinstall-cli
upx --best netinstall-cli
-rwxr-xr-x 1 patrik users 55667668  8 mar 14.35 netinstall-cli
55748164 ->  55667668   99.86%   linux/i386    netinstall-cli 
Last edited by patrikg on Sun Mar 17, 2024 1:15 pm, edited 1 time in total.
 
tangent
Forum Guru
Forum Guru
Posts: 1351
Joined: Thu Jul 01, 2021 3:15 pm
Contact:

Re: GUIDE: Running Netinstall Server on a Tik

Sun Mar 17, 2024 1:07 pm

The last time I tried UPX in a container, I ran into compatibility errors when doing cross-CPU testing like running the ARM version on x86_64 under Docker, which uses QEMU under the hood.

This container does the opposite, running x86_64 netinstall on ARM under QEMU, but is that double emulation when testing under Docker? What about testing on ARM desktop platforms like a Pi or an M1?

Plus, container images are themselves compressed on Docker Hub and in transit. The only savings is in tarball form and in a local containerd type registry.

Bottom line, I found UPX not worth the hassle.
 
semaja2
newbie
Topic Author
Posts: 39
Joined: Wed Sep 08, 2021 3:50 pm

Re: GUIDE: Running Netinstall Server on a Tik

Sun Mar 17, 2024 1:13 pm

I did a quick test using "upx -9" and it shrank by about 3MB, so not really worth the hassle/risk, if it could save 50% then I would consider making a special upx variant for those in desperate need of disk space
 
User avatar
patrikg
Member Candidate
Member Candidate
Posts: 224
Joined: Thu Feb 07, 2013 6:38 pm
Location: Stockholm, Sweden

Re: GUIDE: Running Netinstall Server on a Tik

Sun Mar 17, 2024 1:19 pm

I did the same thing and with --best but that also don't shrink the size down very much.
But i see very useful using upx with go compiled code. like gitea.
 
holvoetn
Forum Guru
Forum Guru
Posts: 5403
Joined: Tue Apr 13, 2021 2:14 am
Location: Belgium

Re: GUIDE: Running Netinstall Server on a Tik

Sun Mar 17, 2024 1:51 pm

Leave it like it is please.
It works :lol:
 
kevinds
Long time Member
Long time Member
Posts: 631
Joined: Wed Jan 14, 2015 8:41 am

Re: GUIDE: Running Netinstall Server on a Tik

Mon Mar 18, 2024 2:09 pm

Leave it like it is please.
Wouldn't something pynetinstall work a lot better? No need for x86 emulation
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3250
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: GUIDE: Running Netinstall Server on a Tik

Mon Mar 18, 2024 4:33 pm

Leave it like it is please.
Wouldn't something pynetinstall work a lot better? No need for x86 emulation
I'm not sure about that. While X86 emulation has some cost, using the "real" netinstall from Mikrotik has some benefits.

Since pynetinstall reverse-engineered netinstall's protocol, if Mikrotik changes something in netinstall.... pynetinstall have be modified. With QEMU emulation and docker, it just rebuilding the image with new version of netinstall (which theoretically could be automated by GitHub)

Also...I'm not sure performance is a big concern too, if it takes say 5 vs 10 seconds to start...not sure that matter in the overall steps/waiting requires for a netinstall copy/reboot. Plus I'm not sure emulated X86 would be that much slower than loading the python interpreter.

To me, pynetinstall seems more useful if your were already script other parts of provisioning routers/network in python.
 
kevinds
Long time Member
Long time Member
Posts: 631
Joined: Wed Jan 14, 2015 8:41 am

Re: GUIDE: Running Netinstall Server on a Tik

Mon Mar 18, 2024 4:38 pm

Since pynetinstall reverse-engineered netinstall's protocol, if Mikrotik changes something in netinstall.... pynetinstall have be modified. With QEMU emulation and docker, it just rebuilding the image with new version of netinstall (which theoretically could be automated by GitHub)
That would involve big changes to the bootloader.. Even if changes are made, until the bootloader is updated on the board you are reinstalling, there are no changes.

As for the official netinstall application, it has been my experience that not all versions work properly/correctly anyways.

But yeah, I was thinking it would be a lot more efficient not having to emulate x86_64, but if you say it isn't a big deal, I'll believe you.
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3250
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: GUIDE: Running Netinstall Server on a Tik

Mon Mar 18, 2024 5:30 pm

As for the official netinstall application, it has been my experience that not all versions work properly/correctly anyways.
Oh that's true, but not common (but has happened once to me). Here that be solvable by changing the ARG for NET_VERSION and re-building to get a older/newer netinstall as needed.

Wasn't dismissing pynetinstall.... More I do know the QEMU emulation approach works on RB1100AHx4, which is not particular powerful CPU (and 32-bit). pynetinstall may be a worthwhile a docker image, and perhaps simplier Dockerfile etc, e.g.
FROM python
RUN ...
CMD ./pynetinstall ...
... but that a different image IMO than @semaja2 approach, with similar but different options needed.
 
kevinds
Long time Member
Long time Member
Posts: 631
Joined: Wed Jan 14, 2015 8:41 am

Re: GUIDE: Running Netinstall Server on a Tik

Mon Mar 18, 2024 5:38 pm

More I do know the QEMU emulation approach works on RB1100AHx4,
I'm curious though.. When was it needed? Surely you are not doing this using your mobile phone to send the commands to the working router?

You will need to configure it anyways after Netboot.. If you are using a computer, why not just run netinstall from it?
 
holvoetn
Forum Guru
Forum Guru
Posts: 5403
Joined: Tue Apr 13, 2021 2:14 am
Location: Belgium

Re: GUIDE: Running Netinstall Server on a Tik

Mon Mar 18, 2024 8:05 pm

My input

Netinstall does not run stable from windows, far from.
At least not for me.
I have a separate ( old) laptop running Linux just for that purpose. It does it rock solid.
Why ? Because there is nothing on that machine messing with network settings like Windooos does.
The container version presented here saves me getting out that laptop whenever I need a netinstall action. And I might even do it more frequent now it became so easy.

Another big plus: I would not even think about running netinstall remotely with another computer. Too risky.
With this container approach however, it brings additional options.

About netinstall itself:
For giggles, handled a Hex yesterday when testing all this.
220k saved after netinstall. Same ROS package and only ROS package.
For some devices that can mean difference between operational or dustbin.

Luckily I don't have too many of those.
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3250
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: GUIDE: Running Netinstall Server on a Tik

Mon Mar 18, 2024 8:21 pm

More I do know the QEMU emulation approach works on RB1100AHx4,
I'm curious though.. When was it needed? Surely you are not doing this using your mobile phone to send the commands to the working router?
I never used to run netinstall until recently.

I recall only ONE issue MANY years ago where that fix was fixed using an older netinstall. But I recall it being related to a change in the V6 RouterBOOT when they added a protected mode – a long time ago – using a version-matched V6 netinstall, to install V7 version worked there. Other than that, not see in an issue with the Linux netinstall. The Windows one works, but one mistake in firewall/network config on PC, it won't.

Now as a "best practice"... I'm not sure if it better if netinstall version matched the version being installed....or, if it always best to use current netinstall, even if the version being installed is older. I lean toward just always using latest netinstall.


You will need to configure it anyways after Netboot.. If you are using a computer, why not just run netinstall from it?
The RB1100 is kinda my main test router. But have plenty of ports to spare on it... so I configure a port that just always run netinstall on it (with modification to the Dockerfile to keep running). Thus if a netinstall is needed, I can just do the "power-and-push-reset" on device, and using the RB1100's "netinstall port" map to /container. I leave a PoE injector on it, so it's pretty plug-and-play.

I used have an old windows laptop that was dedicated to netinstall, but booting it takes way long than just having a port with netinstall. At one point, I used a couple containers, each running different version of this netinstall container. So I could just use a different port, to get another version.
 
kevinds
Long time Member
Long time Member
Posts: 631
Joined: Wed Jan 14, 2015 8:41 am

Re: GUIDE: Running Netinstall Server on a Tik

Mon Mar 18, 2024 9:47 pm

I'm not sure if it better if netinstall version matched the version being installed....or, if it always best to use current netinstall, even if the version being installed is older. I lean toward just always using latest netinstall.
I've found not all versions of the netinstall application work correctly.. So when I find a version that 'works properly' I use that version to do all my installs, newer or older.

Who is online

Users browsing this forum: No registered users and 40 guests