I'm now going to format and partition a new SD card and copy all boot files there. I would like to try `f2fs` rather than `ext4`, as it is especially made for solid storage disks and SD cards. I'm compiling it into the kernel (`File systems` -> `F2FS filesystem support`).
I've created the partition scheme on my PC for the new card like this:
# fdisk -l Disk /dev/sde: 29.72 GiB, 31914983424 bytes, 62333952 sectors Disk model: Multi-Card Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0xa9169ad7 Device Boot Start End Sectors Size Id Type /dev/sde1 * 2048 104447 102400 50M c W95 FAT32 (LBA) /dev/sde2 104448 62333951 62229504 29.7G 83 Linux
I've created the partitions with `cfdisk`, and set the boot flag with `fdisk`:
# fdisk /dev/sde +Command (m for help): a +Partition number (1,2, default 2): 1 The bootable flag on partition 1 is enabled now. +Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks.
The file systems are created like this [1]:
apt-get install --no-install-recommends f2fs-tools mkfs.vfat -nBOOT /dev/sdX1 mkfs.f2fs -l root -O extra_attr,inode_checksum,sb_checksum /dev/sdX2
Replace the `X` with the device of your SD card.
Then the partitions are mounted and I'm starting to create the directories on the `root` (the `f2fs`) partition:
mkdir -p bin boot/firmware dev etc proc sys
Created the etc/fstab file with recommended mount options for the root partition:
/dev/mmcblk0p2 / f2fs atgc,gc_merge,lazytime 0 1 /dev/mmcblk0p1 /boot/firmware vfat noatime 0 2
And transfered all files from `/boot/firmware/` from the SD card with the recently compiled kernel to the `boot` partition of the new card:
/media/sdcard0# ll total 11M -rwxr-xr-x 1 root root 54K Feb 9 10:14 bcm2711-rpi-4-b.dtb -rwxr-xr-x 1 root root 90K Feb 9 10:14 config-callistix -rwxr-xr-x 1 root root 125 Feb 9 11:11 config.txt -rwxr-xr-x 1 root root 5.3K Jan 24 17:30 fixup4.dat -rwxr-xr-x 1 root root 2.2M Jan 24 17:30 start4.elf -rwxr-xr-x 1 root root 1.2M Feb 9 10:14 System.map-callistix -rwxr-xr-x 1 root root 7.0M Feb 9 10:14 vmlinux-callistix
The `config.txt` is very minimal and contains only:
kernel=vmlinux-callistix
The Raspberry tries to boot from the new card but then only shows the "rainbow", but without any error code which would normally be shown in the form of a blinking green LED. I would have expected it to show at least some kernel boot logs, subsequently failing when trying to find `init`. I've done a few tests and it seems that the `arm_64bit` parameter in `config.txt` is mandatory, the documentation [3] reveals that "[...] if the name given in an explicit kernel option matches one of the known kernels then arm_64bit will be set accordingly." So our kernel name is different than expected by the RPi firmware, and the documentation recommends to name it `kernel8.img`. I've renamed it, which then makes all of our parameters in `config.txt` obsolete, and I've left it empty. The `boot` partition now looks like this:
/media/sdcard0# ll total 11M -rwxr-xr-x 1 root root 54K Feb 9 10:14 bcm2711-rpi-4-b.dtb -rwxr-xr-x 1 root root 90K Feb 9 10:14 config-kernel8.img -rwxr-xr-x 1 root root 0 Feb 9 12:09 config.txt -rwxr-xr-x 1 root root 5.3K Jan 24 17:30 fixup4.dat -rwxr-xr-x 1 root root 7.0M Feb 9 10:14 kernel8.img -rwxr-xr-x 1 root root 2.2M Jan 24 17:30 start4.elf -rwxr-xr-x 1 root root 1.2M Feb 9 10:14 System.map-kernel8.img
And the RPi now boots as expected and panics correctly at `No working init found. Try passing init= option to kernel.`
[1] Creating a F2FS file system
⬅ 8. Kernel reduction second pass
➡ 10. Adding a simple init system
⬆ The minimal Raspberry 4 project
Created: 9/Feb/2024
Modified: 9/Feb/2024