
initrd: initial ramdisk initrd: Initial Ramdisk Introduction On power-up, the first software run from secondary storage is the bootloader, which prepares an environment for the operating system and then runs the kernel. The operating system's environment includes the root filesystem, which must be available before the kernel is started. A temporary initial root filesystem can be used in the boot process of a Linux kernel. It is typically mounted in primary storage and used to make necessary preparations before the normal root filesystem can be mounted. Mechanisms for providing an initial root filesystem include the initial ramdisk, or initrd. Device node /dev/initrd is a read-only RAM drive initialised by the bootloader before the kernel is started. The kernel can then mount an initial root filesystem from the contents of /dev/initrd. Implementation If an initial root filesystem is used, the kernel image and an image of the initial root filesystem must be stored somewhere accessible by the boot firmware of the computer or the bootloader. This is often a small ext2 or FAT-formatted volume in a data storage device (a boot volume). The bootloader loads the kernel and initial root filesystem image into memory and then starts the kernel, passing in the memory address of the initial root filesystem image. At the end of its boot sequence, the kernel makes the image available as a special block device which is then mounted as the initial root filesystem. Once the initial root filesystem is mounted, the kernel executes /linuxrc (linux run command) as its first process. This article continues from the initial bootloader article and explains how to load an initial root filesystem and pass control from the bootloader to the Linux kernel. The first process started by Linux is linuxrc, and this article demonstrates use of a linuxrc shell script. Finally the article demonstrates use of a GRUB menu. Booting from flash drive and floppy disk are both discussed. A flash drive has enough storage to hold the bootloader, kernel and initrd image in its boot volume; a floppy disk, on the other hand, does not and two floppy disks are required. Throughout the article, the terms single boot medium and twin boot media are used to identify scenarios where one or two recording media are required. revision 0 initrd: initial ramdisk Once the bootloader is running, the startup process discussed in this article performs the following operations: 1. The bootloader loads the kernel program into primary storage from file /boot/bzImage in the boot volume or kernel volume. 2. The bootloader loads an initrd image containing the root filesystem into memory from file /boot/initrd.gz in the boot volume. 3. The kernel program is started and the operating system is booted. 4. The kernel executes linuxrc as its first process. 5. linuxrc starts the Unix shell. Concepts initial root filesystem A temporary initial root filesystem can be used in the boot process of a Linux kernel. It is typically mounted in primary storage and used to make necessary preparations before the normal root filesystem can be mounted. initrd The initial ramdisk, or initrd, is a file containing an initial root filesystem. The special device node /dev/initrd accesses a read-only block device. The device is a RAM drive initialised by the bootloader before the kernel is started. The kernel can then mount an initial root filesystem from the contents of /dev/initrd. linuxrc linuxrc (linux run command) is the first process executed after initrd is mounted. Once the initial root filesystem is mounted, if executable file /linuxrc is present, the kernel executes it as its first process. File /linuxrc can be any valid executable, including an executable program, symbolic link or shell script. root volume The root volume is the volume that contains the root filesystem. The root filesystem is the filesystem containing the root directory (/). boot volume The boot volume is the volume that contains the bootloader. kernel volume The kernel volume is the volume that contains the kernel image. revision 0 initrd: initial ramdisk Prerequisites The following article must have been completed: ● initial bootloader: revision 1 or later If deploying to twin boot media, an additional recording medium will be required. For example, if deploying to floppy disk media, a floppy disk will be required in addition to the one used in the initial bootloader article. Download Download initrd from helpcentreonline.com. This will save a file named initrd.tar.gz. Note the directory initrd.tar.gz is downloaded to: this will be referred to as the download directory ([download]). Installation 1. If twin boot media are used, label boot media. 1. The recording medium created in the initial bootloader article should already be labelled boot; if not, write “boot” on a label and attach it to the recording medium created in the initial bootloader article. This recording medium will be referred to as the boot disk. 2. Write “kernel” on a label and attach it to the additional recording medium. This recording medium will be referred to as the kernel disk. revision 0 initrd: initial ramdisk 2. Collect information. 1. Note the target device ([target]). Note the drive letter used to represent the drive that will contain the target recording medium. The drive letter is referred to later in this article as the target device. If the target device is not permanently connected to the computer (for example, if it is connected via USB), the drive letter may be different the next time the computer is switched on. For this reason it is important to note the target device each time the process in this article is followed. 2. If deploying to twin boot media, note whether the additional recording medium has been formatted ([format]). If the additional recording medium has not been formatted, the value of [format] is format; otherwise the value is noformat. Note that as well as being formatted, the additional recording medium must be empty - it must contain no files or directories. If in doubt, assume that the recording medium has not been formatted ([format] = format). 3. Create sources directory ([sources]). 1. Create a directory from which the installation will be performed. For example, a suitable directory could be c:\Unix\source. This directory will be referred to as the sources directory. revision 0 initrd: initial ramdisk 4. Unpack sources. Start a command prompt and type the following commands. (Do not type the > character - it is the command prompt.) 1. > copy [download]\initrd.tar.gz [sources] Copy the sources from the download directory to the sources directory. When typing the command replace [download] with the path name of the download directory including the drive letter and replace [sources] with the path name of the sources directory including the drive letter. For example, if initrd.tar.gz was downloaded to d:\download and the sources directory is c:\Unix\source, type: > copy d:\download\initrd.tar.gz c:\Unix\source 2. > [sources drive]: Change to the drive containing the sources directory. When typing the command replace [sources drive] with the drive letter of the drive containing the sources directory. For example if the sources directory is c:\Unix\source, type: > c: 3. > cd [sources] Change to the sources directory. When typing the command replace [sources] with the path name of the sources directory excluding the drive letter. For example if the sources directory is c:\Unix\source, type: > cd \Unix\source 4. > gzip -d initrd.tar.gz Decompress the compressed file. 5. > tar -xf initrd.tar Extract the archive. revision 0 initrd: initial ramdisk 6. > cd initrd 5. Deploy. 1. > deploy [target] [switch] [format] Deploy kernel and initrd image. When typing the command replace [target], [switch] and [format] as follows: ● Replace [target] with the target device. ● If deploying to twin boot media, replace [switch] with switch; if deploying to a single boot medium replace [switch] with noswitch. For example, there is insufficient space on a single floppy disk to store all the required data, and it is therefore necessary to switch floppy disks during the boot process. This is indicated in the [switch] argument. ● If deploying to twin boot media and the additional recording medium is unformatted or if it is not known whether the additional recording medium is formatted, replace [format] with format; otherwise replace [format] with noformat. For example, to deploy to a flash drive represented by drive letter f with sufficient space for all data, type the following: > deploy f noswitch noformat To deploy to floppy disks represented by drive letter a with the second floppy disk requiring formatting, type the following: > deploy a switch format If formatting, during the deployment a prompt will be issued to insert a new disk and hit ENTER. This is part of the format process: just press the enter key. When asked whether to format another disk, respond by pressing the n and then the enter key. revision 0 initrd: initial ramdisk 6. Start Unix. 1. Reboot the computer with the device still attached and the recording medium still inserted if a removable medium (e.g. floppy disk) is being used. 2. If booting from twin boot media, after the grub> prompt is displayed, insert the kernel disk. 3. Load the kernel program by typing the following command. (Do not type the grub> command prompt.) grub> kernel /boot/bzImage 4. If booting from twin boot media, insert the boot disk. 5. Load the initrd image by typing the following command. grub> initrd /boot/initrd.gz 6. Start the kernel program and boot the operating system by typing the following command. grub> boot revision 0 initrd: initial ramdisk The kernel runs and displays messages as it performs its startup activities.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages19 Page
-
File Size-