Ram-disk kernel FreeBSD

Kenneth Lind exil at solace.miun.se
Mon Feb 5 11:11:04 CET 2007


On Mon, 5 Feb 2007, Johan Björk wrote:

> Hej,

Hej hej.

> Jag letar efter information om hur man kan flytta in binärer och en
> ramdisk in i kerneln för FreeBSD.
>
> OpenBSD har ett projekt som kallas Flashboot, finns det något liknande för
> FreeBSD?
>
> Det lilla Google gav mig var MD_ROOT_IMAGE, men jag hittar inte den
> "options" i 6.2. Mycket hänvisningar till 4.7, tyvärr...
> http://www.bsdatwork.com/2002/11/07/monolithic_kernels_on_freebsd/

För FreeBSD 5 fungerade
options         MD_ROOT_SIZE=19045
options                ROOTDEVNAME=\"ufs:md0a\"
options                BOOTP
options                BOOTP_COMPAT
options                BOOTP_WIRED_TO=rl0
(vilket naturligtvis ska anpassas efter eget behov)
                           fin-fint för min firewall med 80MB RAM.

Problemet för mig var att få in ett befolkat filsystem i kärnan, men
jag hittade lite perl-saker någonstans som fixade detta. Efter lite
anpassning.
Det anpassade scriptet är bifogat.
Orginalet kan hittas här:
 http://www.ultradesic.com/index.php?section=86

Annan metod:
 http://www.bsdatwork.com/2002/11/07/monolithic_kernels_on_freebsd/

 Lycka till!

  MVH, Kenneth Lind

--

   "When dogma enters the brain, all intellectual activity ceases"
                            Robert Anton Wilson

Homepage (Swedish only):                 http://www.solace.miun.se/~exil
Cellphone .se:                                        +46-(0)73 218 1937
Cellphone .nl:                                        +31-(0)64 409 6291
-------------- next part --------------
#!usr/local/bin/perl
$mfs = "lennonmfs";
$kernel_in = "p11";
#$kernel_in = "kernel_new_with_space";
$kernel_out = "lennon.steaming_fresh";

    open (F, $kernel_in) || die "can't open $kernel_in ($!)\n";
    ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size1,
         $atime,$mtime,$ctime,$blksize,$blocks) = stat($kernel_in);
    $n = sysread (F, $k, $size1);
    if ($n != $size1) {die "read error on $kernel_in ($!)\n";}
    close F;
    $pos = index ($k, "MFS Filesystem goes here", 0);
    if ($pos < 0) {die "MFS filesystem signature not found in $kernel_in\n";}
    $end = index ($k, "MFS Filesystem had better STOP here", $pos);
    if ($end < 0) {die "MFS filesystem end signature not found in $kernel_in\n";}
    $size = $end - $pos;
######## step 2: write the MFS in kernel
    open (F, $mfs) || die "can't open $mfs ($!)\n";
    ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size2,
         $atime,$mtime,$ctime,$blksize,$blocks) = stat($mfs);
    if ($size < $size2) {die "MFS file system too small: file size=$size2\n";}
    $n = sysread (F, $m, $size2);
    if ($n != $size2) {die "read error on $mfs ($!)\n";}
    close F;
    # write new kernel
    open (F, ">$kernel_out") || die "can't create ./$kernel_out ($!)\n";
    $n = syswrite (F, $k, $pos+8192); # data before MFS
    if ($n != ($pos+8192)) {die "write error on ./$kernel_out ($!)\n";}
    $n = syswrite (F, $m, $size2-8192, 8192); # MFS
    if ($n != ($size2-8192)) {die "write error on ./$kernel_out ($!)\n";}
    $n = syswrite (F, $k, $size1-($pos+$size2), $pos+$size2);
    if ($n != ($size1-($pos+$size2))) {die "write error on ./$kernel_out ($!)\n";}
    close F;


More information about the BUS mailing list