- Power on/off USB ports
- 4 Answers 4
- 5 Ways To Fix USB Port Not Working on Linux 2023
- How To Fix USB Port Not Working on Linux 2023
- #1. Is Your Device Detected By Linux?
- #2. How to Check USB Port
- #3. Repair Damaged USB Hardware
- #4. Restart Linux To Fix the USB Port
- #5. Checking USB Device Driver In Linux
- Conclusion:
Power on/off USB ports
Is it possible to on/off a specific USB port using the terminal in Ubuntu? lsusb displays the following result:
Bus 001 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub Bus 002 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 001 Device 003: ID 2232:1020 Bus 002 Device 009: ID 0bc2:a013 Seagate RSS LLC Bus 002 Device 003: ID 0a5c:219c Broadcom Corp.
Seagate is my external hard disk drive. Can I power it off in the terminal? I tried Controlling a USB power supply (on/off) with Linux. But I am confused about what should be replaced in place of usbX .
4 Answers 4
All of the previous answers talk about a USB suspend mechanism, i.e. a «logical power-off», they will never physically cut the VBUS +5V from the USB port.
Only a few hubs can actually cut VBUS as described here.
The hubpower tool can do it (if the hub supports it).
After running into the same problem, I found that the commands should be entered differently so that «sudo» would apply rights appropriately.
echo 0 | sudo tee /sys/bus/usb/devices/usb2/power/autosuspend_delay_ms
will apply root rights to the «tee» command which will write the 0 into the specified file, replacing anything that is currently there. To append, use the tee command with option -a.
for info see the man page of tee
The tee command will have the side effect of also printing to the screen. If you want, dd of=/sys/bus/. will write only to the file, and nowhere else.
Actually usbX is nothing but the USB ports numbers where X denotes the number like 1 or 2 and so on. For example, usb1 and usb2 for ports 1 and 2. In general, a laptop may have three or four USB ports with USB 2.0 and USB 3.0 ports.
In Ubuntu, usb1 , usb2 . usbX are the links to /sys/devices/pci000:00/* . To understand it well, run this command:
So to enable/disable USB ports usbX will be replaced with usb1 when you want to enable/disable USB Port Number 1 (or refer Stack Exchange):
Edit: Thanks to Stefan Denchev to tell the correct way to echo some text to a file using sudo. (Check his comment also.) You should not get the permission denied message now.
sudo sh -c "echo '0' > /sys/bus/usb/devices/usb1/power/autosuspend_delay_ms" sudo sh -c "echo 'auto' > /sys/bus/usb/devices/usb1/power/control"
After seeing your lsusb result, it looks like your Seagate device is connected to Port No. 2 , so you need to disable usb2 . Then the commands would be:
sudo sh -c "echo '0' > /sys/bus/usb/devices/usb2/power/autosuspend_delay_ms" sudo sh -c "echo 'auto' > /sys/bus/usb/devices/usb2/power/control"
Thanks. If I try echo «0» > «/sys/bus/usb/devices/usb2/power/autosuspend_delay_ms» the output is bash: /sys/bus/usb/devices/usb2/power/autosuspend_delay_ms: Permission denied
Actually I didn’t try to enable/disable any ports in Linux.. My motto was to make you clear about usbX problem. If you are much clear about the commands that you grabbed from StackOverflow then only you should give it a try. Any way now I am also interested to know which is actual command to enable/disable ports. I’ll reply you soon, when it works for me. Tell then you unplug your device and try again. or try the first answer given at stackoverflow .
udisksctl has power-off flag, which I suggest you use in conjunction with unmount
power-off Arranges for the drive to be safely removed and powered off. On the OS side this includes ensuring that no process is using the drive, then requesting that in-flight buffers and caches are committed to stable storage. The exact steps for powering off the drive depends on the drive itself and the interconnect used. For drives connected through USB, the effect is that the USB device will be deconfigured followed by disabling the upstream hub port it is connected to
Here’s me unmounting my USB jumpdrive and then powering it off
testdir:$ lsusb Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 001 Device 009: ID 154b:007a PNY Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub testdir:$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 111.8G 0 disk └─sda1 8:1 0 111.8G 0 part / sdb 8:16 1 30G 0 disk └─sdb1 8:17 1 30G 0 part /media/xieerqi/6A32C4555E1C5B4D sr0 11:0 1 1024M 0 rom testdir:$ udisksctl unmount -b /dev/sdb1 && udisksctl power-off -b /dev/sdb1 Unmounted /dev/sdb1. testdir:$ lsusb Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub testdir:$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 111.8G 0 disk └─sda1 8:1 0 111.8G 0 part / sr0 11:0 1 1024M 0 rom testdir:$
5 Ways To Fix USB Port Not Working on Linux 2023
5 Ways To Fix USB Port Not Working on Linux – If you have connected a USB flash drive or keyboard, or mouse to your Linux PC. But nothing happened. Maybe you’re confused about what’s going on right now. Why is your Linux computer not detecting the device? Is this a Linux problem, or has your USB device stopped working? Here are the steps to fix the USB port not working on Linux
How To Fix USB Port Not Working on Linux 2023
Disk drives, card readers, phones, media players, and media peripherals. All of them are useful, but if there is a problem with your USB port or system drivers, it won’t work. This can be very frustrating if you use a Bluetooth keyboard or mouse (with a USB dongle) because it means digging for wired USB alternatives.
However, it may not be a non-working port. Maybe the USB device you are using has developed an error and cannot be detected. Dealing with USB issues can be tricky, but it’s not impossible to diagnose the error and make the necessary repairs. There are five steps to follow to fix USB problems on Linux:
- Confirm the USB port is detected
- Make necessary repairs to the port
- Repair or repair USB device
- Restart your Linux operating system
- Confirm the presence of the device driver
Let’s look at each of these in turn and learn how to handle dodgy USB devices in Linux.
#1. Is Your Device Detected By Linux?
The first thing to check after inserting your USB device into a Linux computer is to check if the device is detected. USB device detection is usually not as verbal or audible as in Windows or macOS, which means that you should frequently check that the device has been picked up by the operating system. Fortunately, it’s simple.
First, remove the USB device you asked about. Then, open a terminal window and enter the command “list USB”:
Record the results, then connect the USB device, and run lsusb again. This time, you will see additional devices listed, with Bus ID, Device ID, USB ID, and description. If you can’t figure out the enhancement (you might have an internal USB device, maybe Ethernet), try a different command.
The dmesg command will list the USB devices connected to your system. It will also cover non-USB hardware, but unfortunately offers a lot of information. To solve this, you can try
Finally, you can count on a more user-friendly one
It’s like a cross between the dmesg and lsusb commands, listing connected USB hardware with enough information to identify them. So, is the USB you guys connected listed here? If not, then maybe the port is damaged or there is a problem with the device. Similarly, the device may not be compatible with Linux.
#2. How to Check USB Port
If the USB device doesn’t show up, it could be caused by a problem with the USB port. The best way to quickly check is to use a different USB port on the same computer. If the USB hardware is now detected, then you know you have a problem with the other USB port.
If other USB ports are not available, you should try USB devices on another PC or laptop. However, this may not be ideal, as you may only have a Windows or macOS computer as an alternative.
Since some USB devices are unusable on Linux, it will be difficult to tell whether it is a USB device or a USB port that is causing you problems. For best results, if possible stick to Linux-compatible hardware when troubleshooting USB devices.
#3. Repair Damaged USB Hardware
If your USB device is damaged, you have two options: repair or restore. A repair usually involves checking USB ports, as well as devices that are currently not working. Repairs will almost always center around USB cables, and ports on your computer.
However, USB cables can usually be replaced, while ports can be repaired. Physical inspection of the USB device is a good idea. The cable must be sturdy, without splitting; plugs must be solid, with metal parts firmly attached.
USB ports, meanwhile, should be checked with your PC turned off, and disconnected from the mains supply. Check if the port is plugged in correctly; a wobbly USB port is an indication of shabby hardware.
If the USB port is loose, you may be able to solder it back into place. Of course, you should already know how to solder, never try a DIY job without prior experience. Also, check for dust and dirt on your USB ports, especially those on the back of your PC where dust collects regularly.
Dust is the enemy of PCs, so it’s a good idea to keep your system in a dust-free environment to boost performance. Since dust can enter your PC via the USB slot, take the time to keep this port clean. Use compressed air to remove dust and dirt.
Can you restore your USB device? If the device is new, then maybe. The problem is, unless it’s explicitly labeled as running on Linux, then, the retailer is unlikely to accept returns. You may need to be a little selective with the facts you share with them.
#4. Restart Linux To Fix the USB Port
In some cases like if you are using a laptop the power issue might affect its ability to detect USB devices. The autosuspend setting is designed to reduce power usage on Linux laptops, but it can prove counterproductive. So, what can you do?
First, check if autosuspend is causing the problem. You can do this by rebooting your computer, if the USB device is working, then the USB port is receiving power. The next step is to make sure this doesn’t happen again. The following command line tricks are for both Ubuntu and Debian, so check the correct procedure on your Linux distribution of choice. Open a terminal window and enter:
cat /sys/module/usbcore/parameters/autosuspend
It should return a value of 2, which means autosuspend is enabled. You can fix this by editing the grub file. Enter:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash usbcore.autosuspend=-1"
Press Ctrl + X to save the file, and exit. Next, update-grub:
When that’s done, restart Ubuntu. After rebooting, log into your account and enter the cat command again:
cat /sys/module/usbcore/parameters/autosuspend
This time, the value returned should be -1. You have disabled autosuspend, so USB devices connected to your laptop shouldn’t fail due to power issues.
#5. Checking USB Device Driver In Linux
Once upon a time, USB devices didn’t often work on Linux. Only devices manufactured by OEMs interested in Linux (perhaps they use it for development) offer Linux drivers. Today, things are very different, with most manufacturers offering Linux drivers.
In most cases, it is already available on your Linux operating system, via the kernel. You don’t need to install any USB drivers. If the driver is not available, you may be able to find it by contacting the USB device manufacturer.
Conclusion:
Following the steps above, it can actually solve the problem of the USB port not working on your Linux PC. But with built-in drivers and broad support for various types of USB devices, it should be easy to diagnose problems with your computer’s USB hardware. While faulty hardware may need to be repaired or exchanged, software repairs are also available.
Don’t forget to bookmark and always visit every day Technowizah.com because you can find here the latest Tech Computer Android games How-to Guide Tips&Tricks Software Review etc, Which we update every day.