求助:如何在Ubuntu开机前禁用故障的笔记本内置键盘?
Got it, let's tackle this frustrating stuck-key problem on your Ubuntu laptop. Since the internal keyboard is acting up even before the system finishes booting, we need to disable it early in the boot process—here are the most reliable methods to get this fixed:
This is the quickest way to disable the internal keyboard right at boot time, and works for most laptops.
Temporary Disable (Single Boot, Test First)
Use this to confirm the fix works before making it permanent:
- When the GRUB menu appears (hold the
Shiftkey during boot if you don't see it), select your Ubuntu entry and presseto enter edit mode. - Find the line starting with
linux(it'll look something likelinux /boot/vmlinuz-xxxx root=UUID=xxxx quiet splash). - Add the
i8042.nokbdparameter to the end of this line. - Press
Ctrl+XorF10to boot. Your internal keyboard should be disabled, and your USB keyboard will work normally.
Permanent Disable (Auto-Apply on Every Boot)
Once you've confirmed the temporary fix works, make it permanent:
- Log into Ubuntu with your external keyboard, open a terminal, and edit the GRUB config file:
sudo nano /etc/default/grub - Locate the line
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"and addi8042.nokbdinside the quotes. It should look like:GRUB_CMDLINE_LINUX_DEFAULT="quiet splash i8042.nokbd" - Save and exit: press
Ctrl+O, hit Enter, thenCtrl+X. - Update GRUB to apply the changes:
sudo update-grub - Reboot your system—your internal keyboard will stay disabled on every boot.
If the GRUB method disables your external keyboard too (rare, but possible if your USB keyboard uses the i8042 interface), use this method to target only the internal keyboard.
Identify your internal keyboard's details:
- Open a terminal and run:
xinput list - Look for your internal keyboard (usually named something like "AT Translated Set 2 keyboard"). Note its name or the
idnumber. - To confirm, you can run
xinput list-props <device-id>(replace<device-id>with the number you found) to verify it's the internal one.
- Open a terminal and run:
Create a udev rule:
- Open a terminal and create a new rule file:
sudo nano /etc/udev/rules.d/99-disable-internal-keyboard.rules - Add one of the following lines (choose based on what you identified):
- By device name:
SUBSYSTEM=="input", ATTRS{name}=="AT Translated Set 2 keyboard", RUN+="/bin/sh -c 'echo 0 > /sys$devpath/disable'" - By vendor/product ID (find these via
lsusbif the name doesn't work):SUBSYSTEM=="input", ATTRS{idVendor}=="xxxx", ATTRS{idProduct}=="yyyy", ENV{ID_INPUT_KEYBOARD}="1", RUN+="/bin/sh -c 'echo 0 > /sys$devpath/disable'"
- By device name:
- Save and exit the file (
Ctrl+O, Enter,Ctrl+X).
- Open a terminal and create a new rule file:
Apply the rule immediately:
sudo udevadm control --reload-rules && sudo udevadm triggerReboot—only your internal keyboard will be disabled.
- If the
i8042.nokbdparameter breaks your external keyboard, switch to the udev rule method—it's more targeted. - To re-enable the internal keyboard later:
- For GRUB: Remove
i8042.nokbdfrom the GRUB config and runsudo update-grub. - For udev: Delete the rule file you created and reboot.
- For GRUB: Remove
- If GRUB doesn't appear by default, hold
Shiftduring boot to bring it up.
内容的提问来源于stack exchange,提问作者Quack

