Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Mon 20 Oct 2014, 23:05
All times are UTC - 4
 Forum index » House Training » Users ( For the regulars )
USB device non-detection at boot.[SOLVED]
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 2 [20 Posts]   Goto page: 1, 2 Next
Author Message
greengeek

Joined: 20 Jul 2010
Posts: 2594
Location: New Zealand

PostPosted: Wed 10 Oct 2012, 13:07    Post subject:  USB device non-detection at boot.[SOLVED]
Subject description: Possibility of "USB wakeup" code?
 

I am trying to set up a self-booting "server" using puppy and often find that some usb sticks are not detected at boot time, but DO get detected if I unplug them after boot, and replug them ("hotplug"?)

I wondered if it might be possible to make a script that has the ability to "tickle" the usb ports in such a way that the system thinks that a new device has been plugged in - kicking off the detection process without having to physically unplug the device?

My plan would be to place this script in the /root/Startup folder so that it ran after X started. (I would probably then follow this script with some code that I got from sunburnt which automounts all drives.)

(I know that the sensitivity of usb device detection varies between versions of puppy, but I would like to try to find a piece of code that is likely to run ok on a wide range of puppies - my server is likely to be built on PupServer435 which is based on 4.3.1 or I might even use an older more barebones puppy so it would be good if the code worked on older versions, but I have also had this problem on some more recent puppies too)

Last edited by greengeek on Fri 12 Oct 2012, 16:23; edited 1 time in total
Back to top
View user's profile Send private message 
rcrsn51


Joined: 05 Sep 2006
Posts: 9199
Location: Stratford, Ontario

PostPosted: Wed 10 Oct 2012, 13:28    Post subject:  

Maybe something simpler would work. Go into your auto-mount script and put a "sleep 5" before the lines that mount the USB drives.
Back to top
View user's profile Send private message 
greengeek

Joined: 20 Jul 2010
Posts: 2594
Location: New Zealand

PostPosted: Wed 10 Oct 2012, 13:52    Post subject:  

The problem is that I can't mount what has not yet been detected. I find that if the operating system itself has not detected the usb drive during the boot sequence then none of the various mount methods will work. However, if I then pull the drive out and plug it back in, an icon appears on the desktop and I can proceed to mount.
Back to top
View user's profile Send private message 
musher0


Joined: 04 Jan 2009
Posts: 4254
Location: Gatineau (Qc), Canada

PostPosted: Wed 10 Oct 2012, 14:01    Post subject:  

Hi!

Would that be a Seagate FreeAgent external USB hard drive, by any chance ? They're notorious for "sleeping on the job", and Linux has apparently no way to wake them up besides reboot. (With the exception of dpup 4.85, in my experience.)

Best.

_________________
"Logical entities must not be multiplied needlessly." / "Il ne faut pas multiplier les êtres logiques inutilement." (Ockham)
Back to top
View user's profile Send private message Visit poster's website 
greengeek

Joined: 20 Jul 2010
Posts: 2594
Location: New Zealand

PostPosted: Wed 10 Oct 2012, 15:09    Post subject:  

