LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices

Reply
 
Search this Thread
Old 11-20-2006, 04:08 AM   #1
teluguswan
Member
 
Registered: Oct 2005
Posts: 116

Rep: Reputation: 15
Lightbulb 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.

Please give the information


it will be very helpfull for us.
 
Old 11-20-2006, 08:15 AM   #2
Samotnik
Member
 
Registered: Jun 2006
Location: Belarus
Distribution: Debian GNU/Linux testing/unstable
Posts: 471

Rep: Reputation: 40
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.
 
Old 11-20-2006, 08:23 AM   #3
wabbalee
Member
 
Registered: Oct 2006
Location: brisbane - australia
Distribution: mepis, ubuntu, zenwalk
Posts: 334

Rep: Reputation: 38
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.
 
Old 11-20-2006, 11:25 PM   #4
teluguswan
Member
 
Registered: Oct 2005
Posts: 116

Original Poster
Rep: Reputation: 15
when

when i turnoff the or stop the pen drive in windows usually the light goes off.

But where as in Linux still the light glows.

Cause of loss of Pen-Drive: It is showing the pendrive but unable to browse the pen drive in linux when my previous pen drives went wrong.

Just i want to know is the light glows off like in windows or not.

Please give the info

with regards
teluguswan
 
Old 11-21-2006, 12:30 AM   #5
J.W.
LQ Veteran
 
Registered: Mar 2003
Location: Milwaukee, WI
Distribution: Mint
Posts: 6,642

Rep: Reputation: 69
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.
 
Old 08-09-2007, 09:16 PM   #6
gregtrounson
LQ Newbie
 
Registered: Sep 2004
Distribution: RedHat/Fedora/Debian
Posts: 11

Rep: Reputation: 0
Quote:
Originally Posted by Samotnik
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".
 
Old 08-09-2007, 11:41 PM   #7
teluguswan
Member
 
Registered: Oct 2005
Posts: 116

Original Poster
Rep: Reputation: 15
Yes I thought the Same, When the Power goes off then only it is totally off. I thought like that if the same happens.
 
Old 08-11-2007, 03:14 AM   #8
Electro
Guru
 
Registered: Jan 2002
Posts: 6,042

Rep: Reputation: Disabled
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.
 
Old 11-17-2007, 11:18 AM   #9
romashka
LQ Newbie
 
Registered: Nov 2003
Location: Ukraine
Distribution: Arch Linux
Posts: 4

Rep: Reputation: 0
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
Example usage:
# ./suspend-device.sh /dev/sdc
 
Old 11-18-2007, 04:04 PM   #10
gregtrounson
LQ Newbie
 
Registered: Sep 2004
Distribution: RedHat/Fedora/Debian
Posts: 11

Rep: Reputation: 0
Thank you!

This is exactly what I was after, thank you.

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:

sync
umount /media/sd*
suspend-device.sh /dev/sd*
 
Old 11-19-2007, 02:50 AM   #11
romashka
LQ Newbie
 
Registered: Nov 2003
Location: Ukraine
Distribution: Arch Linux
Posts: 4

Rep: Reputation: 0
Quote:
Originally Posted by gregtrounson View Post
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.
 
Old 10-04-2008, 03:36 PM   #12
romashka
LQ Newbie
 
Registered: Nov 2003
Location: Ukraine
Distribution: Arch Linux
Posts: 4

Rep: Reputation: 0
updated version of suspend-device.sh

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
 
  


Reply

Tags
drive, pen, power, usb


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using a usb thumb drive or flash drive as a swap partition. stevenjoseph Linux - Hardware 8 01-16-2012 12:09 PM
Vtec V-Drive USB 2.0 Flash Pen not working in Ubuntu 5.10 qwerty Linux - Hardware 0 02-16-2006 06:54 PM
Usb Pen Drive vivekthemind Linux - Hardware 4 09-30-2005 05:09 AM
USB Flash Drive - can't cut power malone1234 Linux - Hardware 4 08-19-2005 06:32 AM
USB Pen Drive fuoi2 Linux - Newbie 10 09-08-2004 08:03 AM


All times are GMT -5. The time now is 09:18 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration