[syslinux] Adding memdisk or similar when booting linux

H. Peter Anvin hpa at zytor.com
Wed Mar 19 05:51:13 PDT 2008


Kjetil.Mikkelborg at kongsberg.com wrote:
> 
> Ok, thanks, but..
> 
> Ive tried using linux.c as an example, but I am in no way capable of adding files with this simple code
> 
> size_t kernel_len, dd_len;
> void *kernel_data, *dd_data;
> struct initramfs *initramfs;
> 
> loadfile("path to vmlinuz on tftp server",&kernel_data,&kernel_len);
> loadfile("Path to dd.img file on tftp server",&dd_data,&dd_len);
> initramfs = initramfs_init();
> initramfs_load_archive(initramfs,"path to redhat enterprise 4 initrd.img file on tftp server");
> initramfs_add_file(initramfs,dd_data,dd_len,dd_len,"/dd.img",0,0755);
> syslinux_boot-linux(kernel-data,kernel_len,initramfs,"append string",0xffff,0);
> 
> is there any more init I have to do to add files? and,  is it really right to use dd_len,dd_len as arguments (whats the first len since the second is for how much data we add).
> 

Yes, that's correct (the reason there is data length and file length is 
that hard links are stored as a file with a data length of zero.)

However, since you're loading a file from the underlying mendium, you're 
probably better off using initramfs_load_file(), which pretty much does 
the same thing you have above.

However, you have the mem_limit argument (the last argument) to 
syslinux_boot_linux() set to zero, which is guaranteed to break every 
time.  Set it to -1 unless you have better information, although the 
best would be to use the code from linux.c as-is(*).

	-hpa

(*) I really should librarize extracting this kind of information from 
the kernel command line.





More information about the Syslinux mailing list