Pour voir ce qui est inclu dans le initrd pour notre Kernel
zcat /boot/initrd-$(uname -r).img | cpio -itv
Nous allons ajouter dans l'exemple suivant le module raid1.ko
cd /boot mkinitrd --with=raid1 initrd-raid1-$(uname -r).img $(uname -r)
Attention de ne pas ecraser l'ancien initrd
Note : Les modules dispo pour le kernel se trouvent dans /lib/modules/$(uname -r)/kernel/
Editer /boot/grub/grub.conf et ajouter un nouveau bloc pour tenir compte de nouvel initrd
title Red Hat Enterprise Linux ES (2.6.9-42.EL) root (hd0,0) kernel /vmlinuz-2.6.9-42.EL ro root=/dev/rootvg/lvroot initrd /initrd-raid1-2.6.9-42.EL.img
Rebooter
Autre exemple : Pour charger un module au démarrage du système :
mkinitrd --preload=megaraid initrd-megaraid-$(uname -r).img $(uname -r)
Pour résumer les actions suivantes sont à effecter:
initrd
.ko
ou .o
)module-info
et pcitable
Récupérer le fichier initrd que l'on veux recupérer par dans le cd de linux dans ./Image/pxeboot/initrd.img
Renommer et décomprésser l'archive initrd.img
mv initrd.img initrd.img.gz gunzip initrd.img.gz
Monter le FS initrd.img
mkdir mount-initrd mount -o loop initrd.img mount-initrd
Le fichier mount-initrd/modules/modules.cgz
contient tous les modules, nous allons le copier en dehors du FS
cp mount-initrd/modules/modules.cgz .
Renommer et décomprésser l'archive modules.cgz
mv modules.cgz modules.gz gunzip modules.gz cpio -idv < modules
Copier les fichier .o
ou .ko
que l'on veut ajouter dans le repertoire décompressé
cp bnx2.o ./2.4.21-37.ELBOOT/i386/
Ajouter les informations sur le matériel dans mount-initrd/modules/module-info
, par exemple pour une carte Broadcom NetXtreme II :
bnx2 eth "Broadcom NetXtreme II Gigabit Ethernet Driver"
Mettre à jour le fichier mount-initrd/modules/pcitable
(info dispo par le contructeur ou par la commande : grep bnx2 /usr/share/hwdata/pcitable
)
0x14e4 0x164a "bnx2" "Broadcom Corpoation|NetXtreme II BCM5706 Gigabit Ethernet" 0x14e4 0x164c "bnx2" "Broadcom Corpoation|NetXtreme II BCM5708 Gigabit Ethernet" 0x14e4 0x16aa "bnx2" "Broadcom Corpoation|NetXtreme II BCM5706S Gigabit Ethernet" 0x14e4 0x16ac "bnx2" "Broadcom Corpoation|NetXtreme II BCM5708S Gigabit Ethernet"
Contruire une nouvelle archive modules.cgz
find ./2.4.21-37.ELBOOT |cpio -ocv > modules gzip -9 modules
Copier modules.cgz
dans le FS
mv modules.gz mount-initrd/modules/modules.cgz
Démonter le FS et recompresser l'archive initrd.img
umount mount-initrd gzip -9 initrd.img mv initrd.img.gz initrd.img
Editer inittab :
vim /etc/inittab
Mettre en commentaire :
#ca::ctrlaltdel:/sbin/shutdown -t3 -r now
Prise en compte de la modification :
telinit q