#!/bin/bash # # InitRD.sh.txt # ------------- # # Original Files # -------------- # http://Linux-Boot.net/Boot/FD # http://document.eidologic.de/Documentation/Making_boot_disk.html # # http://www.linux.org/docs/ldp/howto/Bootdisk-HOWTO/buildroot.html # http://www.tldp.org/HOWTO/Encrypted-Root-Filesystem-HOWTO/setup-boot-device.html # # http://penguinppc.org/embedded/howto/root-filesystem.html # http://linuxdoc.org/HOWTO/mini/Loopback-Root-FS.html # # # 08-Mar-05 amo Date-of-Birth # 10-Mar-05 amo Added LoopSize for how big "/" has to be to hold the initrd # # # NM="InitRD.sh.txt" # # # Run the command and show status # ------------------------------- function doecho() { cmd=$1 # echo "$cmd" $cmd # if [ $? != 0 ]; then echo "#" echo "# ERROR: FAILED: $cmd " echo "#" # exit 1 # fi # } # doecho # # # Create a file ... /etc/fstab, /etc/inittab, /etc/lilo.conf # ------------- function CreateFile() { fil=$1 lin="$2" # echo "#" > $fil echo "$lin" >> $fil echo "#" >> $fil # } # createfile # # # =========================================================== # # minimum rootFS that runs in /dev/ram # # CreateRootFS() { # Src=`pwd` # DLoop="/tmp/loop.initrd" MLoop="/mnt/loop" # umount $MLoop # # Size of the RootFS ( /dev/loop ) - it will be "/" # ----------------- #oopSize="8192" #oopSize="16384" LoopSize="32768" # doecho "dd if=/dev/zero of=$DLoop count=$LoopSize bs=1024" doecho "mke2fs -q -j $DLoop" # doecho "mount -o rw,loop $DLoop $MLoop" # doecho "cd $MLoop" echo "#" # # doecho "mkdir boot bin dev etc initrd lib mnt proc root sbin tmp usr var" chmod 1777 tmp # RootFS="$Src/RootFS.txt" # if [ ! -f "$RootFS" ]; then echo "#" echo "# ERROR: Missing Contents of initrd=$RootFS" echo "#" # exit 1 # fi # DevLibBin=` grep -iv ^# $RootFS ` # # echo "$DevLibBin.." # echo "tar cf - $DevLibBin | ( cd $MLoop ; tar xvfp - ) " tar cf - $DevLibBin | ( cd $MLoop ; tar xvfp - ) # # remove the prev copy rm -f $DLoop.gz ; sleep 2 # echo "#" echo "sync ; gzip -9 $DLoop" gzip -9 $DLoop echo "#" echo "#" # cd umount $MLoop # } # CreateRootFS # # # # =========================================================== # echo "#" echo "# Create a minimum RootFS " echo "#" # CreateRootFS # # # End of file