USB Pen Drive / Flash Drive Unmounted but the power is there
Linux - HardwareThis forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
USB Pen Drive / Flash Drive Unmounted but the power is there
Hello to all
Thanks to all for such a good solutions.
I have the problem with my Pen Drives i.e iam using the Redhat Enterprise Linux 4 and my problem is when iam inserting the pen drive it installed correctly and every thing went correct. After whenever i unmount the pen drive the icon on the desktop disappears but the light of the Pen drive is still glowing. When i removed the pen drive in this conditions twice my Pen Drive corrupted and i have to purchase another.
Any one please help me how i should remove the pen drive from the system in linux. After unmounting the pen drive how to turnoff the power to pen drive.
There are no way to turn off power on USB port (except unloading kernel module maybe) and no one care about this, becouse unmounting is sufficient. Power on USB line can't damage pen drive when unplugging. When you lose your drive it isn't a power problem, it's a defect in this drive.
i agree with Samotnik, another thing that might be a problem is that the drive is still being written to by the os. you should always wait for a few seconds (10 or so) before pulling it out. you can also tell if it is still in use when you look at the light and it is still flashing. I have noticed that windows 'unmounts' the drive differently as it turns off the led. I use a pendrive all the time and haven't come accross to actually damaging/corrupting the drive.
By design, all USB ports are powered, and anytime you insert a USB device into the slot, it will automatically be powered on. This is really useful and helpful, and the basic idea is simply that when you plug in the USB device, you clearly intend on using it, and therefore the computer should not force you to take any other actions to turn it on. Or to say it the other way, if you didn't want the device to be enabled, you wouldn't have plugged it into the slot in the first place.
Anyhow, in the case of pen drive (or any other USB storage unit), the act of mounting it to a mountpoint (and thus making the data accessible) could be automatic or require a manual step. It depends on your system, but either way it would be perfectly normal to have a pen drive be powered on but unmounted. The fact that the light still glows after you unmount it is OK.
There are no way to turn off power on USB port (except unloading kernel module maybe) and no one care about this, becouse unmounting is sufficient. Power on USB line can't damage pen drive when unplugging. When you lose your drive it isn't a power problem, it's a defect in this drive.
I think he wants just what Windows users see. When a drive is unmounted under Windows, power to that port alone is cut and the drives light goes out. (note that simply removing the usb modules is not a solution here as there may be other devices still connected).
This is a rather sensible safeguard to teach your users if you ask me: "If the little light is on, don't pull it out".
Check the logs. Could be a bad bit. If it is damaged, you should have some patience.
Flash NAND memory is very, very slow. The throughput is about a few hundred kilobytes. Also it is more prone to failing when power is abruptly disconnected during use (writing or reading).
All devices connected to USB are powered, so be careful disconnecting the cable while they are processing.
USB devices are always powered even if you think they are not.
What Windows does is putting USB device in suspend mode.
Use the following script for doing the same:
Code:
#!/bin/bash
if [ -z $1 ]; then
echo 'device not specified'
exit 1
fi
DEVICE=$(udevinfo --query=path --name=$1 --attribute-walk | grep 'USB Mass Storage Device' -B5 | head -n 1 | cut -d"'" -f2)
if [ -z $DEVICE ]; then
DEVICE=$(udevinfo --query=path --name=$1 --attribute-walk | grep 'USB2.0 Storage Device' -B5 | head -n 1 | cut -d"'" -f2)
if [ -z $DEVICE ]; then
echo 'not an USB mass storage device'
exit 1
fi
fi
echo 'suspend' > /sys/$DEVICE/power/level
It works perfectly too. When the drive is plugged in it is usually noticeably hot. When put into suspend it cools down to room temperature so not only is the light off, the unit itself is drawing very little (if any) current. I've extended the script a bit so you can wake it back up too without having to plug it back in. Just cat 'on' or 'auto' instead of 'suspend' to the level file.
Now to bring this to the masses we have to figure out how to tie it into Gnome and KDE's "safely remove" feature. Ideally 'removing' a USB drive should do something like this:
Now to bring this to the masses we have to figure out how to tie it into Gnome and KDE's "safely remove" feature. Ideally 'removing' a USB drive should do something like this:
sync
umount /media/sd*
suspend-device.sh /dev/sd*
sync is not needed when mounting flash with the new 'flush' option (appeared in kernel 2.19 IIRC). With -o flush data are written on filesystem as soon as possible but the process is much faster than with -o sync.
The latest HAL releases already recognize 'flush' as a valid mount option, just add it to default mount options in KDE config centre.
Wanted to try the script again today, and found that it doesn't work with the latest udev because there are many more ATTRS than grep -B5 intended to skip.
So here's an improved version that works with much greater number of ATTRS in the needed device.
Code:
#!/bin/bash
if [ -z $1 ]; then
echo 'device not specified'
exit 1
fi
DEVICE=$(udevinfo --query=path --name=$1 --attribute-walk | grep 'USB Mass Storage Device' -B50 | grep 'looking at parent device' | tail -n 1 | cut -d"'" -f2)
if [ -z $DEVICE ]; then
DEVICE=$(udevinfo --query=path --name=$1 --attribute-walk | grep 'USB2.0 Storage Device' -B50 | grep 'looking at parent device' | tail -n 1 | cut -d"'" -f2)
if [ -z $DEVICE ]; then
echo 'not an USB mass storage device'
exit 1
fi
fi
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.