Community discussions

MikroTik App
 
semaja2
newbie
Topic Author
Posts: 29
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: 1122
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
MTKEK Certified, IP Sparky
Check yer peers!
 
semaja2
newbie
Topic Author
Posts: 29
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
Long time Member
Long time Member
Posts: 691
Joined: Thu Jul 01, 2021 3:15 pm

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: 29
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
Long time Member
Long time Member
Posts: 691
Joined: Thu Jul 01, 2021 3:15 pm

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: 1122
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.
MTKEK Certified, IP Sparky
Check yer peers!
 
holvoetn
Forum Guru
Forum Guru
Posts: 1621
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: 29
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
Long time Member
Long time Member
Posts: 691
Joined: Thu Jul 01, 2021 3:15 pm

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: 29
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: 1122
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.
MTKEK Certified, IP Sparky
Check yer peers!
 
semaja2
newbie
Topic Author
Posts: 29
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)

Who is online

Users browsing this forum: Ahrefs [Bot], bijikuda69, Google [Bot], guipoletto, Semrush [Bot] and 20 guests