📄 hotplug.txt
字号:
MANUAL LOADING, DOCKING STATIONS-------------------------------- Manual loading is used for built-in network interfaces thatare only use at specific time, and that you want disabled the rest ofthe time. We assume that you still use modules so that when theinterface is not used you can remove the driver from the kernel. First, you need to set the configuration for those interfaces,the same way it's done for other network interfaces. The maindifference is that you need to specify that those interfaces shouldnot be enabled at boot time. It's also a good idea to disable Hotpluginit scripts. With Debian, you just need to make sure that the 'auto"keyword doesn't apply to this interface. If you use drivers statically built in the kernel, make surethat ifrename runs at boot time (see CONFIGURATION FROM INITSCRIPTS). Once it's done, you can just enable and disable thoseinterfaces with 'ifup ethX' and 'ifdown ethX'. If you use both a modular system, make sure that the'on-demand' module loading is properly configured :--------- /etc/modprobe.d/local or /etc/modprobe.conf ------# HP 100VG J2585B PCI cardalias eth2 hp100# AMD AMD PCnet LANCE PCI cardalias eth4 pcnet32------------------------------------------------------------ Then, you should instruct 'ifup' to load module and useifrename prior to configuring the interface, and remove the modulewhen going down. With Debian, this is done with :--------- /etc/network/interfaces -----------# AMD AMD PCnet LANCE PCI card# noautoiface eth4 inet dhcp pre-up /sbin/ifrename -p -n eth4 post-down /sbin/modprobe -r eth4# HP 100VG J2585B PCI card# noautoiface eth2 inet static address 10.0.0.2 netmask 255.255.255.0 broadcast 10.0.0.255 gateway 10.0.0.1 pre-up /sbin/ifrename -p -n eth2 post-down /sbin/modprobe -r eth2--------------------------------------------- We use the '-n' option of ifrename to specify the name of theinterface after renaming. This assume that the mapping for thoseinterfaces don't use wildcards. The '-p' option make sure ifrenameprobes the module prior to using it. Using "modprobe -r" make sure that if the driver is composedof multiple module all the modules are unloaded. To enable the interface, just use :-----------------------------------ifup eth4----------------------------------- And to disable the interface :-----------------------------------ifdown eth4----------------------------------- This solution is obviously Debian specific, but could beadapted to other distributions. If you can't manage to get yourdistributions to use those tricks, you can do things manually. If you don't use Hotplug, you enable an interface with :-----------------------------------modprobe eth4ifrenameifup eth4----------------------------------- If you use hotplug, you only need to do :-----------------------------------modprobe eth4----------------------------------- On the other hand, disabling the interface is done with :-----------------------------------ifdown eth4modprobe -r eth4----------------------------------- Docking stations for laptops may contain built-ininterfaces. My previous laptop had one, and Linux had no support forit. After docking, I was able to bring up the network ISA card in thedocking station. However, with most laptops and version of Linux, the issue isthat after docking, the new devices are not seen. The solutions is toforce a rescan of the PCI bus. Documentation is unclear on that, maybe'scanpci' may help. To be able to simply manage my docking station, I had createdtwo little scripts to enable and disable my network interface. After docking, you would run :-------- /sbin/dock ----------------------------#!/bin/shmodprobe eth4ifrenameifup eth4------------------------------------------------ And prior to undocking, you would run :-------- /sbin/undock ----------------------------#!/bin/shifdown eth4modprobe -r eth4------------------------------------------------ Thanks to 'ifrename', the network interface in your dock willalways be properly configured regardless of if you have a Pcmcianetwork card in the Pcmcia slot or not.SCHEMES (MULTI-CONFIG)---------------------- Most Ethernet cards will only connect to a single network, orcan use DHCP to be auto-configured. With Wireless Cards, it's muchmore likely that you will need multiple configurations, for example atwork, at home and on-the-go. Most distributions have various level of support for suchschemes. Some distributions offer simple network schemes, while otheroffer "overall" schemes changing the whole configuration. I documentthe support for schemes in various distributions in the fileDISTRIBUTIONS.txt. You can also use tools such as ifplugd, waproamd orwlandetect. Those tools are a kind of "wireless-DHCP", they attempt toautomatically detect the proper wireless configuration and applyit. Most will also attempt to detect network changes. The main limitation of those tools is that they offer verylittle manual control. If two valid alternatives are possible, youcan't switch between them. If a configuration can't be detected, theyusually fail. That's the same concept as using DHCP versus Static IPaddresses. Some people are very happy with DHCP, my style is Static IPaddresses. If you use Debian and want to use simple manual schemes, theseare the things you need to do. 1) Make sure that 'ifscheme' and 'ifscheme-mapping' areinstalled on the system. You may find them in a separate tar file onmy web site. 2) Check the path for 'ifscheme-mapping' (using whereis). 3) Modify you /etc/network/interface to add proper mapping andconfiguration.------- /etc/network/interfaces ----------------------# Enable Hotplug support (Sarge and later)mapping hotplug script echo# SMC 2835W wireless CardBus cardmapping prism0 script /sbin/ifscheme-mappingiface prism0-any inet dhcp wireless-essid any wireless-mode managediface prism0-adhoc inet static address 10.0.1.2 network 10.0.1.0 netmask 255.255.255.0 broadcast 10.0.1.255 wireless-essid THE_ESSID wireless-mode ad-hoc wireless-channel 5iface prism0-other inet static address 10.10.10.2 network 10.10.10.0 netmask 255.255.255.0 broadcast 10.10.10.255 wireless-essid ANOTHER_ESSID wireless-mode ad-hoc wireless-key "s:secure"------------------------------------------------------FIRMWARE LOADING---------------- A lot of modern wireless card don't have built in firmware andneed firmware loading. Recent kernels (2.6.X) have a firmwareloader. These are a few notes on how to use it. First, read the documentation coming with your driver, becauseeach driver has specificities (like the name of the firmware file itrequires). Some drivers may offer additional ways to load thefirmware, but in the long term things should be standardised aroundthe hotplug method to simplify packaging in distributions. You need to compile your kernel with firmware loading(CONFIG_FW_LOADER in "Generic Driver Options"). If your driver wasbuilt from the kernel, chances are that it enabled this featurealready. Make sure you boot from this new kernel. The 'sysfs' file system must be mounted. The easiest is tomount it at boot time, add a line for it in /etc/fstab :-------- /etc/fstab ------------------------------sysfs /sys sysfs defaults 0 0-------------------------------------------------- Then, you add the firmware file in the directory where it'sexpected, which is /usr/lib/hotplug/firmware/ in most cases. Most distributions nowadays have a version of the Hotplugscripts that knows how to deal with firmware. If it is not the case,just grab the 'firmware.agent' file from an alternate source and copyit into your /etc/hotplug directory (make sure it's executable). You can try the canonical version : http://linux-hotplug.sourceforge.net/ Or Debian's version : http://packages.debian.org/unstable/admin/hotplug Note that firmware loading will usually only work withinterfaces that are fully managed by Hotplug. This is the only way toensure the that proper sequence of action is happening in the rightorder every time. Firmware loading may not work properly forinterfaces configured in the init scripts. This means that if you have a built-in interface that requirefirmware loading, you should just use manage those interfaces likeremovable interfaces (see section above). However, interfaceconfiguration need to be explicitly triggered at boot time. One possibility is to set-up Hotplug to be run from the initscript at boot time. This is usually an option for recentdistributions (it's not the case for Hotplug in Debian 3.0). But, wehave seen that this has some issues. The other possibility is to use an hybrid between the initscript method and the hotplug method. First, you need to add an aliasfor the driver in /etc/modprobe.conf. Then, you need to specify amapping for this interface in /etc/iftab, and specify a configurationfor this interface and that it is enabled at boot time. Lastly,you make sure that the network init scripts run 'ifrename-p'. 'ifrename' will trigger the module to load, and all the Hotplugevents will be generated properly to configure the interface.DEVICES WITH MULTIPLE NAMES--------------------------- Some wireless drivers offer multiple network interfaces forthe same device. A classical example is the Aironet driver thatcreates a 'ethX' and 'wifiY' for each card. 'ifrename' allows you a finer selection of interfaces than'nameif'. For example, to only rename the pseudo-Ethernet networkinterface name of the Aironet driver, you would do :--------- /etc/iftab -----------------------# Cisco Aironet 350 wireless Pcmcia cardairo* mac 00:07:0E:* arp 1--------------------------------------------- After that, your device would be available through 'eth0' and'wifi0'. You can rename both interfaces. You just need to remember that'ifrename' starts matching from the last line of the file, so youwould do :--------- /etc/iftab -----------------------# Cisco Aironet 350 wireless Pcmcia cardwifi* mac 00:07:0E:*airo* mac 00:07:0E:* arp 1--------------------------------------------- The current version of 'ifrename' supports only the most usefulselectors, but it is architectured such as adding selectors is relativelytrivial. If you find a case that 'ifrename' can't handle, you shouldjust extend it.DEVICES WITHOUT MAC ADDRESSES----------------------------- Most Ethernet and Wireless devices have a fixed and unique MACaddress, and it is therefore advised to name them based on thiscriteria. However, there are also network interfaces that don't have afixed and unique MAC address, for example Ethernet over USB, IP overFireWire, PPP and tunnel interfaces. The driver for those devices creates the interface with a namespecific to the driver, such as ppp* for PPP interfaces and usb* forEthernet over USB, and therefore they are easy to identify andconfigure, and few users feel the need to rename them. Moreover, someof them, such as PPP, have their own configuration scripts andmethodology addressing their unique needs. There are a few cases where you might want to renameinterfaces without MAC addresses. One example is two Ethernet over USBdongles. The way to do this is to use alternate ifrenameselectors. Choosing the right selector depends on what you want toachieve. A quick theoretical example to illustrate :--------- /etc/iftab -----------------------# All other usbnet devicesusb* driver usbnet# Specific usbnet devicesusb-p firmware "Prolific PL-2301/PL-2302"usb-4 bus-info usb-00:02.0-1.4---------------------------------------------TROUBLESHOOTING--------------- If your interface doesn't show up as expected with ifconfig,you will need to find out why. First, you need to be familiar with thesequence of actions in the system and find which one did not happen. You need to check that the driver module(s) was loaded using'lsmod'. You need to check if the interface was properly renamed with'ifrename'. You can use 'ifrename -D -V' to debug your /etc/iftab. Get the list of interfaces on your system with 'ifconfig -a'or 'cat /proc/net/dev', and check if an interface is using the nameyou assigned or 'eth0'. Check any suspicious interfaces with 'ifconfigeth0', and check its MAC address. Note that some rare drivers don'thave a proper MAC address before brought up, which fools ifrename. Verify that no line in /etc/iftab matches the all-zero MACaddress. The all-zero MAC address matches the loopback interface 'lo'and various pseudo network devices, renaming the loopback interface ishighly discouraged. You need to check which configuration was given to theinterface using 'ifconfig' and 'iwconfig'. The Hotplug subsystem has also good debugging facilities. To enable Hotplug debugging, just make sure the variable DEBUGis defined in /sbin/hotplug :--------- /sbin/hotplug --------------------------------- /sbin/hotplug-old Tue Mar 26 09:00:20 2002+++ /sbin/hotplug Fri Feb 20 18:40:38 2004@@ -22,7 +22,7 @@ cd /etc/hotplug . hotplug.functions -# DEBUG=yes export DEBUG+DEBUG=yes export DEBUG if [ "$DEBUG" != "" ]; then mesg "arguments ($*) env (`env`)"------------------------------------------------------ Then, you can check your message logs for Hotplug events with'tail -f /var/log/messages'. Verify that the various Hotplug eventshappen as expected (pci, firmware, net...), and verify the logmessages from 'net.agent'. Have fun... Jean
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -