embeddedlinuxworkshop / M2-S4

FileSystem

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

M2-S4

Building File system and Booting Kernel.

Contents:


  1. Kernel without File system.
  2. Sending Filesystem to Kernel [Pointer from Bootloader - though kernel root=].
  3. Defintion of Minimal rootfilesystem.
  4. Content of Rootfilesystem.
  5. sudo Permisions.
  6. User space first process.
  7. Programs and Utilities.
  8. Libraries.
  9. Merging sysroot with rootfilesystem using rsync
  10. Virtual File systems [proc and sysfs].
proc & sys creation/mounting process.
  1. Packaging rootfilesystem to target [initramfs - Disk Image - NFS].
  2. Creating Uncompressed filesystem.
  3. Compressing initramfs system using [mkinitfs - CPIO].
  4. Booting Kernel with initramfs.
  5. Init program [Process of reading configuration from /etc/inittab].

1. Kernel without filesystem 😱😱😱😱😱😱😱😱😱😱😱


qemu-system-aarch64 -M virt -cpu cortex-a53 -m 1G -kernel Image  -append "console=ttyAMA0"  -nographic

2. How Filesystem should look like


man hier

3. Defintion/Content of Minimal rootfilesystem.


a. Standard Directories. Screenshot 2023-10-27 at 1 22 34 PM

Actions:

  1. Create directories Manual.
  2. Filling content of directory with a. Init process. b. shell. c. commands. d. Applications. e. Libraries.

4. Fix permission for directories.


By changing to to root ownership.

5. User space first process.


a. init.d -----> read configuration /etc/inittab. b. systemd.


6. [BusyBox] Programs and Utilities.


Busy Box solution.
  1. Download Busybox.
git clone git://busybox.net/busybox.git
cd busybox
  1. Build busybox.
make distclean
make ARCH=arm64 CROSS_COMPILE=<prefix_toolchain> menuconfig ---> for PREFIX install.
make ARCH=arm64 CROSS_COMPILE=<prefix_toolchain>
  1. Install busybox to Minimal rootfilesystem.
make ARCH=arm64 CROSS_COMPILE=<prefix_toolchain> install

7. Merging sysroot with rootfilesystem using rsync.


rsync -avh /path/source /path/to/destination/

8. Creating initramfs


find . -print0 | cpio --null -ov --format=newc > initramfs.cpio
find . -print0 | cpio --null -ov --format=newc > initramfs.cpio

9. Creating C++ Application


#include <iostream>

using namespace std;


int main ()
{
  cout << "Hello From Kernel" << endl;
}

Reading C++ Dependencies

readelf

10. Booting Kernel


qemu-system-aarch64 -M virt -cpu cortex-a53 -m 1G -kernel Image  -append "console=ttyAMA0 rdinit=/bin/sh" -initrd <initramfs> -nographic

About

FileSystem