getting your system to boot with initrd and initramfs
play

Getting your system to boot with initrd and initramfs Ryan Curtin - PowerPoint PPT Presentation

Getting your system to boot with initrd and initramfs Ryan Curtin LUG@GT Ryan Curtin Getting your system to boot with initrd and initramfs - p. 1/12 Goals By the end of this presentation, hopefully, you should be able Goals to: Overview


  1. Getting your system to boot with initrd and initramfs Ryan Curtin LUG@GT Ryan Curtin Getting your system to boot with initrd and initramfs - p. 1/12

  2. Goals By the end of this presentation, hopefully, you should be able » Goals to: Overview � Know the basic history of initrd and initramfs, and why they Building an initramfs or initrd exist Configuring your bootloader � Know how to configure GRUB / LILO to use an initrd or Questions and Comments? initramfs � Unpack and look inside an initrd or initramfs � Use standard tools to generate a new initrd or initramfs � Modify an initrd and initramfs by hand or through configuration files � Know how to configure a kernel to avoid using an initrd or initramfs Ryan Curtin Getting your system to boot with initrd and initramfs - p. 2/12

  3. History of initrd and initramfs � The idea of an initrd has been around almost as long as » Goals Linux itself, going back to the 1.xx kernels a Overview » History of initrd and initramfs � It exists to load modules that are required by the kernel at » Internals of an initrd » /linuxrc or /init - the initialization script boot-time, but not compiled into the kernel » So what makes initrd and initramfs different? � The concept exists today in 2.6 kernels as initramfs and Building an initramfs or initrd is used by distributions such as Fedora, Red Hat, Ubuntu, Configuring your bootloader and Debian (there are more, of course) Questions and Comments? a http://ussg.iu.edu/hypermail/linux/kernel/9602/1289.html Ryan Curtin Getting your system to boot with initrd and initramfs - p. 3/12

  4. Internals of an initrd � The initrd is usually a cpio archive passed through gzip » Goals � Inside the archive is a straightforward simple directory Overview » History of initrd and initramfs hierarchy, similar to the standard Linux filesystem hierarchy » Internals of an initrd » /linuxrc or /init - the initialization script � You can crack open an archive with » So what makes initrd and initramfs different? Building an initramfs or initrd $ gzip -dc initrd.img | cpio -idv Configuring your bootloader � /linuxrc and /init contain the script that is run to boot Questions and Comments? the system Ryan Curtin Getting your system to boot with initrd and initramfs - p. 4/12

  5. /linuxrc or /init - the initialization script � /linuxrc or /init is the first executable started once the » Goals initrd or initramfs is loaded by the kernel Overview » History of initrd and initramfs � /linuxrc is used in the older initrd » Internals of an initrd » /linuxrc or /init - the initialization script � /init is used in the newer initramfs » So what makes initrd and initramfs different? � This executable is usually a shell script; Debian uses Building an initramfs or initrd /bin/sh but Red Hat uses /bin/nash ; it does not matter Configuring your bootloader which shell/interpreter is used Questions and Comments? Ryan Curtin Getting your system to boot with initrd and initramfs - p. 5/12

  6. So what makes initrd and initramfs different? � Both initrd and initramfs exist to solve the same » Goals problem; however, initramfs is used by modern 2.6 Overview » History of initrd and initramfs kernels whereas initrd was used by older 2.4 (and earlier) » Internals of an initrd » /linuxrc or /init - the kernels initialization script » So what makes initrd and � initramfs uses a dynamically-allocated RAM filesystem; initramfs different? initrd uses a statically-allocated RAM disk Building an initramfs or initrd Configuring your bootloader � A filesystem driver is required to read a initrd image at Questions and Comments? boot-time; initramfs requires only a lightweight ramfs driver, which is built-in by default in 2.6 kernels � initramfs makes NFS-mounted root filesystems easier; DHCP and logins may be necessary to mount an NFS share as root Ryan Curtin Getting your system to boot with initrd and initramfs - p. 6/12

  7. The Red Hat way � The Red Hat utility for generating an initramfs is » Goals mkinitrd Overview � This utility seems to use the term initrd and initramfs Building an initramfs or initrd » The Red Hat way interchangeably, as it produces an initramfs » The Debian way » The Gentoo way » By hand General syntax: Configuring your bootloader Questions and Comments? mkinitrd -allow-missing -f initrd.img kernel-version The mkinitrd command is referenced by � /sbin/new-kernel-pkg � /sbin/installkernel /etc/modprobe.conf controls the modules that are put into the initramfs . Ryan Curtin Getting your system to boot with initrd and initramfs - p. 7/12

  8. The Debian way � The Debian utility for creating an initramfs is the » Goals slightly-more-aptly-named mkinitramfs Overview � Another utility is updateinitramfs , which can update the Building an initramfs or initrd » The Red Hat way initramfs for all kernels on your machine » The Debian way » The Gentoo way � yaird will also generate an initramfs , but it is less tested » By hand Configuring your bootloader than the other Debian tools Questions and Comments? A comparison of methods - � yaird will generate a rather small initramfs by default; initramfs-tools will not � initramfs-tools will create an initramfs no matter what; yaird will stop if it cannot be sure that the generated initramfs will work � An initramfs generated by initramfs-tools will have an emergency shell if it fails; yaird does not include this unless you explicitly specify it Ryan Curtin Getting your system to boot with initrd and initramfs - p. 8/12

  9. The Gentoo way � A kernel configured by hand generally does not require an » Goals initramfs - the install guide encourages you to compile Overview everything you need into the kernel Building an initramfs or initrd » The Red Hat way � A kernel created with genkernel will also create an » The Debian way » The Gentoo way initramfs » By hand � mkinitrd is in the Portage tree; this could also be used Configuring your bootloader Questions and Comments? � Gentoo-Wiki has an extensive article about configuring your own initramfs - http://gentoo-wiki.com/HOWTO_Initramfs Ryan Curtin Getting your system to boot with initrd and initramfs - p. 9/12

  10. By hand When the initrd filesystem is done, it should contain (for proper » Goals startup) Overview Building an initramfs or initrd � An /init script (necessary) » The Red Hat way » The Debian way � The shell necessary to run the /init script and its » The Gentoo way » By hand dependencies Configuring your bootloader � Any modules that need to be loaded to mount the root Questions and Comments? filesystem Pack up the filesystem with $ find ./ > file_list $ cpio -o < file_list > initrd.cpio $ gzip initrd.cpio $ rm file_list Ryan Curtin Getting your system to boot with initrd and initramfs - p. 10/12

  11. Configuring your bootloader � GRUB - sample grub.conf excerpt » Goals Overview title Debian GNU/Linux, kernel 2.6.18-4-686 Building an initramfs or initrd root (hd0,0) Configuring your bootloader kernel /vmlinuz-2.6.18-4-686 root=/dev/hda3 ro » Configuring your bootloader initrd /initrd.img-2.6.18-4-686 Questions and Comments? � LILO - sample lilo.conf excerpt image=/vmlinuz label=Linux read-only initrd=/initrd.img Ryan Curtin Getting your system to boot with initrd and initramfs - p. 11/12

  12. Questions and Comments? » Goals Overview Building an initramfs or initrd Configuring your bootloader Questions and Comments? » Questions and Comments? Ryan Curtin Getting your system to boot with initrd and initramfs - p. 12/12

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend