Linux and Initrd used to access disk : how does it work ?
Hello,
I've been fighting for a few days with binary modules from some manufacturer for hardware support of disk controler, and I'm at a point where I need some more understanding.
1 - My machine contains an Adaptec SATA Raid based on Marvel 88SX60xx
so I need to used the aar81xxx binary module,
2 - This module is presented as required to access the disk (when
installing a RH kernel, it says that no disk is present unless the module is loaded),
3 - When booting the kernel from disk after installation, the module is
loaded so the machine can access the disk...
... BUT ... how can the machine /
- boot the kernel,
- access the initrd image and uncompress it,
- read the binary module inside and load it
BEFORE loading the module itself, if it is mandatory to access the disk.
And if it is not, then how can I do the installation ?
I suspect this should be fairly trivial, but I've been thinking about for long, and it looks like chicken and egg to me...
Any help ?
Regards,
Paul
Paul Rolland, rol(at)as2917.net
ex-AS2917 Network administrator and Peering Coordinator
--
Please no HTML, I'm not a browser - Pas d'HTML, je ne suis pas un navigateur "Some people dream of success... while others wake up and work hard at it"
"I worry about my child and the Internet all the time, even though she's too young to have logged on yet. Here's what I worry about. I worry that 10 or 15 years from now, she will come to me and say 'Daddy, where were you when they took freedom of the press away from the Internet?'" --Mike Godwin, Electronic Frontier Foundation
Quoted 24 lines · Paul Rolland
Hello,
I've been fighting for a few days with binary modules from some manufacturer for hardware support of disk controler, and I'm at a point where I need some more understanding.
1 - My machine contains an Adaptec SATA Raid based on Marvel 88SX60xx
so I need to used the aar81xxx binary module,2 - This module is presented as required to access the disk (when
installing a RH kernel, it says that no disk is present unless the module is loaded),3 - When booting the kernel from disk after installation, the module is
loaded so the machine can access the disk...... BUT ... how can the machine /
- boot the kernel,
- access the initrd image and uncompress it,
- read the binary module inside and load it
BEFORE loading the module itself, if it is mandatory to access the disk.And if it is not, then how can I do the installation ?
Quoted 7 lines
I suspect this should be fairly trivial, but I've been thinking about for long, and it looks like chicken and egg to me...
Any help ?
Regards,
Paul
initrd means Initial RAM disk.
The boot image is put onto your Hard disk. The hard disk needs to be accessible from the BIOS to boot from it. Most controllers have a BIOS module that lets it be accessed during boot so you don't need a chicken before the egg to start the boot. Then, when booting, LILO or grub starts linux which uncompresses a RAM disk and mounts it instead of your hard disk. A special version of init (called nash) gets started which reads a script called linuxrc. It contains commands like:
#!/bin/nash
mount -t proc /proc /proc
setquiet
echo Mounted /proc filesystem
echo Mounting sysfs
mount -t sysfs none /sys
echo "Loading scsi_mod.ko module"
insmod /lib/scsi_mod.ko echo "Loading sd_mod.ko module" insmod /lib/sd_mod.ko echo "Loading aic7xxx.ko module" insmod /lib/aic7xxx.ko echo "Loading libata.ko module" insmod /lib/libata.ko echo "Loading ata_piix.ko module" insmod /lib/ata_piix.ko echo "Loading jbd.ko module" insmod /lib/jbd.ko echo "Loading ext3.ko module" insmod /lib/ext3.ko echo Creating block devices mkdevices /dev
echo Creating root device
mkrootdev /dev/root
umount /sys
echo 0x0100 > /proc/sys/kernel/real-root-dev echo Mounting root filesystem
mount -o defaults --ro -t ext3 /dev/root /sysroot pivot_root /sysroot /sysroot/initrd
umount /initrd/proc
In this case, it loads my SCSI disk (aic7xxx) module and other stuff necessary to access the disk and its filesystem.
The module(s) are in the /lib directory of the RAM disk. They are put there by a build-script that installs initrd. This script gets executed when you do 'make install' in
the kernel directory. If you have private modules, you
can copy them to the appropriate /lib/modules/uname -r/kernel/drivers directory. You put the module(s) name(s) you need to boot
in /etc/modprobe.conf or /etc/modules.conf (depends upon the module tools version) as:
alias scsi_hostadapter aic7xxx
alias scsi_hostadapter1 ata_piix
... any scsi_hostadapter stuff will be put into initrd when you execute the script, /sbin/mkinitrd.
Cheers,
Dick Johnson
Penguin : Linux version 2.6.11.9 on an i686 machine (5537.79 BogoMips).
Notice : All mail here is now cached for review by Dictator Bush.
98.36% of all statistics are fiction.
Hello Dick,
Quoted 6 lines
initrd means Initial RAM disk.
The boot image is put onto your Hard disk. The hard disk needs to be accessible from the BIOS to boot from it. Most controllers have a BIOS module that lets it be accessed during boot so you don't need a chicken before the egg to start the boot.
Ok, basically, the trick is that the BIOS knows how to access the disk, and Linux doesn't because it doesnt use the BIOS ? Or is it some more subtle (though I doubt) thing in which only a part of the disk can be accessed by the BIOS.
Quoted 4 lines
Then, when booting, LILO or grub starts linux which uncompresses a RAM disk and mounts it instead of your hard disk. A special version of
init(called nash) gets started which reads a script called linuxrc. It contains commands like:
Yes, I've seen that in my .img file...
Quoted 10 lines
The module(s) are in the /lib directory of the RAM disk. They are put there by a build-script that installs initrd. This script gets executed when you do 'make install' in the kernel directory. If you have private modules, you can copy them to the appropriate
/lib/modules/uname -r/kernel/drivers
directory. You put the module(s) name(s) you need to boot in/etc/modprobe.confor/etc/modules.conf(depends upon the module tools version) as:
Quoted 6 lines
alias
scsi_hostadapteraic7xxx
aliasscsi_hostadapter1ata_piix... any
scsi_hostadapterstuff will be put into initrd when you execute the script,/sbin/mkinitrd.
Hmmm... I didn't know this part, thanks for the details.
So, it seems that I'm stuck with my binary module unless I can find a way to tell the kernel to use the BIOS to access the disk ;-)))
Cheers,
Paul
Quoted 9 lines · Paul Rolland
Hello Dick,
Quoted 6 lines
initrd means Initial RAM disk.
The boot image is put onto your Hard disk. The hard disk needs to be accessible from the BIOS to boot from it. Most controllers have a BIOS module that lets it be accessed during boot so you don't need a chicken before the egg to start the boot.
Quoted 5 lines
Ok, basically, the trick is that the BIOS knows how to access the disk, and Linux doesn't because it doesnt use the BIOS ? Or is it some more subtle (though I doubt) thing in which only a part of the disk can be accessed by the BIOS.
Linux needs to load a driver before it can access the disk. The BIOS only works for 16-bit real-mode access.
Quoted 19 lines
Quoted 4 lines
Then, when booting, LILO or grub starts linux which uncompresses a RAM disk and mounts it instead of your hard disk. A special version of
init(called nash) gets started which reads a script called linuxrc. It contains commands like:Yes, I've seen that in my .img file...
Quoted 13 lines
The module(s) are in the /lib directory of the RAM disk. They are put there by a build-script that installs initrd. This script gets executed when you do 'make install' in the kernel directory. If you have private modules, you can copy them to the appropriate
/lib/modules/uname -r/kernel/drivers
directory. You put the module(s) name(s) you need to boot in/etc/modprobe.confor/etc/modules.conf(depends upon the module tools version) as:alias
scsi_hostadapteraic7xxx
aliasscsi_hostadapter1ata_piix
Quoted 9 lines
Quoted 3 lines
... any
scsi_hostadapterstuff will be put into initrd when you execute the script,/sbin/mkinitrd.Hmmm... I didn't know this part, thanks for the details.
So, it seems that I'm stuck with my binary module unless I can find a way to tell the kernel to use the BIOS to access the disk ;-)))
No. You are "stuck with a driver" just like everybody else. You either have drivers built-in (getting rare, because there are so many), or you load a driver while booting. This is the usual way. From the boot perspective, it doesn't matter if the module is a 'binary' one or a GPL one.
Quoted 4 lines
Cheers,
Paul
Cheers,
Dick Johnson
Penguin : Linux version 2.6.11.9 on an i686 machine (5537.79 BogoMips).
Notice : All mail here is now cached for review by Dictator Bush.
98.36% of all statistics are fiction.
Quoted 5 lines · Paul Rolland
Ok, basically, the trick is that the BIOS knows how to access the disk, and Linux doesn't because it doesnt use the BIOS ? Or is it some more subtle (though I doubt) thing in which only a part of the disk can be accessed by the BIOS.
I'm not an expert in this area, but . . . For lilo I think the boot loader just records the physical address where the initrd image resides and loads it directly into memory thru the bios. It doesn't need to understand the device or filesystem -- it's just retrieving a chunk of data -- as long as the bios understands how to read raw (real-mode) data from the device. That would be why you have to rerun lilo after changing any boot files -- because the addresses probably changed.
I believe grub understands filesystems but I've also had trouble using grub to boot from devices which need module loading, i.e. USB flash drives. I don't use grub much though.
Quoted 22 lines · Paul Rolland
Hello,
I've been fighting for a few days with binary modules from some manufacturer for hardware support of disk controler, and I'm at a point where I need some more understanding.
1 - My machine contains an Adaptec SATA Raid based on Marvel 88SX60xx
so I need to used the aar81xxx binary module,2 - This module is presented as required to access the disk (when
installing a RH kernel, it says that no disk is present unless the module is loaded),3 - When booting the kernel from disk after installation, the module is
loaded so the machine can access the disk...... BUT ... how can the machine /
- boot the kernel,
- access the initrd image and uncompress it,
- read the binary module inside and load it
BEFORE loading the module itself, if it is mandatory to access the disk.
Quoted 6 lines
And if it is not, then how can I do the installation ?
I suspect this should be fairly trivial, but I've been thinking about for long, and it looks like chicken and egg to me...
Any help ?
The kernel and initrd images are loaded by the bootloader (grub, lilo, etc.), which uses the BIOS to read from the disk. So as long as your controller has BIOS support you should be ok.
--
Brian Gerst