I had an embedded device which uses busybox as the Linux operating system. There is a hard disk (hda) attached to the device. My goal is to deploy a linux operating system to the kit.
I use UNetbootin to create a bootable USB and this will install the image as per syslinux.cfg. The installation image contains some scripts to create a partition and format the hard disk, install the GRUB to the hard disk (using grub-install command), and copy my own grub files to the boot directory of the GRUB.
My own grub files include the kernel image (bzImage) and menu.lst, where menu.lst will tell where to find the kernel bzImage (p.s. I did not specify initrd option). i.e.
kernel /boot/bzImage root=/dev/hda1
When I remove the USB pendrive and reboot, it can load the bzImage and start the operating system. However, the filesystem is volatile (i.e. the changes to the filesystem will be lost after reboot)!
I am very new to the kernel build. I guess to make the filesystem is non-volatile, I have to write a script to mount the hard disk and use switch_root for the initramfs to point the root to the hard disk. However, switch_root requires PID 1 and the process ID started by /etc/inittab is not 1. I have seen in threads/forum mentioning there is a /init script but did not specify where it is located.
Is switch_root the correct way to make the filesystem to non-volatile in initramfs?
If so, where should I put the /init script to execute switch_root command? Can I put the /init script inside the kernel bzImage, or the installation image, or something else?