7

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??

  • 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 – ctrl-alt-delor Jul 11 '16 at 12:05
  • what is the difference between zImage and root-file-system?? – seereddi sekhar Jul 11 '16 at 12:06
  • 1
  • zimage is an image of the kernel; root-file-system is a file-system. – ctrl-alt-delor Jul 11 '16 at 12:09
8

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.
  • 1
    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. – jc__ Jul 11 '16 at 14:03
  • thank u @user2564741...this is what exactly i want to know – seereddi sekhar Jul 12 '16 at 4:14
4
  • 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 me mounted.
  • uboot is the boot loader used by embedded linux; it basically tells the BIOS 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 SDcard image, even if you no longer need to manually add the former three to the final image anymore.

  • 1
    If I actually download the kernel source and build it only zImage will be generated but not the rootfs. Am I right – seereddi sekhar Jul 11 '16 at 12:11
  • 1
    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. – Shadur Jul 11 '16 at 12:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.