You are here

howto: meshchat on Mikrotik hAP using extra USB storage for files

8 posts / 0 new
Last post
KB9OIV
howto: meshchat on Mikrotik hAP using extra USB storage for files

Here is a general outline for setting up extra USB sorage for files, using the USB port on Mikrotik hAP.

You will need to be comfortable using command line and 'vi' editor, and able to follow (but not create) bash.  Internet and/or offline package cache needed.

Do not test this on a production device--make sure you have easy access for reflash if you mess up!

------------------------------------

Prepare USB storage:
format USB as FAT32 on another computer (do not insert to hAP yet)
 
Install packages on hAP:
kmod-usb-storage
kmod-usb2
kmod-fs-vfat
 
Insert prepared USB into hAP
 
Install package 'block-mount' on hAP
 
Copy 'USB Passthrough' script code from near bottom of /etc/rc.d/S99local:
Paste into bottom of /etc/rc.d/S10boot, just before last '}'.
This is required so USB device is available by execution of /etc/rc.d/S40fstab
 
'Comment out' (with #) the 'USB Passthrough' script code from /etc/rc.d/S99local
 
Modify /etc/config/fstab:
Change 'option enable '0'' to '1' for the USB device
 
Reboot hAP and check that USB is mounted
 
Install meshchat .ipk
 
Modify meshchat config to use USB storage:
Change /www/cgi-bin/meshchatconfig.pm:
 
modify these (3) for USB path:
$remote_files_file
$local_files_dir
$tmp_upload_dir
 
modify appropriately:
$max_file_storage  
 
Create any missing folders/subfolders in meshchat USB path with respect to the (3) paths above in meshchatconfig.pm
 
Restart meshchat:
/etc/init.d/meshchatsync restart
 
K9CQB
K9CQB's picture
This should also work on the BaseBox as well, right?
KB9IOV,
This should work on any of the MikroTik devices that have a USB port, like the BaseBox series. Will this also work on the GL devices (AR150, AR300, AR750, etc.) that have USB ports?
Would it be possible to include this working USB storage support as a 'check block' option in the base AREDN firmware like it currently is with USB power or PoE passthrough?

-Damon K9CQB
KB9OIV
I don't have any other

I don't have any other devices to try it on, but if you have those kernel modules available in the repository for your device I would think so?

Give it a shot if you have a device to experiment on!

You will know for sure, if you have the correct USB packages installed, you should see the detection of the USB storage partitions in the output of 'dmesg' command from the cli.  It will absolutely work if you see that.  It is possible that you may need other USB related kernel module packages installed for the other models of devices, I sort of guessed on the correct ones, such as 'usb2' vs 'usb3', etc.

I don't have the coding skills to automate and harden it for inclusion to firmware, I guess you could call this a proof of concept.

Also, you could consider using native linux ext2 filesystem instead of FAT32, or some other filesystem for the USB storage, but keep in mind that Windows OS will not be able to make sense of that filesystem.  

The Mikrotik devices do tend to have extra flash and RAM to support something like this.

Matt, KB9OIV

KB9OIV
Another thing I want to try
Another thing I want to try is GPS ntp support via USB GPS dongle and ntpd.  I bet that could be functional.  The package repository doesn't seem to have usb serial modules included.  The raspberry pi is really good for this stuff, too, but I was looking for a way to use what I have.
AA7AU
AA7AU's picture
GPS-NTP side note

On a side note: I've been struggling trying use an inexpensive USB GPS dongle with an Arch-based (HamVoip) PI to upddate my already existing NTP PI sever (which straddles the mesh as well as the interwebs) but have run into confusing issues which have so far side-tracked me. At this poont, I'm thinking I'll have to go back to a separate Raspian instance for this.

- Don - AA7AU

K5DLQ
K5DLQ's picture
Just be careful of flash
Just be careful of flash storage space after loading the drivers.   On 32MB devices, it's tight.
kj6dzb
kj6dzb's picture
Is this still a valid way to
Is this still a valid way to increase storage for mesh chat? Im wondering if the Dev team could bring this upto date with the current FW.

Im wondering about 2 things? 

1: Is this the only version of Mesh Chat able to run on fw <3.23.4.0? https://github.com/kn6plv/meshchat.

2: It would be useful for others... in the future, for mesh chat to have a config page too assist configuration from the UI.
K7DEV
Verified on 3.24.4.0
Verified this works on AREDN 3.24.4.0 with a Mikrotik hAP ac2 and meshchat - 2.12.0

These should be seen as my extended troubleshooting after going through KB9OIV's instructions.

Change kmod-usb2 to kmod-usb3 (ac2 has a USB3 port on top.)

When the USB storage is inserted, look for a message like this in your dmesg:
​[    8.259897] scsi 0:0:0:0: Direct-Access     Netac    OnlyDisk              PQ: 0 ANSI: 4
[    8.262007] sd 0:0:0:0: [sda] 121610240 512-byte logical blocks: (62.3 GB/58.0 GiB)
[    8.267399] sd 0:0:0:0: [sda] Write Protect is off
[    8.274544] sd 0:0:0:0: [sda] Mode Sense: 23 00 00 00
[    8.274881] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
Change kmod-fs-vfat to kmod-fs-ext4.
Inserted USB drive into my Linux Desktop.
$ sudo dmesg | tail | grep sd
[676588.111328] sd 0:0:0:0: Attached scsi generic sg0 type 0
[676588.112333] sd 0:0:0:0: [sda] 121610240 512-byte logical blocks: (62.3 GB/58.0 GiB)
[676588.112729] sd 0:0:0:0: [sda] Write Protect is off
[676588.112736] sd 0:0:0:0: [sda] Mode Sense: 23 00 00 00
[676588.112998] sd 0:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[676588.117000]  sda: sda1
[676588.117303] sd 0:0:0:0: [sda] Attached SCSI removable disk
$ sudo gparted /dev/sda
Right click FAT32 partition, Format To, ext4. Click green checkmark to Apply operations if you are sure. (Don't wipe your main drive!)
Close gparted. (Always run sync below before changing around storage devices in Linux/UNIX to make sure buffers are flushed.)
$ sync
Remove USB drive and put it into your Mikrotik hAP ac2.
You should see the storage like below:
​root@K7DEV-MOBILE:~# block info
/dev/mtdblock7: UUID="XXXXXXXX-XXXXXX-XXXXXXX-XXXXXX" VERSION="4.0" MOUNT="/rom" TYPE="squashfs"
/dev/mtdblock8: MOUNT="/overlay" TYPE="jffs2"
/dev/sda1: UUID="XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX" VERSION="1.0" TYPE="ext4"
root@K7DEV-MOBILE:~# block detect | uci import fstab

That last line adds it to /etc/config/fstab, then you can option enabled '0' -> '1', per the original instructions.
Then reboot and cross your fingers that all the scripts do what they're supposed to do:

root@K7DEV:~# mount | grep sda
/dev/sda1 on /mnt/sda1 type ext4 (rw,relatime)
root@K7DEV:~# mkdir /mnt/sda1/meshchat
root@K7DEV:~# echo 'meshchat_path = "/mnt/sda1/meshchat/persist"' >> /www/cgi-bin/meshchat_local.lua
root@K7DEV:~# echo 'tmp_upload_dir = "/mnt/sda1/meshchat/tmp_upload"' >> /www/cgi-bin/meshchat_local.lua
root@K7DEV:~# echo 'lock_file = meshchat_path .. "/lock"' >> /www/cgi-bin/meshchat_local.lua
root@K7DEV:~# echo 'messages_db_file = meshchat_path .. "/messages"' >> /www/cgi-bin/meshchat_local.lua
root@K7DEV:~# echo 'messages_db_file_orig = meshchat_path .. "/messages"' >> /www/cgi-bin/meshchat_local.lua
root@K7DEV:~# echo 'sync_status_file = meshchat_path .. "/sync_status"' >> /www/cgi-bin/meshchat_local.lua
root@K7DEV:~# echo 'local_users_status_file = meshchat_path .. "/users_local"' >> /www/cgi-bin/meshchat_local.lua
root@K7DEV:~# echo 'remote_users_status_file = meshchat_path .. "/users_remote"' >> /www/cgi-bin/meshchat_local.lua
root@K7DEV:~# echo 'remote_files_file = meshchat_path .. "/files_remote"' >> /www/cgi-bin/meshchat_local.lua
root@K7DEV:~# echo 'messages_version_file = meshchat_path .. "/messages_version"' >> /www/cgi-bin/meshchat_local.lua
root@K7DEV:~# echo 'local_files_dir = meshchat_path .. "/files"' >> /www/cgi-bin/meshchat_local.lua
root@K7DEV:~# echo 'max_file_storage = 50 * 1024 * 1024 * 1024' >> /www/cgi-bin/meshchat_local.lua

If you previously had meshchat, you'll need to move files to the above directories. If this is a fresh install, then install meshchat .ipk now, then reboot.

73,
K7DEV

edit: large files ("22MB pdf") still fail, troubleshooting...  Looks like they've implemented the buffering oddly. PRs incoming.

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer