#!/bin/bash ### Imports ################################################################### source ScriptFunctions # Import GoboLinux # if you want Verify_Superuser Import OptionParser Import File ### Options ################################################################### #scriptDescription="[[Create an initrd]]" scriptCredits="Copyright (C) 2005 Carlo J. Calica Released under the GNU GPL." #helpOnNoArguments=yes scriptUsage=" " scriptExample="-o /tmp/initrd -- libata /external/module.ko" scriptNotes="In order to use an initrd, changes to your grub config are required. An example: title GoboLinux - Console - initrd kernel (hd0,0)/System/Kernel/Boot/kernel acpi=off root=/dev/ram0 vga=0 init=/linuxrc initrd (hd0,0)/System/Kernel/Boot/initrd.img " #Add_Option_Boolean "b" "bool" "A boolean option." Add_Option_Entry "o" "output" "Specify ." "$goboBoot/initrd.img" Add_Option_Entry "m" "module_dir" "Specify ." "$goboModules/`uname -r`" Add_Option_Entry "r" "rootdev" "Specify ." "/dev/sda1" #Add_Option_List "l" "list" "Enter a colon-separated list of..." "foo:bar" Parse_Options "$@" # Global Defines initrd_path="/tmp/initrd" raw_initrd="/tmp/initrd-raw.img" ### Operation ################################################################# [ $UID = "0" ] || Die "$scriptName must be run as superuser." Exists "$goboPrograms/Busybox/Current" || Die "$scriptName requires Busybox package." Assert_Dir "$initrd_path" module_dir=`Entry "module_dir"` initrd=`Entry "output"` eval `Array_To_Args extramodules` mkinitrd.pl `Entry "rootdev"` "$initrd_path" "$module_dir" "${extramodules[@]}" Log_Normal "Creating $initrd from $module_dir" # cramfs not in base kernel. Do this the hardway. mkfs.cramfs "$initrd_path" "$initrd" exit # The Hardway rm -- "$raw_initrd" size=`du -sk /tmp/initrd| cut -d / -f 1` Log_Normal "Create initrd of size $size KB" dd "if=/dev/zero" of=$raw_initrd bs=1k seek=$size count=$size # Yes 2x the size mkfs.ext2 -F -m0 $raw_initrd mount -o loop $raw_initrd /Mount/Floppy cp -pR /tmp/initrd/. /Mount/Floppy umount /Mount/Floppy gzip -c $raw_initrd >$comp_initrd # End of "The Hardway"