Article View: es.comp.os.linux.redes
Article #91Re: Autodetección de chip de red en distro cutom
From: J.A. Gutierrez
Date: Thu, 27 Aug 2009 07:14
Date: Thu, 27 Aug 2009 07:14
286 lines
8756 bytes
8756 bytes
In es.comp.os.linux.redes xmontero <xmontero@dsitelecom.com> wrote:
:> � � � � el fichero de arranque rc.sysinit para que, una vez que /
:> � � � � esta montado en modo rw, modificar el alias de eth0 para que
:> � � � � apunte al modulo correcto en funcion de la salida de lspci.
: En primer lugar, gracias JA. Es un buen sitio por donde empezar...
: En segundo...
: Si hago por ejemplo lspci en mi m�quina, veo esto (among others):
: 00:13.0 Ethernet controller: Realtek Semiconductor Co., Ltd.
: RTL-8139/8139C/8139C+ (rev 10)
: 00:14.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL-8029
: (AS)
: Las preguntas que se me ocurren son:
: a) �El string "Ethernet controller" es determinante? Es decir, ese
: texto �lo pone el "sistema" o el string "Ethernet controller" est�
: hardcoded en la tarjeta?
Diria que si que lo es, de hecho yo uso "Ethernet" a secas.
En la tarjeta, lo unico que va hardcoded son los identificadores
binarios, que aparecen con "lspci -n" como cifras hexadecimales.
: b) Asumiendo que la parte "Ethernet controller" la pone el sistema,
: concluyo que la tarjeta pone strings como "Realtek Semiconductor Co.,
: Ltd. RTL-8139/8139C/8139C+ (rev 10)". �C�mo paso de ese string al
: nombre del m�dulo controlador? �Tengo que tener una tabla con todos o
: existe ya un mapeo que pueda utilizar? �o el lspci se invoca con
: par�metros para obtener los IDs num�ricos del "manufacturar", "model",
: etc?
Hasta donde yo se, no te queda mas remedio que tener una
tabla.
Las buenas noticias son que las cadenas que puedes esperar
encontrar, las puedes ver en /usr/share/hwdata/pci.ids, y
las malas es que hasta que no lo pruebes con cada modelo
concreto no estaras seguro de haber acertado con el modulo...
:> � � � � Si quieres tirar por este camino, te puedo enviar mas detalles
:> � � � � (incluyendo scripts completos) (para distribuciones basadas
:> � � � � en Red Hat, eso si)
: Pues ser�a un muy buen adelanto, toda la distro est� bastante "tuneada
: a mano", por lo que no me importa meterle mano en eso tambi�n.
: Puedo echarles un ojo y luego intentar adaptarlos a debian a ver si me
: aclaro, jeje.
Ahi va:
En /etc/rc.sysinit, despues del bloque "Start up swapping" y antes
del de "Set up binfmt_misc" (en realidad, deberia ir justo antes
del "Start up swapping", ya que tambien ajusto cosas de la particion
de swap):
# [ SPD
if [ -f /etc/sysconfig/config/hw.sh ]; then
/etc/sysconfig/config/hw.sh
fi
# SPD ]
El fichero /etc/sysconfig/config/hw.sh seria mas o menos asi:
---------------------------------------------------------------------------
--- hw.sh -----------------------------------------------------------------
#!/bin/sh
# exec > /root/log 2>&1
PATH=$PATH:/sbin
#
# /etc/sysconfig/config/hw.sh
# Version 0.0.5
# <spd@daphne.cps.unizar.es>
# Thu Sep 25 11:40:49 CEST 2008
# Thu Jan 8 14:26:39 CET 2009 - DELL support
#
# Fix some hardware settings
# To be executed from rc.sysinit after / is mounted rw and
# before network starts
#
# Since /usr/bin may not be mounted, we need to copy cmp to /bin
# and /usr/share/hwdata/pci.ids to $CFG_HW
#
CFG_HW=/etc/sysconfig/config/hw
if [ -f /clone ]
then
rm -f /var/lib/dbus/machine-id
fi
#if [ -f /3com ]
#then
# KERNEL=`uname -r`
# MODULES=/lib/modules/$KERNEL/kernel/drivers/net
# cp /root/3c59x.ko $MODULES/.
# /sbin/depmod > /dev/null 2>&1
# rm -f /3com
# echo 3Com fixed >&2
#fi
###########################################################################
#
# /etc/motd
#
/etc/sysconfig/config/mkmotd.sh > /etc/motd
chmod 644 /etc/motd
###########################################################################
#
# /etc/X11/xorg.conf
#
VGA=`lspci -i $CFG_HW/pci.ids | fgrep VGA`
case "_$VGA" in
_*Intel*2e12* )
XORG_CONF=xorg.conf.DELL
;;
_*Intel* )
XORG_CONF=xorg.conf.INTEL
;;
_*nVidia*NV15DDR* )
XORG_CONF=xorg.conf.NV15DDR
modprobe nvidiafb
;;
_*nVidia*NV17* )
XORG_CONF=xorg.conf.NV17
modprobe nvidiafb
;;
_*nVidia*NV5M64* )
XORG_CONF=xorg.conf.NV5M64
modprobe nvidiafb
;;
_*nVidia*0221* )
XORG_CONF=xorg.conf.NV44A
modprobe nvidiafb
;;
_*nVidia* )
XORG_CONF=xorg.conf.NV
modprobe nvidiafb
;;
_*VIA* )
XORG_CONF=xorg.conf.VIA
;;
*)
XORG_CONF=none
;;
esac
if [ "_$XORG_CONF" != "_none" ]
then
if cmp -s /etc/X11/xorg.conf $CFG_HW/$XORG_CONF
then
:
else
cp -p $CFG_HW/$XORG_CONF /etc/X11/xorg.conf
echo VGA $XORG_CONF fixed >&2
fi
fi
###########################################################################
#
# swap
#
SWAP=`fdisk -l /dev/sda | sed -ne 's,\(/dev/\)\([^\/ ]*[0-9]\) .*Linux swap.*,\2,p'`
if [ -z "$SWAP" ]
then
SWAP=`fdisk -l /dev/hda | sed -ne 's,\(/dev/\)\([^\/ ]*[0-9]\) .*Linux swap.*,\2,p'`
fi
SWAP_FSTAB=`sed -ne '/swap/s,\(/dev/\)\([^\/ ]*[0-9]\)\( .*swap.*\),\2,p' /etc/fstab`
if [ "_$SWAP" != "_$SWAP_FSTAB" ]
then
rm -rf /tmp/fstab.$$
if mkdir /tmp/fstab.$$
then
cp /etc/fstab /tmp/fstab.$$/fstab.orig
sed -e "s/$SWAP_FSTAB/$SWAP/" /etc/fstab > /tmp/fstab.$$/fstab && \
cat /tmp/fstab.$$/fstab > /etc/fstab
echo swap fixed >&2
fi
fi
###########################################################################
#
# Ethernet
#
if [ -f /etc/modprobe.conf ]
then
MODULES=/etc/modprobe.conf
else
MODULES=/etc/modules.conf
fi
NET=`lspci -i $CFG_HW/pci.ids | fgrep Ethernet`
if [ `echo "$NET" | wc -l` -gt 1 ]
then
:
# more than a single ethernet interface; unless /3com exists
# we will disable it
KERNEL=`uname -r`
MODULES=/lib/modules/$KERNEL/kernel/drivers/net
if [ -f /3com ]
then
if [ -f /clone ]
then
mv $MODULES/3c59x.ko /root
/sbin/depmod > /dev/null 2>&1
rm -f /3com
echo 3Com disabled >&2
fi
fi
if [ -f $MODULES/3c59x.ko ]
then
NET=3Com
else
NET=Intel
fi
else
case "_$NET" in
_*Intel*10de*)
ETHER=e1000e
;;
_*Intel* )
ETHER=e100
;;
_*3Com* )
ETHER=3c59x
;;
*)
ETHER=none
;;
esac
ETHER_CURRENT=`awk '/^alias eth0/ {print $3}' $MODULES`
if [ "_$ETHER" != "_$ETHER_CURRENT" ]
then
rm -rf /tmp/ether.$$
if mkdir /tmp/ether.$$
then
cp $MODULES /tmp/ether.$$/modprobe.orig
sed -e "s/$ETHER_CURRENT/$ETHER/" $MODULES >\
/tmp/ether.$$/modprobe.conf && \
cat /tmp/ether.$$/modprobe.conf > $MODULES
echo ethernet fixed >&2
fi
fi
###########################################################################
--- hw.sh -----------------------------------------------------------------
---------------------------------------------------------------------------
: Las distros tipo Knoppix, �utilizan esta metodolog�a o alg�n otro
: sistema de autodetecci�n?
La verdad es que no tengo ni idea.
En las de tipo "Red Hat" viene de serie "kudzu", que es un
sistema de autodetecion de cambios de hardware, pero yo no
lo uso por que prefiero un sistema que controle yo al 100%
y que no entre en ningun momento en modo interactivo...
--
PGP and other useless info at \
http://webdiis.unizar.es/~spd/ \
finger://daphne.cps.unizar.es/spd \ Timeo Danaos et dona ferentes
ftp://ivo.cps.unizar.es/pub/ \ (Virgilio)
Technical Details
Message-ID:
<h75bp4$565$1@aioe.org>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!club-internet.fr!feedme-small.clubint.net!aioe.org!not-for-mailReferences:
<7de267fe-119b-4415-91f8-616e1de37148@b14g2000yqd.googlegroups.com> <h707dc$fqo$1@aioe.org> <7c260bd3-b9db-42d0-9660-eb0a313f4b51@a26g2000yqn.googlegroups.com>Show Full Headers
Complete Article Headers
X-Google-Thread: f4243d8982,7c05c622c835fe80
X-Google-Attributes: gidf4243d8982,public,usenet
X-Google-NewGroupId: yes
X-Google-Language: SPANISH,ASCII
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!club-internet.fr!feedme-small.clubint.net!aioe.org!not-for-mail
From: "J.A. Gutierrez" <spd@daphne.cps.unizar.es>
Newsgroups: es.comp.os.linux.redes,es.comp.os.linux.instalacion
Subject: Re: Autodetección de chip de red en distro cutom
Date: Thu, 27 Aug 2009 07:14:45 +0000 (UTC)
Organization: Rank
Lines: 286
Message-ID: <h75bp4$565$1@aioe.org>
References: <7de267fe-119b-4415-91f8-616e1de37148@b14g2000yqd.googlegroups.com> <h707dc$fqo$1@aioe.org> <7c260bd3-b9db-42d0-9660-eb0a313f4b51@a26g2000yqn.googlegroups.com>
NNTP-Posting-Host: MCosCHQmnr2+xGPgpnz89Q.user.aioe.org
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Complaints-To: abuse@aioe.org
X-Notice: Filtered by postfilter v. 0.8.0
Cancel-Lock: sha1:IcT0KXmfuSYPbHqQd4cf4NCb6Vk=
User-Agent: tin/1.4.7-20030322 ("Suggestions") (UNIX) (IRIX64/6.5 (IP30))