Page 1 of 1

USB handling differences? [Solved]

Posted: Mon Oct 20, 2014 16:18
by viking
I put this in off topic because it is not really a support question just a request for information if anyone knows the answer, but feel free to move it to hardware if you think it more appropriate there.

I mentioned recently in another post that I just installed an SSD in my laptop. Obviously this left me with a spare drive which seemed a shame to waste as it is still in good condition, so I bought a cheap USB3 to sata drive enclosure to put the old drive into with a view to using it as a backup device.

Testing this today I got strange results. In Sabayon and Manjaro, coincidentally or perhaps not I don't know, both systemd distros, the device was not recognised when plugged into a USB3 port. I tried several different ports, and in every case the power light came on and I could hear the disk rotating, but the device partitions would not show up in Thunar, and any attempt to make them show up, for instance by refreshing the Thunar home page resulted in an instant system crash to a black screen loaded with 'fffffff' type memory addresses (on both distros).

But in both Ubuntu and Mint (neither of which use systemd) the device worked normally plugged into the same USB sockets, I could mount and use the partitions on the disk without any failures at all.

That is strange enough, but even more perplexing is that when I tried the device in a USB2 socket with Sabayon, it worked normally :?:

So what could be causing this? Does systemd have anything to do with USB handling or is that way off track? Why does USB2 work when USB3 wont - it is a USB3 device after all?

The device is not independently powered, so is there some difference in power output between USB2 and USB3? But if that is the case why would it work normally on Ubuntu and Mint but not Manjaro and Sabayon?

Re: USB handling differences?

Posted: Tue Oct 21, 2014 13:40
by svantoviit
viking wrote:…the device was not recognised when plugged into a USB3 port.
You mean probably, that it wasn't mounted automatically.

You have to check with dmsg or journalctl ev. lsusb.
Another useful commands are mount or fdisk in this case.

Re: USB handling differences?

Posted: Tue Oct 21, 2014 14:14
by viking
svantoviit, you are single handedly giving me so much assistance that I am embarrassed to disagree with you, but I must.

I consider automounting of usb devices to be the work of the devil, and do my level best to disable it everywhere I can - an increasingly difficult battle as it happens - so no, automounting is not what I am referring to, I am referring to the disk being seen at all, by anything, including the kernel.

The situation is slightly worse than I stated in my previous post, I initially thought that it was an action such as refreshing the Thunar page that made the machine crash, but it isn't that. If you plug the drive into a USB3 slot and then completely leave the machine alone it will crash within 30 seconds or so - Manjaro does the same. This doesn't give you much time for experimentation with any command, so it is impossible to investigate your suggestions, I am also not very happy about having the machine crash so often, it isn't good for the external or internal disk, so I fear I will have to use the USB2 slot or use one of my debian based distros when I want to access this new device.

But thank you for replying.

Re: USB handling differences? [Solved]

Posted: Wed Oct 22, 2014 11:50
by viking
I solved my own problem. It isn't systemd but a kernel problem.

When I installed and booted the 3.13.11 kernel (the same kernel version used by Ubuntu and Mint) the device is properly recognised and configured and fully usable. When I go back to the 3.16 kernel it fails and causes a near instant crash.

So my guess is that there has been some change in between the two kernels (my guess is irq handling) that makes the device unusable on kernel 3.16.

I see 3.17 is available now so I will try that and see if that works.

Re: USB handling differences? [Solved]

Posted: Wed Oct 22, 2014 12:09
by viking
No, the 3.17 kernel is affected as well, so I think I will just stick with the 3.13 one for now, I can see no advantages in the later ones only problems. I will keep 3.17 around as a backup but boot 3.13 as default.

Re: USB handling differences? [Solved]

Posted: Thu Oct 23, 2014 13:36
by viking
I found a better solution to this on the Arch forum (better because it allows you to keep running the up to date kernel). It works in Manjaro, but the technique is not exactly transferable to Sabayon due to differences in handling. This is the technique I used in Manjaro:

