USB Logging & UI6

Howdy,

Baring someone smarter than me figuring it out, I believe the USB logging under UI6 is broken and cannot be enabled via the web interface. There are obvious typos in the scripts related to it, mistakes in terms of how the USB stick setup functions format the stick and incompatibilities with how the USB stick test/mount functions work.

For the brave who know how to use SSH, below are the commands to enable USB logging.

I AM NOT RESPONSIBLE IF YOU DAMAGE/BRICK YOUR VERA!

NOTES

[ul][li]This requires root ssh access to your vera. This is VERY DANGEROUS, even when you know what you are doing.[/li]
[li]You need to double check the device name of your stick (Step 3). If it’s not /dev/sda, something is WRONG and you should reboot. [/li]
[li]Some commands can really brick your Vera (with 0% chance of recovery), so be exact and copy/paste and triple check before hitting ENTER!!![/li]
[li]The ‘#’ below is not to be typed – just indicates you type what follows at the ‘#’ command prompt (in fact, if you type it, the command will not work/execute).[/li]
[li]The steps below will completely erase the USB stick, so make sure there is nothing you need on it[/li][/ul]

UPDATE Unfortunately, it turns out that this may not be worth the hassle. One presumed reason to have a USB stick for logging is to have longer logs from further back in time. But due to bugs in the scripts that manage the log, the limited support for larger logs when a USB stick is present doesn’t work. Which means your log files are limited to about 5MB in size, regardless of where they live (internal flash or USB). Between all the obvious stuff broken for USB logging in UI6 and the nearly unfixable problems with USB logging in UI7, MCV clearly does not take USB logging at all seriously. It is so broken is so many places, some quite unfixable by end users, that its clear they have not bothered to test or look into any of this in a long, long time…

[size=16pt]WARNING: For UI6 Systems ONLY[/size]
This is for fixing the USB logging under UI6. It appears that it is not fixing problems with UI7 and I do not have a UI7 system to test with.

Step By Step

[ol][li]Install USB stick and reboot Vera (especially if you’ve tried to enable USB Logging).
NOTE: You should have only ONE storage device plugged into the USB ports!! Having more than one will cause problems.
NOTE: Reboot it even if you think you know better – seriously.
[br]
[/li]
[li]Be 100% Sure Vera is NOT already using the stick for logging (even if it doesn’t look like it is). Easiest way is to login and issue the command

[tt]# df -h[/tt]

And see if /dev/sda1 is mounted on /tmp/log/cmh. If you don’t see it, you’re likely OK.
[br]
[/li]
[li]Be 100% Sure your USB stick is /dev/sda. Use the command:

[tt]# dmesg | grep sda[/tt]

and be sure you see a line like

[tt]sd 0:0:0:0: [sda] 62530624 512-byte logical blocks: (32.0 GB/29.8 GiB)[/tt]

