Size: 778
Comment:
|
Size: 2070
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 24: | Line 24: |
= initramfs with static program = * https://www.kernel.org/doc/html/latest/filesystems/ramfs-rootfs-initramfs.html#contents-of-initramfs A good first step is to get initramfs to run a statically linked "hello world" program as init {{{#!higlight sh sudo apt install qemu-system cd /tmp wget https://saimei.ftp.acc.umu.se/debian-cd/current/amd64/iso-cd/debian-12.1.0-amd64-netinst.iso sudo mount -o loop /vagrant/debian-12.1.0-amd64-netinst.iso /mnt/iso cat > hello.c << EOF #include <stdio.h> #include <unistd.h> int main(int argc, char *argv[]) { printf("Hello world!\n"); sleep(999999999); } EOF gcc -static hello.c -o init echo init | cpio -o -H newc | gzip > test.cpio.gz cp test.cpio.gz debiancd/install.amd/test.cpio.gz cat > debiancd/isolinux/isolinux.cfg << EOF default bootcd prompt 1 timeout 40 label bootcd kernel /install.amd/vmlinuz append initrd=/install.amd/test.cpio.gz vga=788 EOF cd /tmp/ mkisofs -o /tmp/output2.iso -R -l -L -D -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -V "LFS_$(date +%Y%m%d)" /tmp/debiancd/ rm /vagrant/output2.iso cp output2.iso /vagrant }}} qemu-system-x86_64 -kernel debiancd/install.amd/vmlinuz -initrd test.cpio.gz /dev/zero |
LinuxFromScratch
Linux From Scratch (LFS) is a project that provides you with step-by-step instructions for building your own custom Linux system, entirely from source code.
https://www.linuxfromscratch.org/lfs/downloads/stable/LFS-BOOK-11.3-NOCHUNKS.html
https://www.linuxfromscratch.org/hints/downloads/files/boot-cd_easy.txt
https://www.linuxfromscratch.org/lfs/downloads/stable/wget-list
List of the required downloads for LFS 11.3
initramfs with static program
https://www.kernel.org/doc/html/latest/filesystems/ramfs-rootfs-initramfs.html#contents-of-initramfs
A good first step is to get initramfs to run a statically linked "hello world" program as init
sudo apt install qemu-system cd /tmp wget https://saimei.ftp.acc.umu.se/debian-cd/current/amd64/iso-cd/debian-12.1.0-amd64-netinst.iso sudo mount -o loop /vagrant/debian-12.1.0-amd64-netinst.iso /mnt/iso cat > hello.c << EOF #include <stdio.h> #include <unistd.h> int main(int argc, char *argv[]) { printf("Hello world!\n"); sleep(999999999); } EOF gcc -static hello.c -o init echo init | cpio -o -H newc | gzip > test.cpio.gz cp test.cpio.gz debiancd/install.amd/test.cpio.gz cat > debiancd/isolinux/isolinux.cfg << EOF default bootcd prompt 1 timeout 40 label bootcd kernel /install.amd/vmlinuz append initrd=/install.amd/test.cpio.gz vga=788 EOF cd /tmp/ mkisofs -o /tmp/output2.iso -R -l -L -D -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -V "LFS_$(date +%Y%m%d)" /tmp/debiancd/ rm /vagrant/output2.iso cp output2.iso /vagrant
qemu-system-x86_64 -kernel debiancd/install.amd/vmlinuz -initrd test.cpio.gz /dev/zero