Code: Select all

 First obtain the Vendor and Product ID of the misbehaving device using lsusb, then

touch /etc/modprobe.d/ignore_uas.conf

leafpad /etc/modprobe.d/ignore_uas.conf

Add the line:

options usb-storage quirks=Vendor_ID:Product_ID:u

Substituting the Vendor and Product ID you noted earlier.

In a root terminal cd to /boot and run:

mv initramfs-316-x86_64.img  initramfs-316-x86_64.img.old

Then in the same terminal run:

mkinitcpio -g initramfs-316-x86_64.img
It is all doable in Sabayon right up until the last line, but Sabayon has no command 'mkinitcpio'. I understand that the equivalent would be

Code: Select all

genkernel initramfs
But running this gives me the following errors

Code: Select all

genkernel initramfs
* Gentoo Linux Genkernel; Version 58
* Running with options: initramfs

* Using genkernel.conf from /etc/genkernel.conf
* Sourcing arch-specific from /usr/share/genkernel/arch/x86_64/ ..
* Sourcing arch-specific modules_load from /usr/share/genkernel/arch/x86_64/modules_load ..

* Linux Kernel 3.17.0-sabayon for x86_64...
* .. with config file /usr/share/genkernel/arch/x86_64/kernel-config
* busybox: >> Applying patches...
*           - 1.18.1-openvt.diff
*           - busybox-1.20.1-strict-atime.patch
*           - busybox-1.20.2-glibc-sys-resource.patch
*           - busybox-1.7.4-signal-hack.patch
* busybox: >> Configuring...
* ERROR: Failed to compile the "oldconfig" target...
* -- Grepping log... --
*           - busybox-1.7.4-signal-hack.patch
* busybox: >> Configuring...
*COMMAND: make -j2 CC="gcc" LD="ld" AS="as"  
*  HOSTCC  scripts/basic/fixdep
*/bin/sh: gcc: command not found
*scripts/ recipe for target 'scripts/basic/fixdep' failed
*make[1]: *** [scripts/basic/fixdep] Error 127
*Makefile:356: recipe for target 'scripts_basic' failed
*make: *** [scripts_basic] Error 2
Can anyone tell me what to do about them or suggest another technique to recompile the initramfs?

BTW the error is something to do with 'uas' or 'usb attached scsi' and it is know to the kernel developers.

Re: USB handling differences? [Solved]

Posted: Thu Oct 23, 2014 17:16
by viking
Well the answer to the above question is fairly simple. Compiling goes a lot more smoothly if you have a compiler installed (gcc).

However this technique does not seem to work on Sabayon even with a recompiled initramfs, the reasons for that are beyond my level of understanding.

Shame though, it is a very neat workround on Manjaro.

Re: USB handling differences? [Solved]

Posted: Thu Oct 23, 2014 17:52
by viking
Correction to my last post, the answer is not beyond my level of understanding, it is simply that in Manjaro the usb_storage module is loaded through modprobe whereas in Sabayon it is built in to the kernel. Therefore trying to influence it through 'modprobe.d' is futile. How to influence it as a builtin, I have no idea, I could recompile the entire kernel to remove its builtin status, but that is really a sledgehammer to crack a nut, it is not worth the effort.

Run out of ideas now.

Re: USB handling differences? [Solved]

Posted: Fri Oct 24, 2014 7:48
by Fitzcarraldo
Ah, but you can pass parameters to drivers that are built-in to the kernel rather than built as kernel modules. See, for examples, my posts Re: Request for advice on making a Media Centre and Would a quirk do it?. So, in order to experiment, you could first edit /boot/grub/grub.cfg and add what is known as a kernel quirk 'usb-storage.quirks=Vendor_ID:Product_ID:u' to the end of the kernel boot line. If that works, you can add it 'properly' by adding it to /etc/default/sabayon-grub and running the command 'grub2-mkconfig -o /boot/grub/grub.cfg'.

Re: USB handling differences? [Solved]

Posted: Fri Oct 24, 2014 10:40
by viking
Hey man that solution works perfectly!! Thank you so much :D