(actual numbers and size will vary, but the key is the ‘[sda]’ part.
[br]
[/li]
[li]Load USB support (usually not necessary, but harmless)

[tt]# /usr/bin/UsbStick.sh add_support[/tt]
[br]
[/li]
[li]Partition the USB stick (wipes everything and starts over)
NOTE: VERY DANGEROUS - BE SUPER CAREFUL AND TRIPLE CHECK BEFORE HITTING ENTER!!!
Be especially aware of the quotes and number of commas (two in a row)

[tt]# echo “,83” | sfdisk /dev/sda[/tt]

[br]
[/li]
[li]Format the partition (note: Case of “MiOS” IS important)
NOTE: VERY DANGEROUS - BE SUPER CAREFUL AND TRIPLE CHECK BEFORE HITTING ENTER!!!

[tt]# mkfs.ext3 -m 0 -L MiOS /dev/sda1[/tt]

NOTE: This can take a few minutes for larger sticks
[br]
[/li]
[li]Execute this command to write the necessary mount commands into /etc/config/fstab

[tt]# /usr/bin/UsbStick.sh write_default_config[/tt]

This modifies the /etc/config/fstab mount file.
[br]
[/li]
[li]Reboot the Vera[br][/li]
[li]Verify logging should be enabled:
[list]
[li]You can go to Setup->Logs and it should show enabled[/li]
[li]You can ssh into Vera, execute “df -h” (no quotes) and see an entry for /dev/sda1[/li]
[/list]
[/li][/ol]

And you’re done! Next time Vera rotates it’s logs, they’ll be written to the USB device.

NOTE: Heed the warnings about NEVER, EVER removing the USB stick while Vera is running!!

Can I ask that this VERY informative article be expanded to include UI7? I followed all the steps; everything executed as expected… but the USB share never mounts after a reboot. The /etc/fstab looks fine. I suppose I could try mounting it manually, but I would prefer an expert weigh in…

I’m running UI6 right now and not beta-testing UI7, so hopefully someone else will step in.

Incidentally, while most linux systems do use /etc/fstab, Vera uses /etc/config/fstab to mount things (which is in a format I’ve never seen before). So you may want to double check that file (assuming that hasn’t changed in UI7).

Also, if there is a /etc/config/fstab and the USB/dev/sda1 device entry is in it, look a the file system type (fstype). For UI6, it’s ext3. However, there is a lot of ‘vfat’ stuff littered in the /usr/bin/UsbStick.sh file (most of which is why it doesn’t work under UI6 – it’s sometimes wanting vfat and sometimes wanting ext3).

If it is ‘vfat’ and you formatted things as I listed above (ext3), you may be able to simply edit the /etc/config/fstab and change ‘vfat’ to ‘ext3’,

Just a few pointers – hope someone with UI7 experience can assist further.

Gerry

Doesn’t seem to work under UI7

Followed all steps, no errors. Rebooted the Vera and ran df - h and nothing

Filesystem Size Used Available Use% Mounted on
/dev/root 4.5M 4.5M 0 100% /rom
tmpfs 62.2M 564.0K 61.7M 1% /tmp
tmpfs 512.0K 0 512.0K 0% /dev
/dev/mtdblock7 11.0M 9.5M 1.5M 86% /overlay
overlayfs:/overlay 11.0M 9.5M 1.5M 86% /
/dev/mtdblock8 6.1M 6.1M 0 100% /mios

I did mention this is for UI6 a few times in the notes. I do not have a UI7 system and have no idea what is broken with USB logging in that.

Yes, I understand it was intended for UI6, thought it was worth trying on UI7.

Thanks for the info anyway, might use it if I decide to downgrade to 6.

For UI7 folks, it’s possible that the problem is the mounts in /etc/config/fstab. If someone could post that, it might shed some light.

Alternately, for the very adventurous, you could try to make your /etc/config/fstab look more like this one (from my UI6 system):

[code]config global automount
option from_fstab 0
option anon_mount 0

config global autoswap
option from_fstab 0
option anon_swap 0

config mount
option enabled 1
option target /tmp/log/cmh
option device /dev/sda1
option fstype ext3
option options rw,noatime,nodiratime,errors=continue,data=ordered
option enabled_fdisk 1
option enabled_mkfs 1
option enabled_fsck 1
option label MiOS
option fssize 512
option fsck_days 30
option fsck_mounts 10
[/code]

If you have anything else in there, backup the file first, add the appropriate parts (the biggest being the mount section for the /tmp/log/cmh) and reboot. If it doesn’t work, I’d recommend immediately restoring the backed up original (I have no idea whats in there and if anything is needed for normal UI7 operation).

Here is my fstab from UI7.

[code]config global automount
" option from_fstab 0"
" option anon_mount 0"

config global autoswap
" option from_fstab 0"
" option anon_swap 0"

config mount
" option enabled 1"
" option target /var/log/cmh"
" option device /dev/sda1"
" option fstype ext3"
" option options rw,noatime,nodiratime,errors=continue,data=ordered"
" option enabled_fdisk 1"
" option enabled_mkfs 1"
" option enabled_fsck 1"
" option label MiOS"
" option fssize 512"
" option fsck_days 30"
" option fsck_mounts 10"

config swap
" option enabled 0"
" option device /dev/sda2"[/code]

Are the quotation marks I’m seeing in your post actually in the file? If so, that would be a problem.

If not, can you manually mount the stick?

mount /dev/sda1 /mnt

(be sure to unmount it after with # umount /mnt)

Gerry

No, sorry. I haven’t a clue where the quotes came from

[code]config global automount
option from_fstab 0
option anon_mount 0

config global autoswap
option from_fstab 0
option anon_swap 0

config mount
option enabled 1
option target /var/log/cmh
option device /dev/sda1
option fstype ext3
option options rw,noatime,nodiratime,errors=continue,data=ordered
option enabled_fdisk 1
option enabled_mkfs 1
option enabled_fsck 1
option label MiOS
option fssize 512
option fsck_days 30
option fsck_mounts 10

config swap
option enabled 0
option device /dev/sda2
[/code]

So it looks like it mounts using mount /dev/sda1 /mnt

[code]root@MiOS_30104310:~# df -h
Filesystem Size Used Available Use% Mounted on
/dev/root 4.5M 4.5M 0 100% /rom
tmpfs 62.2M 2.9M 59.3M 5% /tmp
tmpfs 512.0K 0 512.0K 0% /dev
/dev/mtdblock7 11.0M 9.4M 1.6M 86% /overlay
overlayfs:/overlay 11.0M 9.4M 1.6M 86% /
/dev/mtdblock8 6.1M 6.1M 0 100% /mios

root@MiOS_30104310:~# mount /dev/sda1 /mnt

root@MiOS_30104310:~# df -h
Filesystem Size Used Available Use% Mounted on
/dev/root 4.5M 4.5M 0 100% /rom
tmpfs 62.2M 2.9M 59.3M 5% /tmp
tmpfs 512.0K 0 512.0K 0% /dev
/dev/mtdblock7 11.0M 9.4M 1.6M 86% /overlay
overlayfs:/overlay 11.0M 9.4M 1.6M 86% /
/dev/mtdblock8 6.1M 6.1M 0 100% /mios
/dev/sda1 3.7G 71.5M 3.6G 2% /mnt[/code]

Well, thats good you can mount it and that you fstab looks good. I’m sure you’ve rebooted vera (vs just using the Reload button) and one would hope that the fstab entry would just cause the O/S to mount it.

Unfortunately, without a UI7 system to look at scripts, I’m not really sure what next to look at.

Okay – looking into /etc/config/fstab and OpenWRT (which is what MiOS runs atop of), a few things seem to come up:

  1. Insure the stick is not mounted

    umount /dev/sda1

  2. Insure fstab mounts are enabled

    /etc/init.d/fstab enable

  3. Test that this script works

    /etc/init.d/fstab start

  4. If the stick is mounted, try a reboot and see if it still is mounted.

Let me know and if so, I’ll update my instructions

Gerry

P.S. I cannot tell if /etc/init.d/fstab script is a newer or older thing, so it may not even exist – the docs are imprecise. If not, I can think of one last, more intrusive way to get it mounted. But I’m crossing my fingers on this one first…

Ok, so I physically power reset the unit and ran the commands you suggested. However it failed at ‘/etc/init.d/fstab enable’

[code]root@MiOS_30104310:~# uptime
02:49:35 up 5 min, load average: 0.26, 0.47, 0.25

root@MiOS_30104310:~# df -h
Filesystem Size Used Available Use% Mounted on
/dev/root 4.5M 4.5M 0 100% /rom
tmpfs 62.2M 736.0K 61.5M 1% /tmp
tmpfs 512.0K 0 512.0K 0% /dev
/dev/mtdblock7 11.0M 9.4M 1.6M 86% /overlay
overlayfs:/overlay 11.0M 9.4M 1.6M 86% /
/dev/mtdblock8 6.1M 6.1M 0 100% /mios

root@MiOS_30104310:~# umount /dev/sda1
umount: can’t umount /dev/sda1: Invalid argument

root@MiOS_30104310:~# /etc/init.d/fstab enable
-ash: /etc/init.d/fstab: not found

root@MiOS_30104310:~# /etc/init.d/fstab start
-ash: /etc/init.d/fstab: not found[/code]

I was worried about that. Looks like the stripped some things out of the openWRT distro.

Here’s one last attempt – may work, may not, but should not cause problems if it doesn’t

  1. Create a new file call /etc/init.d/usb_logs

  2. Put this in the file (first line must be absolute first line in the file):

[code]#!/bin/sh /etc/rc.common

START=90

start() {
mount -o rw,noatime,nodiratime,errors=continue,barrier=0,data=ordered -t ext3 /dev/sda1 /tmp/log/cmh
}

stop() {
umount /tmp/log/cmh
} [/code]

  1. Set permissions

chmod a+rx /etc/init.d/usb_logs

  1. Enable it

/etc/init.d/usb_logs enable

  1. Start it

/etc/init.d/usb_logs start

  1. Check to see if the logs are mounted

  2. If so, reboot vera and see if they remain mounted after a reboot

This should work, though it’s a pretty ugly solution and one you will have to manually remove when/if they fix the problem in UI7

Still no luck, sorry.

root@MiOS_30104310:~# chmod a+rx /etc/init.d/usb_logs root@MiOS_30104310:~# /etc/init.d/usb_logs enable 'bin/sh: can't open '/etc/rc.common

Running out of ideas, unfortunately.

Take a look and see if there is a file named /etc/rc.common (there should be, OpenWRT and UI6 both have them). If there is, triple check the first line of your new script to make sure there are no special characters before or after the /etc/rc.common (there should be one space before it and nothing after it).

Finally, in /etc/init.d, take a look at one of the scripts and see if it starts with the same line as your script (i.e. referencing but /bin/sh and /etc/rc.common).

Gerry

Ok, I double checked my usb_logs file and the start line looked fine, however I copied and pasted the first line from another script just to be sure and now it mounts ok.

root@MiOS_30104310:~# chmod a+rx /etc/init.d/usb_logs root@MiOS_30104310:~# /etc/init.d/usb_logs start root@MiOS_30104310:~# df -h Filesystem Size Used Available Use% Mounted on /dev/root 4.5M 4.5M 0 100% /rom tmpfs 62.2M 6.6M 55.6M 11% /tmp tmpfs 512.0K 0 512.0K 0% /dev /dev/mtdblock7 11.0M 9.4M 1.6M 86% /overlay overlayfs:/overlay 11.0M 9.4M 1.6M 86% / /dev/mtdblock8 6.1M 6.1M 0 100% /mios /dev/sda1 3.7G 71.5M 3.6G 2% /tmp/log/cmh

But the mount is not there after a reboot.

Probably just a typo. Good news it works!

Now that it does, did you do the ‘enable’ step? Assuming things are working as they should, start mearly runs the start section now. Enable installs it as a service that should be run when the system boots.

If you haven’t, do the ‘enable’ step and reboot.

Gerry

Hi, the mount is not surviving the restart.

I ran the usb_logs enable and can see it mounted.

root@MiOS_30104310:~# df -h Filesystem Size Used Available Use% Mounted on /dev/root 4.5M 4.5M 0 100% /rom tmpfs 62.2M 2.5M 59.7M 4% /tmp tmpfs 512.0K 0 512.0K 0% /dev /dev/mtdblock7 11.0M 9.5M 1.5M 86% /overlay overlayfs:/overlay 11.0M 9.5M 1.5M 86% / /dev/mtdblock8 6.1M 6.1M 0 100% /mios root@MiOS_30104310:~# /etc/init.d/usb_logs enable root@MiOS_30104310:~# /etc/init.d/usb_logs start root@MiOS_30104310:~# df -h Filesystem Size Used Available Use% Mounted on /dev/root 4.5M 4.5M 0 100% /rom tmpfs 62.2M 2.6M 59.7M 4% /tmp tmpfs 512.0K 0 512.0K 0% /dev /dev/mtdblock7 11.0M 9.5M 1.5M 86% /overlay overlayfs:/overlay 11.0M 9.5M 1.5M 86% / /dev/mtdblock8 6.1M 6.1M 0 100% /mios /dev/sda1 3.7G 75.0M 3.6G 2% /tmp/log/cmh root@MiOS_30104310:~# date Thu Sep 18 18:42:50 BST 2014

But after rebooting it’s gone again.

root@MiOS_30104310:~# df -h Filesystem Size Used Available Use% Mounted on /dev/root 4.5M 4.5M 0 100% /rom tmpfs 62.2M 712.0K 61.5M 1% /tmp tmpfs 512.0K 0 512.0K 0% /dev /dev/mtdblock7 11.0M 9.5M 1.5M 86% /overlay overlayfs:/overlay 11.0M 9.5M 1.5M 86% / /dev/mtdblock8 6.1M 6.1M 0 100% /mios root@MiOS_30104310:~# date Thu Sep 18 18:46:15 BST 2014 root@MiOS_30104310:~# uptime 18:46:18 up 2 min, load average: 1.18, 0.67, 0.26 root@MiOS_30104310:~#

Any ideas?

Also thanks so much for your help so far, it’s been amazing.

Thank you. After more than a month, I finally have my Vera3 utilizing the USB drive.

I had tried all of the other tricks I could find. Thank you (and the cut and paste command) for helping me finally get this working.

Rob