Hi,

{Around here we don't top-post. We interleave replies in between the relevant 
bits of the quoted text. Pleases tick with the established community 
conventions}

On Thursday 16 April 2009 12:07:08 Thomas Chef wrote:
> Aha I understand.
>
> But what if my cd installation names my disk hda,
> but when I download the gentoo kernel source and build it it will use sda.
> So in my lilo.conf I must use hda, and when the new kernel boots it looks
> for hda (because of my lilo.conf), but in that case it should be sda
> instead ?

It's more complicated than that, much more complicated.

lilo is not Linux, it runs before Linux runs. So the boot loader itself (when 
booting) has absolutely no idea about /dev/sda or /dev/hda. It doesn't even 
know about /dev, and doesn't need to know such things.

However, before lilo (the boot loader) can work at all, it's code must be 
installed to the MBR of the disk, and there is a Linux app that does that. 
This app needs to know which disk to install the boot loader onto, but it's a 
Linux app so must follow Linux conventions when using disks. If your current 
kernel calls it /dev/hda, then the lilo installer must do the same otherwise 
it cannot find the disk (it must use the running kernel to do that, it cannot 
do it itself. The fact that it's a bootloader *installer* doesn't change 
anything).

When booting, the BIOS will access the first sector of the boot device (as 
defined in the BIOS) and load what it finds there. In your case this will be 
lilo. Lilo will read data directly off the disk and stuff them into memory. By 
a process of magic and a little voodoo, this will just happen to be an exact 
copy of a working kernel. The kernel will load, initialise itself, create 
/dev, find disks and decide what to call them - hda or sda depending on how 
you configured it when you built that kernel. This is the first point where 
hda or sda even exists at all so before then these are meaningless concepts.

Now all of this makes complete sense when you pick it apart. The problem (and 
the point of confusion for most folks), is "how the hell did lilo get onto the 
disk????" The correct answer is "You ran Linux and put it there yourself of 
course!!!!"

The trick is to realise that you ran Linux off a CD which let you see the 
disks so that you could put a boot loader on them, then reboot and start all 
over.

It's a chicken and egg thing, and I did tell you up front it was complicated.
Next week we will cover the wonderful topic of GRUB.

Summary: When you finally get the machine to boot, the disks will be called 
whatever you told the kernel to call them.

>
> On Thu, Apr 16, 2009 at 11:49 AM, Alan McKinnon 
<[email protected]>wrote:
> >  On Thursday 16 April 2009 11:28:54 Thomas Chef wrote:
> > > From the handbook:
> > > To begin, we'll introduce block devices. The most famous block device
> > > is probably the one that represents the first drive in a Linux system,
> >
> > namely
> >
> > > /dev/sda. SCSI and Serial ATA drives are both labeled /dev/sd*; even
> > > IDE drives are labeled /dev/sd* with the new libata framework in the
> > > kernel.
> >
> > If
> >
> > > you're using the old device framework, then your first IDE drive is
> > > /dev/hda .
> > >
> > > But when I boot on Via Epia with my minimal installation CD 2008 I get
> > > my IDE-disk as /dev/hda
> > >
> > > Is the kernel on the minimal CD old ?
> >
> > Not really. It's whatever was reasonably current at the time the CD image
> > was
> > built.
> >
> > It's not the age of the kernel that matters here. it's which drivers are
> > in use. These things are in a constant state of flux and right now the
> > Linux kernel still has drivers for the old and the new way of doing
> > things with disks.
> >
> > Rationale: a driver writer decided some time ago that it would be better
> > to consolidate things in the kernel and use the same code-base for all
> > types of
> > disk. This makes things easier overall as you don't have to eternally
> > figure
> > out if you have IDE/SCSI/PATA/SCSI/something_else drives - the thing is
> > always
> > going to be /dev/sd**
> >
> > But you can still use the old drivers and framework if you choose.
> > Apparently,
> > whoever mastered that CD did choose. Point being, if /dev/sda doesn't
> > work for
> > you and /dev/hda does, then you should be using /dev/hda. From your point
> > of
> > view, it's just a name for something
> >
> > --
> > alan dot mckinnon at gmail dot com

-- 
alan dot mckinnon at gmail dot com

Reply via email to