Ubuntu Forums ubuntu.com - launchpad.net - ubuntu help  

Go Back   Ubuntu Forums > The Ubuntu Forum Community > Forum Archive > Main Support Categories > Hardware & Laptops
Register Reset Password Forum Help Forum Council Search Today's Posts Mark Forums Read

Hello, Unregistered You are browsing a READ only archive of the main support categories pre 4/21/2008. You will not be able to post or reply any threads in this section.

Hardware & Laptops
Problems with hardware & laptops not being detected or supported during or after install.

 
 
Thread Tools Display Modes
Old July 7th, 2007   #1
trolav
First Cup of Ubuntu
 
Join Date: Jul 2007
Beans: 1
Trouble with external USB harddrive (Seagate FreeAgent) [SOLVED]

Posting here for personal reference, and maybe save some other users some headache.
The post might need some cleanup.

References:
https://bugs.launchpad.net/ubuntu/+s...dev/+bug/61235
http://ubuntuforums.org/showthread.php?t=168221

System:
Ubuntu 7.04 Feisty Fawn

Hardware:
External USB harddrive, Seagate FreeAgent 500GB

Symptoms
I noticed lots of I/O errors on my nice new Seagate FreeAgent 500GB, which I first though look like filesystem errors. With JFS filesystem the dmesg error looked like this:
sd 6:0:0:0: Device not ready: <6>: Current: sense key: Not Ready
Additional sense: Logical unit not ready, initializing command required
end_request: I/O error, dev sde, sector 450262279
metapage_read_end_io: I/O error
Trying to reformat with EXT3 gave a little different error:
sd 6:0:0:0: Device not ready: <6>: Current: sense key: Not Ready
Additional sense: Logical unit not ready, initializing command required
end_request: I/O error, dev sde, sector 976767935
Buffer I/O error on device sde1, logical block 488383936
Solution
As described in the reference bug report:

Create a new UDEV rule (using your preferred method):

Example (type in Terminal):
sudo gedit /etc/udev/rules.d/85-usb-hd-fix.rules
and enter
BUS=="scsi", SYSFS{vendor}=="WD", RUN+="/usr/bin/usbhdfix %k"
and save the file.
Note: The vendor "WD" have to be replaced with the correct one, in my case "Seagate". Check the second reference link to find the correct one on your system.

Then create the shell script to be run when harddrive is detected:
Still in Terminal, type:
sudo gedit /usr/bin/usbhdfix
and enter
#!/bin/bash
echo 1024 > /sys/block/$1/device/max_sectors
echo 1 > /sys/block/$1/device/scsi_disk:*/allow_restart
and save the file.

Make the script executable:
Still in Terminal, enter
sudo chmod 0755 /usr/bin/usbhdfix
That's it!
It solved all problems for me
trolav is offline  
Old July 8th, 2007   #2
reclusivemonkey
Dark Roasted Ubuntu
 
reclusivemonkey's Avatar
 
Join Date: May 2006
Location: Triangle, West Yorks, UK
Beans: 978
Ubuntu 7.10 Gutsy Gibbon
Send a message via ICQ to reclusivemonkey Send a message via AIM to reclusivemonkey Send a message via MSN to reclusivemonkey Send a message via Yahoo to reclusivemonkey
Re: Trouble with external USB harddrive (Seagate FreeAgent) [SOLVED]

Thanks for posting your solution and for using the [SOLVED] thread tool. Glad you got it fixed =]
__________________
"The superior man understands what is right; the inferior man understands what will sell"
--Confucius
reclusivemonkey is offline  
Old July 11th, 2007   #3
p_ano
First Cup of Ubuntu
 
Join Date: Jul 2007
Beans: 7
Re: Trouble with external USB harddrive (Seagate FreeAgent) [SOLVED]

i've been having trouble with my freeagent, but it's a little different than the problems the rest of you guys have been having. it works fine for hours, but then one or two directories will disappear. unmounting and remounting makes the directories reappear. the drive worked fine in windows, so i assumed it must be a problem with linux and ntfs. i reformatted it as fat32 and still had the same problem. finally, i tried formatting it as ext3--still having the same problem.

trying this fix now.... fingers crossed...
p_ano is offline  
Old July 12th, 2007   #4
p_ano
First Cup of Ubuntu
 
Join Date: Jul 2007
Beans: 7
Re: Trouble with external USB harddrive (Seagate FreeAgent) [SOLVED]

