How to configure devices in Linux (I)

Source: Internet
Author: User
Article Title: how to configure devices in Linux (I ). Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
The configuration process of a device in Linux is to use this information to configure the driver and working method of the device after detecting the device type and current working parameters of the device, (For device detection process, see how to implement automatic hardware detection in Linux). To complete such a task, you need to do the following:
  
The first is a detailed device information file, which describes the device ID, the device driver corresponding to the device ID, and the device configuration parameters (device options) detailed descriptions of device settings, device configuration methods, aliases of devices, and the number of the primary devices.
  
In the Linux kernel, kmod is used to automatically load the device module. The general working mechanism is: when the device module is referenced for the first time, the kernel uses the system command/sbin/modprobe to load the device module. To make this mechanism work normally, you first need to use depmod-a to establish the file modules that expresses the dependencies between modules. dep, and then in/etc/modules. set the correct device alias in conf (about/etc/modules. for more information about conf, see appendix A. If you need to set parameters for the device. For example, when you set the NIC, the NIC Driver is ne2k-pci, And the NIC device alias is eth0, then in the file/etc/modules. add the alias eth0 ne2k-pci to conf and set the ne2000 compatible PCI Nic so that when a program attempts to access the network, the kernel automatically loads the NIC Driver ne2k-pci.
  
The second is to set the configuration script file for the device based on the device type and the installed Linux system version (different Linux distributions have different configuration script files for the same device.
  
   1. Configure the keyboard
  
1.1 configure the keyboard Device Module
  
There are three common types of keyboards: vintage five-pin keyboard, ps/2 keyboard, and usb mouse. For the first two types of keyboards, the current Linux releases usually package the device modules they need into the kernel. Therefore, the keyboard works properly without the need to insert additional modules. For a usb keyboard, to make it work properly, you must first Insert the corresponding device module.
  
For a usb keyboard, If You Want To manually load the module to work, you must first Insert the usb Bridge module, and then you must also insert the usb KBD keyboard module. o, and keybdev. o, so that the usb keyboard can work normally. In this case, the system command is as follows:
/Sbin/modprobe usbkbd
/Sbin/modprobe keybdev
  
For 2.2.x series kernels, if the kmod of the kernel is to be automatically loaded as needed, it must be in/etc/modules. set the alias usb-interface in the conf file, which corresponds to the bridge module you are using. For example, if the bridge type is UHCI, add the device alias to/etc/modules. conf:
Alias usb-interface usb-uhci
  
For the 2.4.x series kernel, the device alias is changed:
Alias usb-controller usb-uhci
After this alias is set, the usb device is detected automatically when the system starts. When the system detects that the connected device is supported by the system, the system automatically inserts the required module.
  
1.2 keyboard configuration file
  
The keyboard configuration file/etc/sysconfig/keyboard has very simple content. The optional configuration item is KEYTABLE (the content of this file varies with the release version, but this field is the most important ). For example, when KEYTABLE = "us" is set, the system uses an American keyboard.
  
Then, to correctly use the function keys on the keyboard, you also need to call the command dumpkeys to generate the file/etc/sysconfig/console/default. kmap.
/Usr/bin/dumpkeys>/etc/sysconfig/console/default. kmap
This file describes the Keyboard Scan code of the keyboard and the corresponding Keyboard Scan code after the keyboard is modified.
  
Similarly, in order for the keyboard to work normally in the X system environment, you may also need to set the keyboard in the X system. In this case, you must use xmodmap to set the correct keyboard ing. For example,
/Usr/X11R6/bin/xmodmap/usr/share/xmodmap. fr
Set the keyboard in your X system to a French keyboard.
  
After the/etc/sysconfig/keyboard file is correctly configured, the configuration program of X system configures the section on keyboard configuration in X according to the information in this file. If the content of this file is incorrect or the file does not exist, X system cannot be started and configured.
  
   2. Configure the mouse
  
2.1 Basic mouse information
  
Linux supports four different bus mouse hardware interfaces: Inport (Microsoft), Logitech, PS/2, and ATI-XL. The 2.4 kernel also supports the IBM PC110 digital board and Apple Desktop mouse.
  
Inport mice
Inport mice contains most old Microsoft mouse types. Inport mice is usually connected to the interface card of the motherboard. If the mouse wire connector is round and has 9 needles, it may be Inport mice.
Logitech mice
PS/2 mice
ATI combo video/mice
IBM PC110 palmtop digitizer
Apple Desktop Mouse
Hybrid Mice
For the mouse protocol, most bus mice use the BusMouse protocol. Some ancient Logitech mice use the MouseSystems protocol, while some older Microsoft mice use the Logitech protocol. The PS/2 mouse always uses the PS/2 protocol.
  
Device Files corresponding to different types of Mouse:
  
Number of the primary device of the Interface Type Device
Logitech/dev/logibm 10 0
PS/2/dev/psaux 10 1
Inport/dev/inportbm 10 2
ATI-XL/dev/atibm 10 3
USB mouse/dev/input/mice 13 63
  
Table 2-1
  
  
Command to create the corresponding device:
  
Mknod/dev/logimm c 10 0
Mknod/dev/psaux c 10 1
Mknod/dev/inportbm c 10 2
Mknod/dev/atibm c 10 3
Mknod/dev/input/mice c 13 63
  
After the device file corresponding to the mouse is created, many programs now use/dev/mouse as the default device file, to make the mouse work properly, you need to create a symbolic connection/dev/mouse pointing to the real mouse device file. For example, for the ps/2 mouse,/dev/mouse points to/dev/psaux, for the usb mouse,/dev/mouse/points to/dev/input/mice, for serial mouse/dev/mouse pointing to/dev/ttyS0. These files may be different for different linux Release versions. The above introduction is mainly based on the Redhat release configuration.
  
For the three most common mouse types: Serial mouse, PS/2 mouse, and USB mouse, the support for PS/2 mouse is usually in the kernel, therefore, you do not need to insert a device module before the mouse operation. However, for the other two types of mouse, the insert module operation is generally required. For serial mouse, you must first insert module serial. o,
/Sbin/modprobe serial
  
After a module is successfully inserted, if the serial port mouse supports the plug-and-play serial port protocol, you can read the mouse type information from the serial port (/dev/ttyS *), and then the resulting information, complete the configuration file with the mouse. To make the USB mouse work properly, you must first Insert the module USB mouse. o and mousedev. o
/Sbin/modprobe usbmouse
/Sbin/modprobe mousedev
Similarly, to enable automatic loading of the mouse driver, you also need to create a usb-interface (usb-controller) alias in the/etc/modules. conf file.
  
2.2 mouse configuration file
  
The correct mouse configuration must generate the configuration file/etc/sysconfig/mouse, which includes the following options: MOUSETYPE, XMOUSETYPE, FULLNAME, XEMU3, and DEVICE. The mouse configuration file is also the basis of the mouse configuration section in the X configuration file. Without this file, many X configuration programs will not work.
  
MOUSETYPE =
Configure the mouse type, including ps/2, Busmouse, imps2, netmouse, Microsoft, Logitech, MouseMan, MMHitTab, MouseSystems, pnp, logim, ms3, and MMSeries.
  
XMOUSETYPE =
The mouse types configured in the X system, including MouseMan, IntelliMouse, MMSeries, MMHittab, Logitech, MouseMan, Microsoft, MouseSystems, PS/2, and BusMouse.
  
FULLNAME =
The full name of the mouse device. For example, for a common PS/2 mouse, its full name is PS/2 | Standard.
  
XEMU3 =
Whether to simulate a three-Key mouse. The optional parameter is yes or no.
  
DEVICE =
The device file corresponding to the mouse. For example. For a common PS/2 mouse, the device file is psaux.
  
2.3 tips for mouse Configuration
  
With gpm, you can use the mouse in command line mode. In this way, you can use the mouse to perform operations such as cutting and pasting on the console. For example, for the ps/2 mouse, the configuration method is:
Gpm-t ps/2-m/dev/psaux
If the-m option is not specified, the system searches for the file/dev/mouse.
  
Irregular mouse movement may be caused by incorrect mouse settings. For example, the new Logitech mouse does not use the Logitech protocol, but uses the Microsoft protocol (MouseMan ). If your mouse moves irregularly, you may need to replace the value specified by MouseType (XMouseType) first.
In system X, if you need to change the left and right mouse buttons, you can execute xmodmap-e "pointer = 3 2 1 ".
  
   3 Nic configuration process
  
3.1 configure the NIC Device Module
  
According to the bus type, the current Ethernet Card mainly includes PCI Nic, ISA Nic and PCMCIA Nic. To make these NICs work properly, set the device alias eth0 in/etc/modules. conf and the device parameters to be passed to the driver. In this way, when the kernel needs to use the driver, the kernel service kmod uses the system command modprobe (insmod) to automatically load the required device module.
  
When configuring the NIC, if the NIC can be automatically detected, you only need to identify the corresponding device driver in the device description file, then configure the NIC based on this information. However, this method is not suitable for general isa bus ne2000 compatible NICs, because they generally do not meet isapnp specifications during design, so they cannot read their device information. However, this type of NIC generally uses ne as the device driver, but to make it work properly, you must specify the io address and occupied irq.
  
For example, for ne2000-compatible isa NICs, such as DE220X, their drivers are ne. To make the network adapter work properly, add the following to the/etc/modules. conf file:
Alias eth0 ne
Options ne io = 0x300 irq = 5
  
Generally, for such NICs, The NICs can work normally only when the correct I/O address space is specified. This

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.