hkphooey
December 11th, 2022, 07:07 AM
I've been doing dist-upgrades for the last few years, but this year when going from 20.04 to 22.04 a bunch of things broke, so I decided to install fresh. I was sideswiped by my USB wifi dongle, which was working fine before, but caused me no end of headaches with the new install. Long story short, it didn't boot up after reinstall and the reason was that the USB wifi dongle appeared in 'storage device' mode. But instead of just moving on the OS sat there and did nothing for 3 minutes, with a black screen, no error messages, causing me to reinstall several times, until once I booted up with the dongle disconnected, and figured out what the problem was.
Previously adding a line to /usr/lib/udev/rules.d/40-usb_modeswitch.rules had worked fine.
ATTR{idVendor}=="0bda", ATTR{idProduct}=="1a2b", RUN+="/usr/sbin/usb_modeswitch -K -v 0bda -p 1a2b"
Once added, my 20.04 Ubuntu would detect the modem, and switch it to product ID 0bda:c811 and would proceed with the boot. Obviously this is the first thing I tried. Obviously this did not work.
Next searches around the internet suggested adding a file in /etc/usb_modeswitch.d/
cat /etc/usb_modeswitch.d/0bda:1a2b
# Dlink adapter
DefaultVendor=0x0bda
DefaultProduct=0x1a2b
TargetVendor=0x0bda
TargetProduct=0xc811
StandardEject=1
This also didn't work. Although now it was working on a reboot, but not on a cold boot.
It seems that during the boot usb modeswitch wasn't firing off quick enough. I then tried forcing it manually with init.d
cat /etc/init.d/10_usbmodeswitch
# Grrr
/usr/sbin/usb_modeswitch -K -v 0bda -p 1a2b
Once again, no joy, so my final attempt was to try and manipulate systemd to firing off usb modeswitch, according to other posts around the internet.
cat /usr/lib/systemd/system/usb_modeswitch@.service
[Unit]
Description=USB_ModeSwitch_%i
Documentation=man:usb_modeswitch_dispatcher(1)
# added
DefaultDependencies=no
After=local-fs.target systemd-sysctl.service
Before=network-pre.target shutdown.target
Wants=network-pre.target
Conflicts=shutdown.target
[Service]
Type=oneshot
ExecStart=/usr/sbin/usb_modeswitch_dispatcher --switch-mode %i
# Testing
#ExecStart=/bin/echo "usb_modeswitch.service: device name is %i"
Environment="TMPDIR=/run"
Once again no good. So I've exhausted my options at the moment. It seems there are two problems:
USB modeswitch is running too late in the boot process to catch the dongle at the correct time.
Something in the disk mounting/inspection procedure freezes when it sees the disk and doesn't proceed.
So now I'm inviting suggestions for anything else I can try. It seems to be related to something which changed between 20.04 and 22.04
Oh, I've also tried
- turning on logging in /etc/usb_modeswitch.conf which results in zero logs. Maybe that's broken.
- Setting SetStorageDelay=4 in that same file, as it mentions a possible issue with USB 3.
- Trying a USB 2 port instead of USB 3.
Previously adding a line to /usr/lib/udev/rules.d/40-usb_modeswitch.rules had worked fine.
ATTR{idVendor}=="0bda", ATTR{idProduct}=="1a2b", RUN+="/usr/sbin/usb_modeswitch -K -v 0bda -p 1a2b"
Once added, my 20.04 Ubuntu would detect the modem, and switch it to product ID 0bda:c811 and would proceed with the boot. Obviously this is the first thing I tried. Obviously this did not work.
Next searches around the internet suggested adding a file in /etc/usb_modeswitch.d/
cat /etc/usb_modeswitch.d/0bda:1a2b
# Dlink adapter
DefaultVendor=0x0bda
DefaultProduct=0x1a2b
TargetVendor=0x0bda
TargetProduct=0xc811
StandardEject=1
This also didn't work. Although now it was working on a reboot, but not on a cold boot.
It seems that during the boot usb modeswitch wasn't firing off quick enough. I then tried forcing it manually with init.d
cat /etc/init.d/10_usbmodeswitch
# Grrr
/usr/sbin/usb_modeswitch -K -v 0bda -p 1a2b
Once again, no joy, so my final attempt was to try and manipulate systemd to firing off usb modeswitch, according to other posts around the internet.
cat /usr/lib/systemd/system/usb_modeswitch@.service
[Unit]
Description=USB_ModeSwitch_%i
Documentation=man:usb_modeswitch_dispatcher(1)
# added
DefaultDependencies=no
After=local-fs.target systemd-sysctl.service
Before=network-pre.target shutdown.target
Wants=network-pre.target
Conflicts=shutdown.target
[Service]
Type=oneshot
ExecStart=/usr/sbin/usb_modeswitch_dispatcher --switch-mode %i
# Testing
#ExecStart=/bin/echo "usb_modeswitch.service: device name is %i"
Environment="TMPDIR=/run"
Once again no good. So I've exhausted my options at the moment. It seems there are two problems:
USB modeswitch is running too late in the boot process to catch the dongle at the correct time.
Something in the disk mounting/inspection procedure freezes when it sees the disk and doesn't proceed.
So now I'm inviting suggestions for anything else I can try. It seems to be related to something which changed between 20.04 and 22.04
Oh, I've also tried
- turning on logging in /etc/usb_modeswitch.conf which results in zero logs. Maybe that's broken.
- Setting SetStorageDelay=4 in that same file, as it mentions a possible issue with USB 3.
- Trying a USB 2 port instead of USB 3.