36 hours later and my freeagent is running like a charm. still too early to get excited, but it seems like this fix has resolved my problems.

so, what exactly does "allow_restart" do? my guess is that it does a quick scan to see if the drive is responding, and if it isn't, then remounts the drive. i could be way off-base.
p_ano is offline  
Old July 14th, 2007   #5
p_ano
First Cup of Ubuntu
 
Join Date: Jul 2007
Beans: 7
Re: Trouble with external USB harddrive (Seagate FreeAgent) [SOLVED]

3 days later and still no problems. I feel confident that this issue is truly SOLVED.

thanks so much trolav.
p_ano is offline  
Old July 21st, 2007   #6
LukeKendall
5 Cups of Ubuntu
 
Join Date: Jul 2006
Location: Sydney
Beans: 37
Ubuntu 9.10 Karmic Koala
Re: Trouble with external USB harddrive (Seagate FreeAgent) [SOLVED]

Quote:
Originally Posted by p_ano View Post
3 days later and still no problems. I feel confident that this issue is truly SOLVED.

thanks so much trolav.
I'm having slightly similar problems with my Seagate Freeagent 500GB drive: the drive seems to work fine (e.g. I copied 100GB data to it), but after it goes idle, it goes into standby mode. I can use the scsitools command
Code:
scsi-spin -u /dev/sdb
# or
scsi-spin -u -f /dev/sdb
# (if scsi-spin thinks the device is properly mounted)
to force it to spin up out of standby mode (though the device name in /sys increments).

But my problem is that if I try to create the allow_restart file (as root) I just get "Permission denied":
Code:
root@potter:~# ls /sys/block/sdb/device/scsi_disk:4:0:0:0/
cache_type  device  FUA  uevent
root@potter:~# echo 1> /sys/block/sdb/device/scsi_disk:4:0:0:0/allow_restart
bash: /sys/block/sdb/device/scsi_disk:4:0:0:0/allow_restart: Permission denied
root@potter:~# ls /sys/block/sdb/device/scsi_disk:4:0:0:0/
cache_type  device  FUA  uevent
root@potter:~# echo 1 > /sys/class/scsi_disk/4\:0\:0\:0/allow_restart
bash: /sys/class/scsi_disk/4:0:0:0/allow_restart: Permission denied
Would this be because "allow_restart" is a feature of a newer kernel than what I'm running (2.6.17-11)?

luke
LukeKendall is offline  
Old July 21st, 2007   #7
LukeKendall
5 Cups of Ubuntu
 
Join Date: Jul 2006
Location: Sydney
Beans: 37
Ubuntu 9.10 Karmic Koala
Re: Trouble with external USB harddrive (Seagate FreeAgent) [SOLVED]

Quote:
Originally Posted by LukeKendall View Post
I'm having slightly similar problems with my Seagate Freeagent 500GB drive: the drive seems to work fine (e.g. I copied 100GB data to it), but after it goes idle, it goes into standby mode.
... stuff deleted ...

Would this be because "allow_restart" is a feature of a newer kernel than what I'm running (2.6.17-11)?

luke
After a little more reading it seems that the allow_restart option was only available for IBM arrays at first, then for Maxtor, and only later permitted (or is in the process of being permitted?) for all kinds of scsi discs. So yes, I think allow_restart needs kernel 2.6.21 or later.

For me, I can workaround by becoming root and then doing a umount/scis-spin/mount sequence like so:
Code:
root@potter:~# ls /data
ls: reading directory /data: Input/output error
root@potter:~# scsi-spin -u /dev/sdb
scsi-spin: device already in use (mounted partition)
root@potter:~# umount /dev/sdb1
root@potter:~# scsi-spin -u /dev/sdb
root@potter:~# mount /dev/sdb1
root@potter:~# ls /data
audio     codecs  gentoo         lost+found  old-logs  var
cdimages  emerge  linux-src      news        tmp
LukeKendall is offline  
Old July 30th, 2007   #8
TKill
First Cup of Ubuntu
 
Join Date: Jul 2007
Beans: 6
Ubuntu 7.10 Gutsy Gibbon
Re: Trouble with external USB harddrive (Seagate FreeAgent) [SOLVED]

