Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
Eject USB Drive from command line (ReadyNAS 102) [UPDATE]
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2021-03-13
03:34 AM
2021-03-13
03:34 AM
Eject USB Drive from command line (ReadyNAS 102) [UPDATE]
Hardware: Netgear ReadyNAS 102. (firmware 6.10.4)
UPDATE:
This is an update to the script in my original post (https://community.netgear.com/t5/Using-your-ReadyNAS-in-Business/Eject-USB-Drive-from-command-line-R...).
I originally wrote this because I could not get umount to work consistently. This script uses the same USB unmount process as the admin web front-end, so is very reliable.
With shell access to your NAS, you can list the USB mounted drives using the following:
# ls -l /media/ total 8 drwxrwxrwx 1 root root 8192 Feb 24 22:19 USB_HDD_3
To unmount using the script, do the following:
# ./usb_eject.sh /media/USB_HDD_3 USB_device=sdc1
Now the drive is unmounted:
# ls -l /media/ total 0
usb_eject.sh
#!/bin/bash envecho() { echo ${1}=${!1} } usb_pattern=${1%/} [[ -z ${usb_pattern} ]] && { echo echo "need path to USB device" echo " eg $ usb_eject.sh /media/USB_FLASH_6" echo exit 2 } # Get device from mountpoint eg /media/USB_FLASH_6 USB_device=$(lsblk -P -o NAME,MOUNTPOINT |sed -n "s|^NAME=\"\([^\"]*\)\" *MOUNTPOINT=\"${usb_pattern}\"|\1|p") [[ -z ${USB_device} ]] && { # Ok, that didn't work; how about /run/nfs4/media/USB_FLASH_6? USB_device=$(lsblk -P -o NAME,MOUNTPOINT |sed -n "s|^NAME=\"\([^\"]*\)\" *MOUNTPOINT=\"/run/nfs4${usb_pattern}\"|\1|p") # Out of ideas, exit [[ -z ${USB_device} ]] && { echo "Cannot detect USB device using lsblk -P -o NAME,MOUNTPOINT" exit 1 } } envecho USB_device # Call event_push to eject the USB device as done from admin console # event_push logs to /var/log/readynasd/event_push.log event_push shell readynasd "<xs:delete-s resource-type=\"HotPlug\" resource-id=\"UsbStorage\" action=\"eject\" device=\"${USB_device}\"></xs:delete-s>" 1 1 exit $?
Hope this helps
Model: RN102|ReadyNAS 100 Series 2- Bay
Message 1 of 2
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2021-03-13
03:37 AM
2021-03-13
03:37 AM
Re: Eject USB Drive from command line (ReadyNAS 102) [UPDATE]
Thx for posting this.
Message 2 of 2