If we forget to unplug (after copy Sync will be happening and we will wait) lot of energy is wasted in form of heat energy (will reduce battery backup in laptop as well).
In Windows, I beleive it is powerd off.
To test this simply run udisksctl power-off -b /dev/sdb and you will see it is executed, again run it and it will say no device to poweroff (means while eject it is not powered off).
Found a command to powerdown the usb after unmount - udisksctl power-off -b /dev/sdb (Please correct me if I am wrong)
Now the step is to automate it, not manually running the script.
Created a file nano /etc/udev/rules.d/90-usb-notify-poweroff.rules with below contents to poweroff any connected and unmounted USB
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
ACTION=="remove", ENV{ID_PART_TABLE_TYPE}!="", ENV{DEVTYPE}=="partition", RUN+="/usr/bin/sudo -u guest DISPLAY=:0 /usr/bin/Usb-Poweroff.sh"
This will poweroff after unmount of any USB drive connected.
Content of Usb-Poweroff is below. Searched internet for the script and any changes or modification to below script is welcome for better result.
We intent to help other and hope this will help somebody.
Code: Select all
#!/bin/bash
for DEV in /sys/block/sd*
do
if readlink $DEV | grep -q usb
then
DEV=`basename $DEV`
udisksctl power-off -b /dev/$DEV
fi
done
exit 0