[unRAID 6 beta14+] Unassigned Devices [former Auto Mount USB]


Recommended Posts

* Notice: our esteemed plugin author gfjardim has been out of touch for awhile, so caution is advised.  The latest version of this plugin (from the Download link below the Demonstration video) has a few issues (for some users, not all), so it is recommended to install the newest version from the new Topic listed below.

 

* "This plugin is no longer being supported from this support thread.  There is a modified version of unassigned devices available here:

 

>>>>>>- - - http://lime-technology.com/forum/index.php?topic=45807.0. - - - <<<<<<

 

* This modified version works on all V6 versions and some fixes have been applied.  Please post about this plugin on the new thread."

 

 

* If you have a copy of the plugin already installed, uninstall it, then reboot, before installing the replacement plugin.

* gfjardim, PLEASE remove all of this, retake control! Then PM squid to remove the mod comment in CA

 

 

This plugin uses UDEV to mount and share disks that are not part of your unRAID array. Available devices are listed under "Main/Unassigned Devices" tab.

 

Demonstration video:

 

 

 

[glow=red,2,300]Download Link:[/glow]

 

Link: https://raw.githubusercontent.com/gfjardim/unRAID-plugins/master/plugins/unassigned.devices.plg

 

[glow=red,2,300]FAQ:[/glow]

 

Q) Which filesystems are supported by this plugin?

A) Currently, XFS, ReiserFS, VFAT, EXT4 and BTRFS are supported via unRAID's own tools; NTFS is supported through NTFS-3G (v.2014.2.15); HFS+ is supported through original kernel module (and it's own limitations, like no journaling) plus hfsprogs v.332.25; finally, EXFAT is supported through fuse-exfat v.1.1.0 and exfat-utils v.1.1.1.

 

Q) Is there a way to verify my partition for errors?

A) Yes, there is. You can click on the TmMDD2N.png icon while the partition is unmounted (the exception is BTRFS which check requires a mounted partition). A new window will appear with the result of a read-only check. If needed, there is a "Run with CORRECT flag" button that will launch a read/write instance of the filesystem check utility.

 

Q) Is this plugin suitable to mount a disk that can be used to store VMs or Docker images?

A) Right now (v6 beta15), there's a race condition between those services and this plugin. LT will postpone Docker and VMs to a latter event, so there won't be any problems. I'll keep you posted about this.

PS: Since unRAID v6.0-rc1, it's safe to use a disk managed by this plugin to store VM's and Docker images.

 

Example script for those who mount disks used by Docker and/or VMs:

 

#!/bin/bash
PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin
## Available variables: 
# AVAIL      : available space
# USED       : used space
# SIZE       : partition size
# SERIAL     : disk serial number
# ACTION     : if mounting, ADD; if unmounting, REMOVE
# MOUNTPOINT : where the partition is mounted
# FSTYPE     : partition filesystem
# LABEL      : partition label
# DEVICE     : partition device, e.g /dev/sda1
# OWNER      : "udev" if executed by UDEV, otherwise "user"

case $ACTION in
  'ADD' )
    // do your stuff here
    /usr/local/emhttp/plugins/dynamix.vm.manager/event/started
    /usr/local/emhttp/plugins/dynamix.docker.manager/event/started
  ;;
  'REMOVE' )
    // do your stuff here
    /usr/local/emhttp/plugins/dynamix.vm.manager/event/stopping_svcs
    /usr/local/emhttp/plugins/dynamix.docker.manager/event/stopping_svcs
  ;;
esac

 

Q) Can I set commands to run when my disk is plugged in?

Yes, you can. See the video below:

 

Link to comment

I have been using udev to mount disks to fixed mount points based on a USB cradle slot numbers since v5 and find it ultra reliable. The only time it fails is when so extra disk checks happen and udev mount times out.

 

I cant test your plugin without braking my own manual setup but IMO UDEV is the way to go. Nice work.

Link to comment

Is it ok to uninstall dlandons NTFS-3G Package plugin and use yours in its place?

 

This plugin uses UDEV to automount and share inserted USB mass storage devices. Available devices are listed under "Main/USB Devices" tab.

 

link: https://raw.githubusercontent.com/gfjardim/unRAID-plugins/master/plugins/gfjardim.usb.automount.plg

 

PS: this will install NTFS-3G package.

 

I'm using the latest version of ntfs-3g, so yes, it's safe.

Link to comment

I have not tried using USB devices on unRAID yet, can you explain how this is different from SNAP?

 

One thing I'd like to do is run a script that detects when I plug in a particular microsd card (from my camera), moves the files to a particular location on unraid, then unmounts the card and beeps so I know it is safe to remove it.

 

Would this or SNAP be better starting point for that sort of thing?

 

Thanks!

Link to comment

I have not tried using USB devices on unRAID yet, can you explain how this is different from SNAP?

 

One thing I'd like to do is run a script that detects when I plug in a particular microsd card (from my camera), moves the files to a particular location on unraid, then unmounts the card and beeps so I know it is safe to remove it.

 

