From bfcf2bdef4c95afcc0588d14ca90dc16fabee896 Mon Sep 17 00:00:00 2001 From: Tomas M Date: Sun, 2 Sep 2012 22:11:05 -0500 Subject: [PATCH] boot to bash --- .config | 11 ++---- build | 25 ++++++++++--- initramfs/initramfs_create | 77 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 99 insertions(+), 14 deletions(-) diff --git a/.config b/.config index 3808f80..49ed9cf 100644 --- a/.config +++ b/.config @@ -5,7 +5,7 @@ # Live Kit Name. Defaults to 'mylinux'; # For example, Slax changes it to 'slax' # Must not contain any spaces. -LIVEKITNAME="mylinux" +LIVEKITNAME="slax" # Kernel version. Change it to "3.2.28" for example, if you are building # Live Kit with a different kernel than the one you are actually running @@ -19,17 +19,12 @@ MKMOD="bin etc home lib lib64 opt root sbin srv usr var" # List of files and directories you'd like to exclude from your Live Kit EXCLUDE="/etc/fstab /etc/mtab" -# Temporary directory to store compressed directories -# (the whole folder will be erased and recreated during build!) -TMPDATA=/tmp/live_data_$$ +# Temporary directory to store livekit filesystem +LIVEKITDATA=/tmp/livekit-data-$$ # Bundle extension, for example 'sb' for .sb extension BEXT=sb -# Change this variable if you installed your distro to some directory. -# for example ROOT=/tmp/newdir. You may leave it empty, then it defaults to / -ROOT= - # Directory with kernel .ko modules, can be different in some distros LMK="lib/modules/$KERNEL" diff --git a/build b/build index 8fc04b7..3b30ec0 100755 --- a/build +++ b/build @@ -20,13 +20,26 @@ if [ "$(mksquashfs 2>&1 | grep "Xdict-size")" = "" ]; then fi # build initramfs image +cd initramfs +INITRAMFS=$(./initramfs_create "$LIVEKITNAME") +cd .. +# create live kit filesystem +rm -Rf "$LIVEKITDATA" +BOOT="$LIVEKITDATA"/"$LIVEKITNAME"/boot +mkdir -p "$BOOT" +cp bootfiles/isolinux.bin $BOOT +cp bootfiles/vesamenu.c32 $BOOT +mv "$INITRAMFS" $BOOT/initfs.img +cat bootfiles/isolinux.cfg | sed -r "s:/boot/:/$LIVEKITNAME/boot/:" > $BOOT/isolinux.cfg +cp /boot/vmlinuz $BOOT/ # create compressed bundles +# ... - - - - - - +# create ISO for CD image (so I can test it) +cd "$LIVEKITDATA" +mkisofs -o "/tmp/iso.iso" -v -J -R -D -A "$LIVEKITNAME" -V "$LIVEKITNAME" \ +-no-emul-boot -boot-info-table -boot-load-size 4 \ +-b "$LIVEKITNAME"/boot/isolinux.bin -c "$LIVEKITNAME"/boot/isolinux.boot . \ +>/dev/null 2>/dev/null diff --git a/initramfs/initramfs_create b/initramfs/initramfs_create index a9bf588..36a3c85 100755 --- a/initramfs/initramfs_create +++ b/initramfs/initramfs_create @@ -1 +1,78 @@ #!/bin/bash + +. ../.config + +# Automatically determine the architecture we're building on: +if [ -z "$MYARCH" ]; then + case "$( uname -m )" in + i?86) export MYARCH=i486 ;; + arm*) export MYARCH=arm ;; + # Unless $MYARCH is already set, use uname -m for all other archs: + *) export MYARCH=$( uname -m ) ;; + esac +fi + +INITRAMFS=/tmp/livekit-initramfs-$MYARCH-$$ + +# copy file to initramfs tree, including +# all library dependencies (as shown by ldd) +# $1 = file to copy (full path) +copy_including_deps() +{ + # if source doesn't exist or target exists, do nothing + if [ ! -e "$1" -o -e "$INITRAMFS"/"$1" ]; then + return + fi + + cp -R --parents "$1" "$INITRAMFS" + if [ -L "$1" ]; then + DIR="$(dirname "$1")" + LNK="$(readlink "$1")" + copy_including_deps "$(cd "$DIR"; realpath "$LNK")" + fi + + ldd "$1" 2>/dev/null | sed -r "s/.*=>|[(].*//g" | sed -r "s/^\\s+|\\s+\$//" \ + | while read LIB; do + copy_including_deps "$LIB" + done + + shift + if [ "$1" != "" ]; then + copy_including_deps "$@" + fi +} + +rm -Rf $INITRAMFS +mkdir -p $INITRAMFS/{bin,dev,etc,lib,lib64,mnt,proc,root,run,sbin,sys,tmp,usr,var/log} + +modprobe zram +copy_including_deps /dev/zram0 + +copy_including_deps /dev/console /dev/null /dev/fb0 /dev/zero +copy_including_deps /dev/ram /dev/systty /dev/fuse +copy_including_deps /dev/tty /dev/tty? +copy_including_deps /bin/bash /bin/mount +copy_including_deps /bin/ln /bin/cat /bin/ls /bin/free +copy_including_deps /sbin/blkid /sbin/swapon /sbin/mkswap /sbin/modprobe +copy_including_deps /bin/grep /bin/egrep /bin/cut /bin/tr +copy_including_deps /sbin/lsmod +copy_including_deps /sbin/fdisk + +#copy_including_deps /usr/bin/vi +#copy_including_deps /usr/bin/strace + +copy_including_deps /$LMK/kernel/fs +copy_including_deps /$LMK/kernel/drivers/staging/zram +copy_including_deps /$LMK/modules.* + +depmod -b $INITRAMFS + +echo "root::0:0::/root:/bin/bash" >$INITRAMFS/etc/passwd +touch $INITRAMFS/etc/{m,fs}tab + +cp init $INITRAMFS/ +chmod a+x $INITRAMFS/init + +cd $INITRAMFS +find . -print | cpio -o -H newc 2>/dev/null | gzip -f --best >$INITRAMFS.img +echo $INITRAMFS.img