What is zImage, rootfs

19,685

Solution 1

To understand what every file is responsible for you should understand how MPU starts up.
As I understood from your qestion you use NXP (Freescale) i.MX microprocessor family. It includes small ROM loader, which will make basic system setup (interfaces to memory, clock tree etc.), search for media to boot from (based on burned OTP bits or GPIO), find bootloader (u-boot in your case) in exact address which is specified in datasheet, load and start it. U-boot will init more interfaces (e.g. Ethernet), find arguments that should be passed to Kernel (screen settings, console, network settings if you use NFS), copy Kernel to DDR and pass all arguments. Kernel will load all drivers, and search for rootfs with all libraries, applications etc. After this Kernel will start init scripts, which will init all system and start your application.

  1. u-boot is the first thing that will start after ROM bootloader. You can replace it with your own code if you would like MPU to run bare-metal code without OS (like microcontroller).
  2. zImage is compressed version of the Linux kernel image that is self-extracting.
  3. rootfs is root file system, which contains all applications, libs and in most cases everything, including home folder.
  4. sdcard image is just all stuff mentioned above which can be copied (with dd) to the card, after copy you will see FAT partition with Kernel and device tree and EXT partition with rootfs, u-boot is in unpartitioned area before FAT (in case you use i.MX6 it's 0x80000). It's there just to make your life easier.

Solution 2

  • zImage is the actual binary image of the compiled kernel. It's what the boot loader will load and attempt to execute (I believe on embedded linux it's written to the boot sector directly somehow; consult your embedded linux distro manual for instructions)
  • rootfs is the so-called INITial RamDisk (also known as initrd) image that contains everything that the kernel will need to boot up into a state where the actual root filesystem can be mounted.
  • uboot is the boot loader used by embedded linux; It basically tells the BIOS (Basic Input Output System) to run zImage with the options that tell zImage where to find the root filesystem so it knows how to start.

If I had to guess, I'd hazard that all these files are created in the process of generating the actual SD Card image, even if you no longer need to manually add the former three to the final image anymore.

Share:
19,685

Related videos on Youtube

seereddi sekhar
Author by

seereddi sekhar

Updated on September 18, 2022

Comments

  • seereddi sekhar
    seereddi sekhar over 1 year

    I am very much new to Embedded Linux. We use poky build system. We just use bitbake linux-imx command to build the kernel. It generates some files zImage, rootfs, uboot and also a sdcard image. We just copy the sdcard image and run the linux on our custom board. My questions what does rootfs and zImage actually contain??

    • ctrl-alt-delor
      ctrl-alt-delor almost 8 years
      They may be intermediate files, that where used to create the sdcard image. zImage I think may be a compressed kernel. rootfs is (and this is a guess) a root file-system. and uboot something to do with a boot loader. Try file on them. e.g. file zImage
    • seereddi sekhar
      seereddi sekhar almost 8 years
      what is the difference between zImage and root-file-system??
    • ctrl-alt-delor
      ctrl-alt-delor almost 8 years
  • seereddi sekhar
    seereddi sekhar almost 8 years
    If I actually download the kernel source and build it only zImage will be generated but not the rootfs. Am I right
  • Shadur
    Shadur almost 8 years
    That depends on what instructions you give the compile process; the default kernel tree's Makefile contains instructions to also build an initrd, as they're interrelated. I recommend you continue using bitbake on your embedded system; futzing around in order to learn how linux work is best done on a desktop system where a single mistake is less likely to irrretrievably brick your system.
  • jc__
    jc__ almost 8 years
    In addition to the kernel zImage may also contain the inital file system (initramfs, initrd) the kernel uses to ‘bring up the system’ before the rootfs is mounted.
  • seereddi sekhar
    seereddi sekhar almost 8 years
    thank u @user2564741...this is what exactly i want to know