Would this or SNAP be better starting point for that sort of thing?

 

Thanks!

 

SNAP all the way. This plugin doesn't support custom commands, so it's useless to your scenario. This may change in the future, but it's time to mature the basic first.

Link to comment

I have not tried using USB devices on unRAID yet, can you explain how this is different from SNAP?

 

One thing I'd like to do is run a script that detects when I plug in a particular microsd card (from my camera), moves the files to a particular location on unraid, then unmounts the card and beeps so I know it is safe to remove it.

 

Would this or SNAP be better starting point for that sort of thing?

 

Thanks!

 

Ok, I added the ability to run scripts on disk mount/umount. Users have to click on the "Script" icon, define a name on the editor and click "Save". If You want to start with a new script, you can click "Default Script" and a template will be inserted on the text area.

 

In your case, you could try something like this:

 

#!/bin/bash
PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin
## Available variables: 
# AVAIL      : available space
# USED       : used space
# SIZE       : partition size
# SERIAL     : disk serial number
# ACTION     : if mounting, ADD; if unmounting, REMOVE
# MOUNTPOINT : where the partition is mounted
# FSTYPE     : partition filesystem
# LABEL      : partition label
# DEVICE     : partition device, e.g /dev/sda1

beep_imperial() {
  for i in $(seq 1 ${1}); do
    beep -f 392 -l 450 -r 3 -D 150 -n -f 311.13 -l 400 -D 50 \
    -n -f 466.16 -l 100 -D 50 -n -f 392 -l 500 -D 100 \
    -n -f 311.13 -l 400 -D 50 -n -f 466.16 -l 100 -D 50 \
    -n -f 392 -l 600 -D 600 -n -f 587.33 -l 450 -r 3 -D 150 \
    -n -f 622.25 -l 400 -D 50 -n -f 466.16 -l 100 -D 50 \
    -n -f 369.99 -l 500 -D 100 -n -f 311.13 -l 400 -D 50 \
    -n -f 466.16 -l 100 -D 50 -n -f 392 -l 500 -D 100
    sleep 2
  done
}

DESTINATION="/mnt/user/Pictures/Recent/"

case $ACTION in
  'ADD' )
    // do your stuff here
    rsync -a "${MOUNTPOINT}" "${DESTINATION}/" && \
    newperms "${DESTINATION}" && \
    /usr/local/sbin/usb_umount $DEVICE &&
    beep_imperial 1 &
  ;;
  'REMOVE' )
    // do your stuff here
    echo "Removed"
  ;;
esac

 

Scripts are defined using their serial number, so if your card reader export it's own serial instead of the card's serial, every card inserted will run the same script.

Link to comment

Wow gfjardim, this is awesome! 

 

The sample script made it pretty easy to figure out how to do what I wanted, although replacing "echo" with "logger" might help people get started faster.  The imperial theme song was awesome :)

 

You were right about the serial number, each card I plugged in to the reader called the same script.  I was able to differentiate them using:

  if [ "${LABEL}" == "EOS DIGITAL" ]

etc.

 

The only strange thing I noticed was that the script is named:

EOS_DIGITAL.sh

it seems like the name should be based on the card reader's serial number rather than the label of the first thing I plugged into it?

 

Would it be possible for the system to detect when a drive needs to have dosfsck run on it?  It would be nice to automatically run:

  dosfsck -av ${DEVICE}

if it was needed.

 

Thank you very much for this!

Link to comment

Wow gfjardim, this is awesome! 

 

The sample script made it pretty easy to figure out how to do what I wanted, although replacing "echo" with "logger" might help people get started faster.  The imperial theme song was awesome :)

 

You were right about the serial number, each card I plugged in to the reader called the same script.  I was able to differentiate them using:

  if [ "${LABEL}" == "EOS DIGITAL" ]

etc.

 

The only strange thing I noticed was that the script is named:

EOS_DIGITAL.sh

it seems like the name should be based on the card reader's serial number rather than the label of the first thing I plugged into it?

 

Would it be possible for the system to detect when a drive needs to have dosfsck run on it?  It would be nice to automatically run:

  dosfsck -av ${DEVICE}

if it was needed.

 

Thank you very much for this!

 

1) The plugin suggest the "LABEL" as the script name, but you can choose to change it in the input. The LABEL variable is the label of the partition, if it exist, or the full serial number if it doesn't.

 

2) This could be tricky to archive. Maybe a "Check" in a new window?

 

 

Link to comment

1) The plugin suggest the "LABEL" as the script name, but you can choose to change it in the input.

 

Ah, thanks!

 

2) This could be tricky to archive. Maybe a "Check" in a new window?

 

I saw you started implementing this, nice!  So far for me it does a non-error correcting check:

  /sbin/fsck -n /dev/sdi1 2>&1

not sure how to make it actually fix the errors yet.  But I'm not trying to be pushy :)

 

Link to comment

In case anyone is interested, I expanded a bit on gfjardim's sample script and posted it here:

  https://gist.github.com/ljm42/02b54ce9cc36f992515b

 

