Synology NAS complains about not ejecting USB drive

I just purchased VirtualHere. Very cool. Very useful. However.... :-)

My USB drive is used to back up my NAS and Windows machine. The Synology NAS backs up on even days and Windows machine on odd days. This means every other day the Windows machine takes over the USB drive.

The problem is that the drive is not being gracefully ejected from the NAS which causes a warning to be generated.

Does a way exist where I can force a script to trigger before VirtualHere ejects the drive? As documented here: http://forum.synology.com/enu/viewtopic.php?f=12&t=13202

I would like to execute something like this:
sync; umount -f /dev/sdq1; echo 1 > /sys/block/sdq/device/delete

Thanks in advance,
Tim

P.S. I am using crashplan for my Windows backup. That is why I am not mounting the NAS via SMB/CIFS/NFS. CrashPlan doesn't back up network mounts without complex configuration. I am hoping VirtualHere will solve that for me.

#2

Yes this is supported, i designed VirtualHere for this sort of situation

I safely ejected on my test Synology by doing the following:

1. Plug in the USB stick into the Synology
2. In the VirtualHere client, right click on the stick and select properties. Make a note of the Vendor id and Product id. E.g my "STORE N GO" stick is 13FE for vendor id and 3623 for product id
3. Right click again on the device and select Custom Event Handler
4. Put in the following line to hook the onBind event for this device. (http://www.virtualhere.com/quirks) Make sure to substitute the values of product id and vendor id found in step 2 with your values:

onBind.13fe.3623=sync; umount -f /dev/sdq1; echo 1 > /sys/block/sdq/device/delete

5. Click OK and that will now run that script just before the device is grabbed by VirtualHere for remote access. Hence safely unbinding the device.

Most devices are FAT anyway so its safe to just take without ejecting. Usually its just ext or hfs formatted sticks that are problematic.

#3

If the virtualhere client is closed, thus the USB device released, does the synology NAS or any other virtualhere client find the USB device again automatically after unmounting it with this method?

Greetings, Johann

#4

Yes it does for me on my DS213j running DSM 5.2-5644 Update 1

This post is old and the virtualhere server/client have since been updated, so you don't need to know the product/vendor id anymore, just right click on the USB drive and put in the line:

onBind.$VENDOR_ID$.$PRODUCT_ID$=sync; umount -f /dev/sdq1; echo 1 > /sys/block/sdq/device/delete

Then it will be correctly unbound before virtualhere uses it and when virtualhere stops using it, the drive will reappear in the synology after 3 seconds or so.

#5

Thanks for the fast reply!

Does this line work for only the first USB device in the row? Do I have to change anything (e.g. sdq1-x) if I have 4 USB devices connected to the NAS with this problem?

#6

I just did further testing with multiple usb sticks. If i do mount my synology shows

...

/dev/sdq1 on /volumeUSB1/usbshare type vfat (utf8,umask=000,shortname=mixed,uid=1024,gid=100,quiet)
/dev/sdr1 on /volumeUSB2/usbshare type vfat (utf8,umask=000,shortname=mixed,uid=1024,gid=100,quiet)

So it looks like synology is setting the sequential letter in the alphabet as the next usbdisk.

This method is a bit messy so in a later build of virtualhere i will automate this process via a more complex bash script than the one specified above...Essentially you need to grep the mount command to find the dev path of the usbdevice , parse the ls -al /sys/class/block files to figure out the device usb path then pass that to the umount path.Perhaps ill find a simpler way...

I will put it on my TODO list to do in the next week or two.

#7

Ok i fixed it , can you download synology server 2.6.7 from https://www.virtualhere.com/nas and then install.

Then in the virutalhere client, right click on each of the usb sticks in turn and select "Custom Event Handler" then put in the entry exactly as below (all on one line):

onBind.$VENDOR_ID$.$PRODUCT_ID$=FP=$(realpath /sys/block/* | grep $(realpath $DEVPATH$));DN=${FP##*/};sync; umount -f /dev/${DN}1; echo 1 > /sys/block/${DN}/device/delete

My testing shows this works. Let me know if it works ok for you and ill automate the process in the next build of the server so no special code is needed for usb drives when using synology as the server.

#8

Hi!

Thanks for the quick support. I will give it a try over the weekend, when the USB-sticks are not in use and report back.

Greetings!

#9

... and it is working!

I don't know if it is just a coincidence, but the windows "repair disk" dialogs are also not popping up!

Thanks a lot!

#10

yeah i noticed the repair doesnt popup anymore either, thanks for your feedback and i will roll out this change in the next build for synology that is pushed to their app store...