Community discussions

MikroTik App
 
majbthrd
just joined
Topic Author
Posts: 17
Joined: Tue Jan 31, 2012 9:17 pm

remastering MetaROUTER images: a sample recipe

Mon Oct 17, 2016 1:23 am

This may be already obvious to others, but I couldn't find such information online (or on the forum) and had to figure it out myself. I'm providing what I learned in case it helps someone else.

My aim was to "remaster" (e.g. customize and modify) a MetaROUTER image *before* installing it on a Mikrotik device. This allows deployment of a standardized image and hopefully saves the labor of having to manually customize each instance *after* installing it. It also makes it more practical to really strip down a distribution so that it uses less RAM.

This was all done using a x86 Ubuntu-based Linux PC distribution; your mileage may vary.

What was essential was the "archivemount" package that allows mounting of tarballs. (I originally tried using tar directly to modify the tarball, but RouterOS always complained "Couldn't continue - import failed: could not extract: archive is too short (6)".)

The following suggested steps also assume that /mnt is unused on the Linux PC; if not, you need to replace /mnt with a mount location that is more suitable for you.

archivemount is installed so:
sudo apt-get install archivemount
I take the standard Mikrotik MIPS image:

http://wiki.mikrotik.com/wiki/Metaroute ... al_machine
http://www.mikrotik.com/download/metaro ... rootfs.tgz

and then make a copy of that file for testing:
cp openwrt-mr-mips-rootfs.tgz otest.tgz
I then mount that file using archivemount:
sudo archivemount otest.tgz /mnt -o allow_other
Note that it may report " fuse: missing mountpoint parameter ". This is apparently a known bug whose fix hasn't been propagated to the Ubuntu distributions. The message seems pointless and doesn't seem to impede operation.

Then change current directory to be at the base of the tarball file image:
cd /mnt
At this point, you can customize the MetaROUTER image however you like. You can add or remove files and modify its configuration. When you are finished, change to a different directory and then issue this command:
sudo umount /mnt
At this point, otest.tgz will have been modified to reflect all the changes that you have made. You should then be able to try deploying it to a Mikrotik device.

I *think* there is the potential to use the "opkg" package manager to remove and add packages. I tried compiling the opkg source code and using command-line options like "--add-arch mr-mips:20" and "--offline-root /mnt", but could not get it to do anything useful. Perhaps someone else will figure out the necessary procedure and add this to the thread.

There is a brute-force method of removing an opkg package, but only do this if you are comfortable with what the following does. The example here is removing "dnsmasq":
cd /mnt
cat ./usr/lib/opkg/info/dnsmasq.list | sed 's/.*/.&/' | xargs rm

Who is online

Users browsing this forum: No registered users and 18 guests