One of the devices I am mostly having this issue with is a Transcend 1TB external usb drive. I have it partitioned with one large NTFS, one small FAT32, and one Linux swap partition. ( I don't know which brand of HDD or controller chip it contains). I don't know if the non-detection is caused by the device itself or something to do with the partitioning (unfortunately I can't fiddle too much with it because it contains all my daughters uni work and media files).

However, I do have similar problems with different usb sticks - some of which have only a single FAT32 partition.

Some puppies seem very good at boot-time usb detection (Grays NOP511 is another lightweight puppy I am trialling for server use), but older puppies seem more variable. I just wanted to find a way to "simulate" a usb "hotplug" action so that the device detection routine gets triggered.
Back to top
View user's profile Send private message 
rcrsn51


Joined: 05 Sep 2006
Posts: 9199
Location: Stratford, Ontario

PostPosted: Wed 10 Oct 2012, 16:03    Post subject:  

Have a look at this. But it may not fix your problem - if a device hasn't been detected yet, you probably can't reset it.

[Edit] I found a site that claims you can restart your USB system by reloading the module.
Code:
rmmod ehci_hcd
modprobe ehci_hcd

Then maybe a sleep command so the drives can be re-detected before you try to mount them.
Back to top
View user's profile Send private message 
greengeek

Joined: 20 Jul 2010
Posts: 2594
Location: New Zealand

PostPosted: Thu 11 Oct 2012, 14:02    Post subject:  

Thanks for those suggestions. The usbreset pet unfortunately did not work on the PupServer435 I am trialling because it is based on a "4" series puppy and does not understand the lsusb command.

However the rmmod/modprobe of the usb driver DID work. It allowed the missing partition to reappear. Thanks!

(I need to report back further once I have done some more testing because the cluster of symptoms I originally had seems to have changed - at the moment the one consistent symptom I have is that the usb stick is detected, but only 2 of the 3 partitions are detected - at least until I do the rmmod trick you suggested, after which all 3 partitions are back.

I need to quantify exactly what was happening across the three troublesome usb devices, two machines, and several remastered versions of Pupserver435 and NOP511. Will report back)
Back to top
View user's profile Send private message 
greengeek

Joined: 20 Jul 2010
Posts: 2594
Location: New Zealand

PostPosted: Fri 12 Oct 2012, 14:51    Post subject:  

OK, here is a script that uses the rmmod to remove the usb driver, modprobe to reload the driver, then sunburnt's second version of mnt-all code to mount all partitions.

I've tested it with PupServer435 and it is successfully getting me past my problem. I also tested it on Slacko but found that the "sleep 5" after the reload usb had to be lengthened to "sleep 10"

I will be putting this in my startup folder.

(more testing to come re the varying nature of the symptoms regarding which partitions fail to detect..)

CAUTION: this script does not attempt to first unmount any partitions that may already have been mounted, and there may be a risk that this could cause a problem, depending on when you run it. (I don't actually know how big a risk this might be. Maybe none at all. However I recommend making sure that the pfix-fsck option is active in the menu.lst entry to correct any filesystem irregularities that might result. I plan to use this script immediately after boot, and before any other programmes are activated)

Code:
#!/bin/sh
#########   This script unloads the usb driver then reloads it then mounts all partitions found.
#(Thanks sunburnt for the mnt-all code and rcrsn51 for the ehci_hcd idea...)
###      Use at your own risk... No warranty!


# For auto. mounting at bootup, put this script in Puppy folder: /root/Startup

# After bootup, if other drives are plugged in, run mnt-all again to mount them.

#SECTION 1 - remove the usb driver, then reload it
rmmod ehci_hcd
sleep 2
modprobe ehci_hcd
sleep 5

#SECTION 2 -  automount all drives and partitions
# This gets a list of all partition info. except swap and optical drives.
List=`probepart |egrep -v '(swap|sr|none)'`


# This "for" loop steps through the list one partiton at a time.
for Line in $List
do
   Part=${Line%%\|*}                     # Get only partition.
   Part=${Part##*/}

   [ "`df |grep $Part`" ]&& continue         # Don`t mount, if done already.

   Type=${Line%\|*}                     # Get file system type.
   Type=${Type##*\|}

   [ -d /mnt/$Part ]|| mkdir /mnt/$Part      # Make the mount dir., if none.
   mount -t $Type /dev/$Part /mnt/$Part            # Mount the partition.
   echo "# Mount Partition:  $Part    Type:  $Type"   # Display mount info.
done

Last edited by greengeek on Fri 12 Oct 2012, 16:09; edited 1 time in total
Back to top
View user's profile Send private message 
rcrsn51


Joined: 05 Sep 2006
Posts: 9199
Location: Stratford, Ontario

PostPosted: Fri 12 Oct 2012, 15:38    Post subject:  

Nice work.

This module reloading technique would probably also work for people whose USB wifi adapters occasionally lock up.
Back to top
View user's profile Send private message 
musher0


Joined: 04 Jan 2009
Posts: 4254
Location: Gatineau (Qc), Canada

PostPosted: Mon 15 Oct 2012, 16:43    Post subject:  

Hello, greengeek.

Concerning
Quote:
> CAUTION: this script does not attempt to first unmount any partitions that may already have been mounted, and there may be a risk that this could cause a problem, depending on when you run it. (I don't actually know how big a risk this might be. Maybe none at all.


the user could issue
Code:
umount -a

before using your script, no?

The $HOME and swap disks (or $HOME and the disk the swap file is on) will remain on, but the other ones will close.

That said, I agree with a fsck at reboot.

BFN.

_________________
"Logical entities must not be multiplied needlessly." / "Il ne faut pas multiplier les êtres logiques inutilement." (Ockham)
Back to top
View user's profile Send private message Visit poster's website 
musher0


Joined: 04 Jan 2009
Posts: 4254
Location: Gatineau (Qc), Canada

PostPosted: Mon 15 Oct 2012, 17:30    Post subject:  

BTW, in case anybody needs to know how to (re)wake up a 160 Gb FreeAgent USB drive under Linux, it's here: Smile

http://alienghic.livejournal.com/382903.html

BFN.

_________________
"Logical entities must not be multiplied needlessly." / "Il ne faut pas multiplier les êtres logiques inutilement." (Ockham)
Back to top
View user's profile Send private message Visit poster's website 
greengeek

Joined: 20 Jul 2010
Posts: 2594
Location: New Zealand

PostPosted: Sat 20 Oct 2012, 20:36    Post subject:  

Hi Musher0, I've just been trying inserting "umount -a" into the script before the usb reset, but getting some strange system hangs etc (when using the script on PupServer 435), so I then tried manually using umount -a in a terminal on my normal Slacko installation - and I got a lot of messages discussing the unmounting of pup-ro, pup-rw etc etc or similar messages (which looks to my untrained eye like unmounting filesystems rather than just drives...). Do you think the umount -a is safe to use or might there be a "softer" way to unmount only the drives?

Thanks for any suggestions.
Back to top
View user's profile Send private message 
musher0


Joined: 04 Jan 2009
Posts: 4254
Location: Gatineau (Qc), Canada

PostPosted: Sun 21 Oct 2012, 01:00    Post subject:  

Hello, greegeek.

> might there be a "softer" way to unmount only the drives?

Strange. I've used the unmount -a command a lot and never had a problem.

Maybe you need something like this, then:

Code:
#!/bin/sh
# ~/my-applications/bin/umount-only-disks.sh
####

df -H -T -x squashfs -x tmpfs -x rootfs -x aufs -P | grep "/mnt/s" | cut -f2 -d'm' > spc_dsq.txt
while read line
do
umount /m$line
done < spc_dsq.txt
rm -f spc_dsq.txt


Explanation:

We do a df avoiding the looped systems (-x means "exclude");
we "grep" only the lines with a /mnt in them (real disks);
we cut the resulting lines after the "m";
we read the lines one after other from the mini-log file we created,
adding the necessary characters removed by the cut command;
and umount does its job;
we clean up after ourselves once finished.

Of course, my code is crude, but it seems to do the job. (See illustration with xv set/unset.)

I hope this helps.
umount-only-disks.jpg
 Description   
 Filesize   30.28 KB
 Viewed   637 Time(s)

umount-only-disks.jpg


_________________
"Logical entities must not be multiplied needlessly." / "Il ne faut pas multiplier les êtres logiques inutilement." (Ockham)
Back to top
View user's profile Send private message Visit poster's website 
greengeek

Joined: 20 Jul 2010
Posts: 2594
Location: New Zealand

PostPosted: Sun 21 Oct 2012, 03:12    Post subject:  

Thanks Musher0, that seems to have improved the behaviour on Slacko. The script now is:
Code:
#!/bin/sh
#########   This script unmounts all disks, reboots the usb driver then reloads it then mounts all partitions found.
#(Thanks sunburnt for the mnt-all code, rcrsn51 for the ehci_hcd idea and musher0 for the unmount code)
###      Use at your own risk... No warranty!


# For auto. mounting at bootup, put this script in Puppy folder: /root/Startup

# After bootup, if other drives are plugged in, run mnt-all again to mount them.
#PREPARATION - unmount devices already mountd during boot
sleep 2
# ~/my-applications/bin/umount-only-disks.sh
####Musher0 code to unmount only disks
df -H -T -x squashfs -x tmpfs -x rootfs -x aufs -P | grep "/mnt/s" | cut -f2 -d'm' > spc_dsq.txt
while read line
do
umount /m$line
done < spc_dsq.txt
rm -f spc_dsq.txt
sleep 5

#SECTION 1 - remove the usb driver, then reload it
rmmod ehci_hcd
sleep 2
modprobe ehci_hcd
sleep 10

#SECTION 2 -  automount all drives and partitions
# This gets a list of all partition info. except swap and optical drives.
List=`probepart |egrep -v '(swap|sr|none)'`


# This "for" loop steps through the list one partiton at a time.
for Line in $List
do
   Part=${Line%%\|*}                     # Get only partition.
   Part=${Part##*/}

   [ "`df |grep $Part`" ]&& continue         # Don`t mount, if done already.

   Type=${Line%\|*}                     # Get file system type.
   Type=${Type##*\|}

   [ -d /mnt/$Part ]|| mkdir /mnt/$Part      # Make the mount dir., if none.
   mount -t $Type /dev/$Part /mnt/$Part            # Mount the partition.
   echo "# Mount Partition:  $Part    Type:  $Type"   # Display mount info.
done
Back to top
View user's profile Send private message 
musher0


Joined: 04 Jan 2009
Posts: 4254
Location: Gatineau (Qc), Canada

PostPosted: Sun 21 Oct 2012, 09:24    Post subject:  

Nice! The modest man forgot to include his name and the date! Wink
_________________
"Logical entities must not be multiplied needlessly." / "Il ne faut pas multiplier les êtres logiques inutilement." (Ockham)
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 1 of 2 [20 Posts]   Goto page: 1, 2 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » Users ( For the regulars )
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1001s ][ Queries: 13 (0.0104s) ][ GZIP on ]