From 86d24fb37d0d95be1ffd2278f5c43a54d32f638f Mon Sep 17 00:00:00 2001 From: Ivan Davidov Date: Sat, 15 Aug 2015 17:58:05 +0300 Subject: [PATCH] Added more detailed comment descriptions in some of the scripts. --- src/5_generate_rootfs.sh | 22 ++++++++++++++++++++-- src/6_pack_rootfs.sh | 2 ++ src/7_generate_iso.sh | 4 +++- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/5_generate_rootfs.sh b/src/5_generate_rootfs.sh index 3d8e6ad16..7a4441f2c 100755 --- a/src/5_generate_rootfs.sh +++ b/src/5_generate_rootfs.sh @@ -7,11 +7,14 @@ rm -rf rootfs cd busybox cd $(ls -d *) +# Copy all BusyBox generated stuff to the location of our "initramfs" folder. cp -R _install ../../rootfs cd ../../rootfs +# Remove "linuxrc" which is used when we boot in "RAM disk" mode. rm -f linuxrc +# Create root FS folders mkdir dev mkdir etc mkdir proc @@ -19,10 +22,16 @@ mkdir root mkdir src mkdir sys mkdir tmp + +# "1" means that only the owner of a file/directory (or root) can remove it. chmod 1777 tmp cd etc +# The script "/etc/bootscript.sh" is automatically executed as part of the +# "init" proess. We suppress most kernel messages, mount all crytical file +# systems, loop through all available network devices and we configure them +# through DHCP. cat > bootscript.sh << EOF #!/bin/sh @@ -32,14 +41,15 @@ mount -t proc none /proc mount -t sysfs none /sys for DEVICE in /sys/class/net/* ; do - ip link set \${DEVICE##*/} up - [ \${DEVICE##*/} != lo ] && udhcpc -b -i \${DEVICE##*/} -s /etc/rc.dhcp + ip link set \${DEVICE##*/} up + [ \${DEVICE##*/} != lo ] && udhcpc -b -i \${DEVICE##*/} -s /etc/rc.dhcp done EOF chmod +x bootscript.sh +# The script "/etc/rc.dhcp" is automatically invoked for each network device. cat > rc.dhcp << EOF #!/bin/sh @@ -53,6 +63,8 @@ EOF chmod +x rc.dhcp +# The file "/etc/welcome.txt" is displayed on every boot of the system in each +# available terminal. cat > welcome.txt << EOF ##################################### @@ -63,6 +75,9 @@ cat > welcome.txt << EOF EOF +# The file "/etc/inittab" contains the configuration which defines how the +# system will be initialized. Check the following URL for more details: +# http://git.busybox.net/busybox/tree/examples/inittab cat > inittab << EOF ::sysinit:/etc/bootscript.sh ::restart:/sbin/init @@ -80,6 +95,8 @@ EOF cd .. +# The "/init" script passes the execution to "/sbin/init" which in turn looks +# for the configuration file "/etc/inittab". cat > init << EOF #!/bin/sh @@ -89,6 +106,7 @@ EOF chmod +x init +# Copy all source files to "/src". Note that the scripts won't work there. cp ../../*.sh src cp ../../.config src chmod +r src/*.sh diff --git a/src/6_pack_rootfs.sh b/src/6_pack_rootfs.sh index 67710f0b8..f9e16e523 100755 --- a/src/6_pack_rootfs.sh +++ b/src/6_pack_rootfs.sh @@ -2,10 +2,12 @@ cd work +# Remove the old initramfs archive if it exists. rm -f rootfs.cpio.gz cd rootfs +# Packs the current folder structure in "cpio.gz" archive. find . | cpio -H newc -o | gzip > ../rootfs.cpio.gz cd ../.. diff --git a/src/7_generate_iso.sh b/src/7_generate_iso.sh index e0df2d046..38c951585 100755 --- a/src/7_generate_iso.sh +++ b/src/7_generate_iso.sh @@ -5,7 +5,9 @@ rm -f minimal_linux_live.iso cd work/kernel cd $(ls -d *) -# Edit Makefile to look for genisoimage instead of mkisofs +# Edit Makefile to look for genisoimage instead of mkisofs. This was added as a +# workaround for some "Debian" and "Arch Linux" distributions. In general this +# fix should be harmless. sed -i 's/mkisofs/genisoimage/g' arch/x86/boot/Makefile # Generate the ISO image with optimization for "parallel jobs" = "number of processors"