We have moved at community.getvera.com

Author Topic: USB Logging & UI6  (Read 11389 times)

Offline gduprey

  • Beta Testers
  • Full Member
  • *****
  • Posts: 122
  • Karma: +6/-1
USB Logging & UI6
« on: September 10, 2014, 04:49:26 pm »
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
  • This requires root ssh access to your vera.  This is VERY DANGEROUS, even when you know what you are doing.
  • 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.
  • Some commands can really brick your Vera (with 0% chance of recovery), so be exact and copy/paste and triple check before hitting ENTER!!!!
  • 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).
  • The steps below will completely erase the USB stick, so make sure there is nothing you need on it

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....

WARNING: For UI6 Systems ONLY
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

  • 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.


  • 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

    # df -h

    And see if /dev/sda1 is mounted on /tmp/log/cmh.  If you don't see it, you're likely OK.


  • Be 100% Sure your USB stick is /dev/sda.  Use the command:

    # dmesg | grep sda

    and be sure you see a line like

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

    (actual numbers and size will vary, but the key is the '[sda]' part.


  • Load USB support (usually not necessary, but harmless)

    # /usr/bin/UsbStick.sh add_support


  • 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)

    # echo ",,83" | sfdisk /dev/sda



  • Format the partition (note: Case of "MiOS" **IS** important)
    NOTE: VERY DANGEROUS - BE SUPER CAREFUL AND TRIPLE CHECK BEFORE HITTING ENTER!!!!!!

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

    NOTE: This can take a few minutes for larger sticks


  • Execute this command to write the necessary mount commands into /etc/config/fstab

    # /usr/bin/UsbStick.sh write_default_config

    This modifies the /etc/config/fstab mount file. 


  • Reboot the Vera
  • Verify logging should be enabled:
    • You can go to Setup->Logs and it should show enabled
    • You can ssh into Vera, execute "df -h" (no quotes) and see an entry for /dev/sda1

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!!
« Last Edit: September 14, 2014, 07:56:18 pm by gduprey »

Offline hmspain

  • Hero Member
  • *****
  • Posts: 528
  • Karma: +16/-8
Re: USB Logging & UI6
« Reply #1 on: September 11, 2014, 11:58:46 am »
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...
VeraPlus, Nest Cameras (6), Siren, Hue Bulbs/Strips/Blooms (65), Fan Dimmer (6), Aeon 4-in-1s (10), Water Sensors (3), Z-Wave Switches (20), Nest Smoke/CO Protects (5), Ecobee 3, HEM Gen2s (2)

Offline gduprey

  • Beta Testers
  • Full Member
  • *****
  • Posts: 122
  • Karma: +6/-1
Re: USB Logging & UI6
« Reply #2 on: September 11, 2014, 12:56:16 pm »
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

Offline snakehead

  • Newbie
  • *
  • Posts: 15
  • Karma: +0/-0
Re: USB Logging & UI6
« Reply #3 on: September 11, 2014, 01:20:50 pm »
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

Offline gduprey

  • Beta Testers
  • Full Member
  • *****
  • Posts: 122
  • Karma: +6/-1
Re: USB Logging & UI6
« Reply #4 on: September 11, 2014, 02:34:25 pm »
Doesn't seem to work under UI7

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.

Offline snakehead

  • Newbie
  • *
  • Posts: 15
  • Karma: +0/-0
Re: USB Logging & UI6
« Reply #5 on: September 11, 2014, 04:02:50 pm »
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.

Offline gduprey

  • Beta Testers
  • Full Member
  • *****
  • Posts: 122
  • Karma: +6/-1
Re: USB Logging & UI6
« Reply #6 on: September 11, 2014, 04:08:09 pm »
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: [Select]
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

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).

Offline snakehead

  • Newbie
  • *
  • Posts: 15
  • Karma: +0/-0
Re: USB Logging & UI6
« Reply #7 on: September 12, 2014, 02:12:47 am »
Here is my fstab from UI7.


Code: [Select]
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"

Offline gduprey

  • Beta Testers
  • Full Member
  • *****
  • Posts: 122
  • Karma: +6/-1
Re: USB Logging & UI6
« Reply #8 on: September 12, 2014, 09:18:47 am »
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

Offline snakehead

  • Newbie
  • *
  • Posts: 15
  • Karma: +0/-0
Re: USB Logging & UI6
« Reply #9 on: September 12, 2014, 01:08:28 pm »
No, sorry. I haven't a clue where the quotes came from

Code: [Select]
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


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

Code: [Select]
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

Offline gduprey

  • Beta Testers
  • Full Member
  • *****
  • Posts: 122
  • Karma: +6/-1
Re: USB Logging & UI6
« Reply #10 on: September 12, 2014, 03:43:25 pm »
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. 

Offline gduprey

  • Beta Testers
  • Full Member
  • *****
  • Posts: 122
  • Karma: +6/-1
Re: USB Logging & UI6
« Reply #11 on: September 12, 2014, 03:51:40 pm »
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....

Offline snakehead

  • Newbie
  • *
  • Posts: 15
  • Karma: +0/-0
Re: USB Logging & UI6
« Reply #12 on: September 12, 2014, 09:56:08 pm »
Ok, so I physically power reset the unit and ran the commands you suggested. However it failed at '/etc/init.d/fstab enable'

Code: [Select]
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

Offline gduprey

  • Beta Testers
  • Full Member
  • *****
  • Posts: 122
  • Karma: +6/-1
Re: USB Logging & UI6
« Reply #13 on: September 13, 2014, 03:03:01 pm »
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: [Select]
#!/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
}

3) Set permissions
  # chmod a+rx /etc/init.d/usb_logs

4) Enable it
  # /etc/init.d/usb_logs enable

5) Start it
  # /etc/init.d/usb_logs start

6) Check to see if the logs are mounted

7) 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

Offline snakehead

  • Newbie
  • *
  • Posts: 15
  • Karma: +0/-0
Re: USB Logging & UI6
« Reply #14 on: September 14, 2014, 12:27:01 pm »
Still no luck, sorry.

Code: [Select]
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