Wednesday, August 17, 2011

Remove usb device from command line

As we use Eject option for usb devices in graphical , what if we need to do same thing using command line. Following command can do this


root# echo 1>/sys/bus/usb/devices/usb1/remove

To poweroff the usb device, hdparm command can also be used in following way

root# hdparm --command=stop /dev/sda1

If usb device has to be put in sleep mode, following command can be used

root#hdparm -Y /dev/sda1
In above given examples /dev/sda1 refering plugged usb device.