Once it is configured, all you have to do is insert a memory card, wait for the beep, and remove the memory card.  The script will automatically move/copy files from the USB's DCIM subdirs onto the array, you just need to configure it so it knows what dirs your camera uses and where you want the files to go.

 

If you install jhead as described in the comments, it will also automatically rotate the images according to the exif data, which is my favorite part :)

 

Link to comment
  • 1 month later...

A few updates I made these days:

 

###2015.04.24a

- Fix webGui being hammered with update requests

- Fix mounting all disks if no devide was supplied

- Set sleep time (15 minutes) to mounted disks

 

###2015.04.24

- Fix some css quirks

 

###2015.04.23a

- Major revamp, will work with SATA/USB disks. It will presume autostart for USB disks, and not for SATA ones.

 

###2015.04.13

- Fix: table color with black theme

Link to comment

Great work.  A couple things. I noticed my 2nd cache drive shows up as an available device to mount.  Maybe this plugin should replace unassigned devices.

 

Great work.  A couple things. I noticed my 2nd cache drive shows up as an available device to mount.  Maybe this should replace unassigned devices.

mine too

 

Please update and see if it got fixed.

 

Thanks!

Link to comment

Great work.  A couple things. I noticed my 2nd cache drive shows up as an available device to mount.  Maybe this plugin should replace unassigned devices.

 

Great work.  A couple things. I noticed my 2nd cache drive shows up as an available device to mount.  Maybe this should replace unassigned devices.

mine too

 

Please update and see if it got fixed.

 

Thanks!

Yes. It's fixed. Thanks.

Link to comment

Great work.  A couple things. I noticed my 2nd cache drive shows up as an available device to mount.  Maybe this plugin should replace unassigned devices.

 

Great work.  A couple things. I noticed my 2nd cache drive shows up as an available device to mount.  Maybe this should replace unassigned devices.

mine too

 

Please update and see if it got fixed.

 

Thanks!

Yes. It's fixed. Thanks.

Fixed for me also.
Link to comment

Maybe this plugin should replace unassigned devices.

 

Liked your idea, so I renamed the plugin. Now it will replace the Unassigned Devices tab.

 

Please remove the old plugin before you install this.

 

https://raw.githubusercontent.com/gfjardim/unRAID-plugins/master/plugins/unassigned.devices.plg

Removed old plugin. Installed this. Now have a tab for USB Devices and a tab for Unassigned Devices. The Unassigned Devices tab has this error message:

 

Fatal error: Cannot redeclare save_ini_file() (previously declared in /usr/local/emhttp/plugins/gfjardim.usb.automount/include/usb_mount_lib.php:19) in /usr/local/emhttp/plugins/unassigned.devices/include/lib.php on line 30

Link to comment

Maybe this plugin should replace unassigned devices.

 

Liked your idea, so I renamed the plugin. Now it will replace the Unassigned Devices tab.

 

Please remove the old plugin before you install this.

 

https://raw.githubusercontent.com/gfjardim/unRAID-plugins/master/plugins/unassigned.devices.plg

Removed old plugin. Installed this. Now have a tab for USB Devices and a tab for Unassigned Devices. The Unassigned Devices tab has this error message:

 

Fatal error: Cannot redeclare save_ini_file() (previously declared in /usr/local/emhttp/plugins/gfjardim.usb.automount/include/usb_mount_lib.php:19) in /usr/local/emhttp/plugins/unassigned.devices/include/lib.php on line 30

 

Please remove this dir: /usr/local/emhttp/plugins/gfjardim.usb.automount/

Link to comment

Maybe this plugin should replace unassigned devices.

 

Liked your idea, so I renamed the plugin. Now it will replace the Unassigned Devices tab.

 

Please remove the old plugin before you install this.

 

https://raw.githubusercontent.com/gfjardim/unRAID-plugins/master/plugins/unassigned.devices.plg

Removed old plugin. Installed this. Now have a tab for USB Devices and a tab for Unassigned Devices. The Unassigned Devices tab has this error message:

 

Fatal error: Cannot redeclare save_ini_file() (previously declared in /usr/local/emhttp/plugins/gfjardim.usb.automount/include/usb_mount_lib.php:19) in /usr/local/emhttp/plugins/unassigned.devices/include/lib.php on line 30

 

Please remove this dir: /usr/local/emhttp/plugins/gfjardim.usb.automount/

That seems to have fixed it. Now there is no USB Devices tab, and the Unassigned Devices tab says

No usb disks present.

which is correct for me currently. Does this plugin also show unassigned SATA devices? I don't have any of those at present either, but maybe the message should be different if non-USB devices are also supported.

 

Link to comment

That seems to have fixed it. Now there is no USB Devices tab, and the Unassigned Devices tab says

No usb disks present.

which is correct for me currently. Does this plugin also show unassigned SATA devices? I don't have any of those at present either, but maybe the message should be different if non-USB devices are also supported.

 

I will update this message, thanks for reporting.

Link to comment
  • Squid locked this topic
Guest
This topic is now closed to further replies.