I don't know why trolav's solution worked for you. For me, %k evaluates to sda1 (or sdb1), and /sys/block/sda1 does not exist. However, /sys/block/sda does, so changing the line in usbhdfix to
Code:
echo 1 > /sys/block/${1:0:3}/device/scsi_disk:*/allow_restart
does the trick for me (${1:0:3} trims "sda1" down to "sda"). Just thought there might be someone else benefiting from this...
TKill is offline  
Old August 1st, 2007   #9
RobertHentosh
First Cup of Ubuntu
 
Join Date: Aug 2007
Beans: 1
Re: Trouble with external USB harddrive (Seagate FreeAgent) [SOLVED]

Quote:
Originally Posted by TKill View Post
I don't know why trolav's solution worked for you. For me, %k evaluates to sda1 (or sdb1), and /sys/block/sda1 does not exist. However, /sys/block/sda does, so changing the line in usbhdfix to
Code:
echo 1 > /sys/block/${1:0:3}/device/scsi_disk:*/allow_restart
does the trick for me (${1:0:3} trims "sda1" down to "sda"). Just thought there might be someone else benefiting from this...
Actually, it will execute the script multiple times with the udev rule that is being used. In my case it excuted four times with the parameters "6:0:0:0", "sg0', "sdb" and "sdb1". This will not really cause harm since those subdirectories don't exist under /sys/block, but it is a hack and explains the reason why it works for others, since the sdb works and the others fail with file not found. (You can verify my findings by changing the /usr/bin/usbhdfix script to include "echo >> /tmp/usbhdfix-output" and you will see 4 or more lines depending on how the usb drive was partitioned)

A better solution would be to change the udev rule in 85-usb-hd-fix.rules to:

Code:
BUS=="scsi",KERNEL=="sd?",SYSFS{vendor}=="Seagate",SYSFS{model}=="FreeAgentDesktop",RUN+="/usr/bin/usbhdfix %k"
And leave the usbhdix script as is:

Code:
#!/bin/bash
echo 1024 > /sys/block/$1/device/max_sectors
echo 1    > /sys/block/$1/device/scsi_disk:*/allow_restart
RobertHentosh is offline  
Old August 1st, 2007   #10
TKill
First Cup of Ubuntu
 
Join Date: Jul 2007
Beans: 6
Ubuntu 7.10 Gutsy Gibbon
Re: Trouble with external USB harddrive (Seagate FreeAgent) [SOLVED]

Quote:
Originally Posted by RobertHentosh View Post
Actually, it will execute the script multiple times with the udev rule that is being used. In my case it excuted four times with the parameters "6:0:0:0", "sg0', "sdb" and "sdb1". This will not really cause harm since those subdirectories don't exist under /sys/block, but it is a hack and explains the reason why it works for others, since the sdb works and the others fail with file not found. (You can verify my findings by changing the /usr/bin/usbhdfix script to include "echo >> /tmp/usbhdfix-output" and you will see 4 or more lines depending on how the usb drive was partitioned)
Right you are, but my rule doesn't execute the script several times:
Code:
BUS=="scsi", KERNEL=="sd?1", SYSFS{vendor}=="Seagate", SYSFS{model}=="FreeAgentDesktop", SYSFS{rev}=="100D", SYMLINK+="usbhd1", RUN+="/usr/local/bin/usbhdfix %k"
The idea was that I also wanted to create a symlink that I could enter into /etc/fstab, since the disk sometimes comes up as sda1 and sometimes sdb1. I see clearly now why it worked for everyone else, but not for me..

The most proper solution is maybe to have two udev rules then; one for executing the script and one for creating the symlink? That is:

Code:
BUS=="scsi", KERNEL=="sd?", SYSFS{model}=="FreeAgentDesktop", RUN+="/usr/local/bin/usbhdfix %k"
BUS=="scsi", KERNEL=="sd?1", SYSFS{model}=="FreeAgentDesktop", SYMLINK+="usbhd1"
By the way, why would we like to have this line in the script?
Code:
echo 1024 > /sys/block/$1/device/max_sectors
I seem to be getting a lot of disk errors (the log says "mounting disk with errors. running e2fsck is recommended", or something, when I mount it). I have not added this line in the script, but in my mind, adding it couldn't make the case better, rather the opposite. Am I right?
TKill is offline  
 

Bookmarks

Thread Tools
Display Modes

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 On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:29 PM.


vBulletin ©2000 - 2010, Jelsoft Enterprises Ltd. Ubuntu Logo, Ubuntu and Canonical © Canonical Ltd. Tango Icons © Tango Desktop Project. lingonberry