[syslinux] Booting using single image file

Kent Robotti dwilson24 at nyc.rr.com
Fri Sep 30 15:21:05 PDT 2005


On Fri, Sep 30, 2005 at 09:13:57PM +0200, Frederic Pasteleurs wrote:
> Kent Robotti wrote:
> >>   I know that syslinux doesn't currently support this, but does anyone
> >>here know how I might go about getting some sort of boot process
> >>together that would have a single firmware image as opposed to seperate
> >>files for initrd, kernel, and root fs?
> > 
> > 
> > It's not a syslinux issue.
> > 
> > You can use the initramfs feature of the 2.6 kernels to embed a initrd/rootfs
> > in the kernel.
> >  
> > When the kernel is booted it will recognize and setup the initrd/rootfs.
> > 
> > I'm not subscribed, Cc me if possible.
> > 
> 
> You can also try an old trick: append the ramdisk image after the kernel
> and specify the ramdisk offset on the kernel command command line.
> 
> An example:
> 
> - Your kernel is 800 Kb round. (dd if=zImage of=kernel bs=1024 conv=sync
> for rounding to a Kb boundary)
> - You put the ramdisk after the kernel image (dd if=ramdisk of=kernel
> bs=1024 seek=800)
> - On the kernel cmdline, you add the option ramdisk_start=800 and you
> specify your kernel as ramdisk.
> 
> This is documented in file linux-<version>/Documentation/ramdisk.txt of
> the linux kernel tarball.
> 
> The only problem with this setup is that the bootloader will read the
> whole file two times. If you have slow storage (floppy, flash) you will
> have a performance problem.
> 
> I have attached a script i wrote some time ago to automate the process.
> 
> -- 
> \m/  Frederic Pasteleurs            [http://belzebuth.ath.cx]  \m/
> 
> O____ Fingerprint: FC13 DC5B F78B C476 5A40  03D8 8696 A92A 6A80 995D
> O  || http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x6A80995D
> 

> #!/bin/sh
> 
> # Script to generate single-file kernel+ramdisk images.
> # Made by Frederic Pasteleurs for Car-Juke-Box "reflashing"
> # without using the mighty screwdriver :-)
> 
> # License: GNU GPL
> 
> # Definitely need some cleanup...
> 
> ME=$(basename $0)
> PRJ_FILE=$ME.prj
> 
> # Is there a project file here ??
> if [ ! -e $PRJ_FILE ]; then
>     echo "$ME: $PRJ_FILE not found: quit."
>     exit 1
> fi
> 
> # Inject the config file
> . $PRJ_FILE
> 
> # Check the config file
> if [ "$KERNEL_ORI" = "" ]; then
>     echo "$ME: Mandatory variable KERNEL_ORI undefined in $PRJ_FILE"
>     exit 1
> fi
> 
> if [ "$RAMDISK_ORI" = "" ]; then
>     echo "$ME: Mandatory variable RAMDISK_ORI undefined in $PRJ_FILE"
>     exit 1
> fi
> 
> # Check for the presence of specified files
> if [ ! -e $KERNEL_ORI ]; then
>     echo "$ME: $KERNEL_ORI not found"
>     exit 1
> fi
> 
> if [ ! -e $RAMDISK_ORI ]; then
>     echo "$ME: $RAMDISK_ORI not found"
>     exit 1
> fi
> 
> # If we don't supply an output file, it will be inputfile.frm
> if [ "$KERNEL" = "" ]; then
>     KERNEL=$KERNEL_ORI.frm    
> fi
> 
> # Warn if there is no destination URL
> if [ "$UPLOAD_URL" = "" ]; then
>     echo "$ME: Warning: no upload URL provided: upload disabled."
> fi
> 
> # Pad the kernel to a 2048 bytes multiple.
> dd if=$KERNEL_ORI of=$KERNEL bs=2048 conv=sync
> 
> # Store the kernel size
> KERNEL_SIZE=$(ls -s -k $KERNEL | cut -d ' ' -f 1)
> # Store the ramdisk size
> RAMDISK_SIZE=$(ls -s -k $RAMDISK_ORI | cut -d ' ' -f 1)
> 
> # Compress the ramdisk & merge it to kernel
> if [ "$PACK" = "NO" ]; then
>     cat $RAMDISK_ORI >> $KERNEL
> else
>     gzip -c -v9 $RAMDISK_ORI >> $KERNEL
> fi
> 
> # Configure the "firmware"
> /usr/sbin/rdev $KERNEL /dev/ram0	# Root is ramdisk
> /usr/sbin/rdev -r $KERNEL $KERNEL_SIZE	# Start of ramdisk
> /usr/sbin/rdev -R $KERNEL 0		# Ramdisk is rw
> 
> # Setting the commandline
> echo "ramdisk_start=$KERNEL_SIZE load_ramdisk=1 ramdisk_size=$RAMDISK_SIZE root=/dev/ram0 $APPEND" > append.txt
> 
> # Generating the md5sum
> md5sum $KERNEL > reflash.md5
> md5sum append.txt >> reflash.md5
> 
> if [ "$UPLOAD_URL" != "" ]; then
>     # Sending files away to server :-)
>     scp $KERNEL $UPLOAD_URL
>     scp append.txt $UPLOAD_URL
>     scp reflash.md5 $UPLOAD_URL
> fi

That's right.




More information about the Syslinux mailing list