Página siguiente Página anterior Índice general

6. Poniendolo todo junto: Creacion del disco(s).

En este momento tiene un kenel y un sistema de ficheros raiz comprimido. Si estan creando un disco boot/root, compruebe su tamaño para asegurarse de que entran juntos en un disco. Si esta creando el conjunto de dos discos boot+root compruebe que el sistema de ficheros raiz entra un un simple disco.

Deberia decidir ahora si va ha utilizar LILO para arrancar el kernel del disco boot. La alternativa es copiar el kernel directamente al disco y arrancarlo sin LILO. La ventaja de usar LILO es que permite suministrar algunos parametros al kernel que puedenser necesarios para iniciar su hardware (Compruebe el fichero /etc/lilo.conf de su sistema. Si existe y tiene una linea como ``append=...'', probablemente necesite esta caracteristica). La desventaja de usar LILO es que la construcion del disco de arranque es mas complicada, y toma un poco mas de espacio. Tiene que preparar un pequeño sistema de ficheros a parte, que llamaremos el sistema de ficheros kernel, donde pondremos el kernel y otros pocos ficheros que necesita LILO.

Si va ha utilizar lilo, siga leyendo; si va a transferir el kernel directamente, saltese esta seccion y pase a la seccion Sin usar LILO.

6.1 Transferir el kernel con LILO .

Primero debe crear un pequeño fichero de configuracion para LILO. Deberia ser como este:


        boot      =/dev/fd0
        install   =/boot/boot.b
        map       =/boot/map
        read-write
        backup    =/dev/null
        compact
        image     = KERNEL
        label     = Bootdisk
        root      =/dev/fd0

Para una explicacion d esto parametros, consulte la documentacion del usuario de LILO. Probablemente quiera añadir una linea con append=... a este fichero del fichero /etc/lilo.conf de su disco duro.

Guarde este fichero como bdlilo.conf.

You now have to create a small filesystem, which we shall call a kernel filesystem, to distinguish it from the root filesystem.

First, figure out how large the filesystem should be. Take the size of your kernel in blocks (the size shown by ``ls -l KERNEL'' divided by 1024 and rounded up) and add 50. Fifty blocks is approximately the space needed for inodes plus other files. You can calculate this number exactly if you want to, or just use 50. If you're creating a two-disk set, you may as well overestimate the space since the first disk is only used for the kernel anyway. Call this number KERNEL_BLOCKS.

Put a floppy diskette in the drive (for simplicity we'll assume /dev/fd0) and create an ext2 kernel filesystem on it:

        mke2fs -i 8192 -m 0 /dev/fd0 KERNEL_BLOCKS

The ``-i 8192'' specifies that we want one inode per 8192 bytes. Next, mount the filesystem, remove the lost+found directory, and create dev and boot directories for LILO:

        mount /dev/fd0 /mnt
        rm -rf /mnt/lost+found
        mkdir /mnt/{boot,dev}

Next, create devices /dev/null and /dev/fd0. Instead of looking up the device numbers, you can just copy them from your hard disk using -R:

        cp -R /dev/{null,fd0} /mnt/dev

LILO needs a copy of its boot loader, boot.b, which you can take from your hard disk. It is usually kept in the /boot directory.

        cp /boot/boot.b /mnt/boot

Finally, copy in the LILO configuration file you created in the last section, along with your kernel. Both can be put in the root directory:

        cp bdlilo.conf KERNEL /mnt

Everything LILO needs is now on the kernel filesystem, so you are ready to run it. LILO's -r flag is used for installing the boot loader on some other root:

        lilo -v -C bdlilo.conf -r /mnt

LILO should run without error, after which the kernel filesystem should look something like this:


total 361
  1 -rw-r--r--   1 root     root          176 Jan 10 07:22 bdlilo.conf
  1 drwxr-xr-x   2 root     root         1024 Jan 10 07:23 boot/
  1 drwxr-xr-x   2 root     root         1024 Jan 10 07:22 dev/
358 -rw-r--r--   1 root     root       362707 Jan 10 07:23 vmlinuz
boot:
total 8
  4 -rw-r--r--   1 root     root         3708 Jan 10 07:22 boot.b
  4 -rw-------   1 root     root         3584 Jan 10 07:23 map
dev:
total 0
  0 brw-r-----   1 root     root       2,   0 Jan 10 07:22 fd0
  0 crw-r--r--   1 root     root       1,   3 Jan 10 07:22 null           

Do not worry if the file sizes are slightly different from yours.

Now leave the disk in the drive and go to section Setting the ramdisk word.

6.2 Transferring the kernel without LILO.

If you are not using LILO, transfer the kernel to the bootdisk with the dd command:

        % dd if=KERNEL of=/dev/fd0 bs=1k
        353+1 records in
        353+1 records out

In this example, dd wrote 353 complete records + 1 partial record, so the kernel occupies the first 354 blocks of the diskette. Call this number KERNEL_BLOCKS and remember it for use in the next section.

Finally, set the root device to be the diskette itself, then set the root to be loaded read/write:

        rdev /dev/fd0 /dev/fd0
        rdev -R /dev/fd0 0

Be careful to use a capital -R in the second rdev command.

6.3 Setting the ramdisk word.

Inside the kernel image is the ramdisk word that specifies where the root filesystem is to be found, along with other options. The word is defined in /usr/src/linux/arch/i386/kernel/setup.c and is interpreted as follows:

        bits  0-10:     Offset to start of ramdisk, in 1024 byte blocks
        bits 11-13:     unused
        bit     14:     Flag indicating that ramdisk is to be loaded
        bit     15:     Flag indicating to prompt before loading rootfs

If bit 15 is set, on boot-up you will be prompted to place a new floppy diskette in the drive. This is necessary for a two-disk boot set.

There are two cases, depending on whether you are building a single boot/root diskette or a double ``boot+root'' diskette set.

  1. If you are building a single disk, the compressed root filesystem will be placed right after the kernel, so the offset will be the first free block (which should be the same as KERNEL_BLOCKS). Bit 14 will be set to 1, and bit 15 will be zero.
  2. If you are building a two-disk set, the root filesystem will begin at block zero of the second disk, so the offset will be zero. Bit 14 will be set to 1, and bit 15 will be 1.

After carefully calculating the value for the ramdisk word, set it with rdev -r. Be sure to use the decimal value. If you used LILO, the argument to rdev here should be the mounted kernel path, e.g. /mnt/vmlinuz; if you copied the kernel with dd, instead use the floppy device name (e.g., /dev/fd0).

        rdev -r KERNEL_OR_FLOPPY_DRIVE  VALUE

If you used LILO, unmount the diskette now.

6.4 Transferring the root filesystem.

The last step is to transfer the root filesystem.

Congratulations, you are done! You should always test a bootdisk before putting it aside for an emergency! If it fails to boot, read on.


Página siguiente Página anterior Índice general