Announce: new boot utilities

Announce: new boot utilities

Post by Joseph H All » Thu, 26 Feb 1998 04:00:00



I've written two new boot utilities:

'mbr' is a single-sector partition manager, which allows you to name each
partition, provides a boot prompt similar to LILO's, allows you to set a
timeout value for the prompt (to boot the default partition) and which can
optionally set the active flag of the parition being booted in the partition
table (this is useful for booting SCO-Xenix or having two primary DOS
paritions).  'mbr' includes an install utility for DOS and Linux.  'mbr'
fits entirely within the first sector- no secondary files are loaded during
it's operation.

'bootfat' is a single sector bootloader which understand DOS FAT
filesystems.  No 'sys'-like utility is needed when you change the operating
system- all you have to do is copy vmlinuz to the root directory.  'bootfat'
does not include an install utility, but does include an assembled version
set up for booting 1.44M floppies.  It needs an install utility for hard
drives.

I'm working the equivalent of 'bootfat' for ext2.  It will be done shortly.

Find on: ftp.worcester.com, files: pub/joe/mbr.tar.Z and
pub/joe/bootfat.tar.Z.
--

int a[1817];main(z,p,q,r){for(p=80;q+p-80;p-=2*a[p])for(z=9;z--;)q=3&(r=time(0)
+r*57)/7,q=q?q-1?q-2?1-p%79?-1:0:p%79-77?1:0:p<1659?79:0:p>158?-79:0,q?!a[p+q*2
]?a[p+=a[p+=q]=q]=q:0:0;for(;q++-1817;)printf(q%79?"%c":"%c\n"," #"[!a[q-1]]);}

 
 
 

Announce: new boot utilities

Post by Jason McMulla » Fri, 27 Feb 1998 04:00:00



Quote:> 'bootfat' is a single sector bootloader which understand DOS FAT
> filesystems.  No 'sys'-like utility is needed when you change the operating
> system- all you have to do is copy vmlinuz to the root directory.  'bootfat'
> does not include an install utility, but does include an assembled version
> set up for booting 1.44M floppies.  It needs an install utility for hard
> drives.

  Yeah! Downloading now! I can't believe it's taken 5 years for someone
to come up with this.... Still, amazing coding....

--
Jason McMullan - Linux - GGI - http://beans.visus.com/~jmcc
NT 5.0 is the last nail in the Unix coffin. Interestingly, Unix
isn't in the coffin... It's wondering what the heck is sealing
itself into a wooden box 6 feet underground...

 
 
 

Announce: new boot utilities

Post by Joseph H All » Tue, 03 Mar 1998 04:00:00


I've finished the single-record ext2fs boot loader.  You can get it by
anonymous ftp from ftp.worcester.com, file: pub/joe/bootext2.tar.Z.  This is
a single record ext2fs boot-loader which understands the ext2 filesystem.
Since it understands the filesystem, there is no need to run a 'lilo' or
'sys' type program each time you install a new kernal- instead you just copy
the kernel to root.  When booting, it searches the root directory for
'vmlinuz', loads it and executes it.
--

int a[1817];main(z,p,q,r){for(p=80;q+p-80;p-=2*a[p])for(z=9;z--;)q=3&(r=time(0)
+r*57)/7,q=q?q-1?q-2?1-p%79?-1:0:p%79-77?1:0:p<1659?79:0:p>158?-79:0,q?!a[p+q*2
]?a[p+=a[p+=q]=q]=q:0:0;for(;q++-1817;)printf(q%79?"%c":"%c\n"," #"[!a[q-1]]);}

 
 
 

Announce: new boot utilities

Post by Joseph H All » Wed, 04 Mar 1998 04:00:00




Quote:>I've finished the single-record ext2fs boot loader.  You can get it by
>anonymous ftp from ftp.worcester.com, file: pub/joe/bootext2.tar.Z.  This is
>a single record ext2fs boot-loader which understands the ext2 filesystem.
>Since it understands the filesystem, there is no need to run a 'lilo' or
>'sys' type program each time you install a new kernal- instead you just copy
>the kernel to root.  When booting, it searches the root directory for
>'vmlinuz', loads it and executes it.

Oops, made a dump mistake in the distribution.  Please download version 1
from ftp.worcester.com if you had downloaded version 0.  It won't break
anything- the installer just didn't work.

Happens every time...

--

int a[1817];main(z,p,q,r){for(p=80;q+p-80;p-=2*a[p])for(z=9;z--;)q=3&(r=time(0)
+r*57)/7,q=q?q-1?q-2?1-p%79?-1:0:p%79-77?1:0:p<1659?79:0:p>158?-79:0,q?!a[p+q*2
]?a[p+=a[p+=q]=q]=q:0:0;for(;q++-1817;)printf(q%79?"%c":"%c\n"," #"[!a[q-1]]);}

 
 
 

Announce: new boot utilities

Post by Albert D. Cahal » Wed, 04 Mar 1998 04:00:00



Quote:> I've finished the single-record ext2fs boot loader.

You might want to announce that in comp.os.linux.announce and

Quote:> anonymous ftp from ftp.worcester.com, file: pub/joe/bootext2.tar.Z

Usually people write that as ftp://ftp.worcester.com/pub/joe/bootext2.tar.Z
Weird, you actually used the compress program?

Quote:> When booting, it searches the root directory for
> 'vmlinuz', loads it and executes it.

Could you add enough code to reach a file in /boot?
If not, consider this instead:

1. Load the first 13 blocks listed for the reserved boot loader inode.
   (typically 12 kB of data + 256 block pointers)
2. Use that code to load 256 more blocks -- now you have lots of code.
3. Load a menu file from /boot, offer choices...

If you can get stage 2 done, somebody else can write the menu.

 
 
 

Announce: new boot utilities

Post by Joseph H All » Thu, 05 Mar 1998 04:00:00





>> I've finished the single-record ext2fs boot loader.

I've also finished the installer for the FAT boot loader:
ftp://ftp.worcester.com/pub/joe/bootfat.tar.Z
It will install onto hard drives now.

Someone asked if I could make a version for DOS (I.E., which loads IO.SYS or
whatever without requiring a 'sys'ed machine).  I'll give it a try (there's
absolutely no room left, so any changes are quite painful- for DOS I'm
pretty sure I have to move the bootloader away from 7c00, so it will
definitely need more code).

Quote:>Could you add enough code to reach a file in /boot?
>If not, consider this instead:
>1. Load the first 13 blocks listed for the reserved boot loader inode.
>   (typically 12 kB of data + 256 block pointers)
>2. Use that code to load 256 more blocks -- now you have lots of code.
>3. Load a menu file from /boot, offer choices...
>If you can get stage 2 done, somebody else can write the menu.

This is not really necessary- there's nothing that says you have to boot
Linux with bootext2.  You could just as easily boot a second-stage boot
loader instead.  This way is easier in fact, since you don't have to deal
with reserved magic boot loader inodes.

Someone might consider making a second stage boot loader with a built-in
text editor for fixing /etc files... :-)  It would be nice to have an
assembly language stub for this, so any application can be written entirely
in Gnu-C.

Instead of dealing with subdirectories, I'm going to use the extra space to
have it prompt for an alternative filename to boot if you hold down the ALT
key.  This will be handy for kernel development.  Next version...
--

int a[1817];main(z,p,q,r){for(p=80;q+p-80;p-=2*a[p])for(z=9;z--;)q=3&(r=time(0)
+r*57)/7,q=q?q-1?q-2?1-p%79?-1:0:p%79-77?1:0:p<1659?79:0:p>158?-79:0,q?!a[p+q*2
]?a[p+=a[p+=q]=q]=q:0:0;for(;q++-1817;)printf(q%79?"%c":"%c\n"," #"[!a[q-1]]);}

 
 
 

Announce: new boot utilities

Post by John Reis » Fri, 13 Mar 1998 04:00:00


Great job on the boot utilities!

Looking at bootext2.asm version 2, I found ways to save 57 bytes. This
may provide enough space for other features.

The single greatest space reduction is in routine lazyld.
Change the representation of an extent to be the count of blocks,
together with the _next_ block number.  Recover the*block number
by subtracting the count from the next block number.

        count:  db      0       ; number of blocks in extent
        nextlo: dw      0       ; block number of next block
        nexthi: dw      0       ;   if extent grows

The code then simplifies dramatically:

lazyld:
        mov     cl,BYTE PTR count
        test    cl,cl           ; current number of blocks in extent
        jz      lazy_ext        ; none yet
        cmp     cl,63           ; blocks are 1KB
        je      lazyflsh        ; 1 more ==> byte length overflows 16 bits
        cmp     ax,WORD PTR nextlo      ; can we grow the current extent?
        jne     lazyflsh        ;   no
        cmp     dx,WORD PTR nexthi
        jne     lazyflsh
lazy_ext:
        inc     cx              ; <inc cl> 1 more block this extent
        dec     di              ; 1 fewer blocks remaining
        inc     ax              ; compute next block number
        jnz     lazy_nc         ; <jnc>
        inc     dx
lazy_nc:
        xchg    cl,BYTE PTR count       ; load current, store new
        xchg    ax,WORD PTR nextlo
        xchg    dx,WORD PTR nexthi
        sub     al,cl           ; first block number
        sbb     ah,0
        sbb     dx,0
        retn

lazyflsh:               ; flush current extent
        mov     cl,0            ; start new extent
        call    lazy_ext
;       jmp     getblks         ; fall through

Reset the count with
        mov     BYTE PTR count,0
at the beginning of getfile .

The other changes are a byte here, a byte there; but they add up.

        mov dx,0  ==>  xor dx,dx     ; hi word of inum of root directory

        mov di,0  ==>  xor di,di     ; golinux

        mov cx,1  ==>  inc cx                ; 1st level indirection (stepn sets cx=0)

        cmp di,0  ==>  test di,di    ; 2nd level indirection

        mov ax,[si]   ==>  lodsw     ; 2nd level indirection
        mov dx,2[si]       xchg ax,dx
                           lodsw
                           xchg ax,dx   ; si dead

   donget:      call lazyflsh           ; don't bother with ax,dx,count here

        cmp di,0  ==>  test di,di    ; stepn

        mov ax,[si]   ==>  lodsw     ; stepn
        mov dx,2[si]       xchg ax,dx
         ...               lodsw
        add si,4           xchg ax,dx

        cmp di,0  ==>  test di,di    ; istepn

        mov ax,[si]   ==>  lodsw     ; istepn
        mov dx,2[si]       xchg ax,dx
         ...               lodsw
        add si,4           xchg ax,dx

   getblks:  ; no need to save+restore dx,ax

        xor ax,ax  ==>  <nothing>      ; getblks "hole block" ==> ax already
0

        add bx,400h  ==> add bh,4    ; getblks

        mov ax,dx  ==> xchg ax,dx    ; Sector within cylinder

        mov cx,ax  ==> xchg cx,ax    ; Divide by number of sectors per
cylinder

and routine bumpes should be based on Carry, not Zero:

bumpes:         ; bump ES with carry from BX
        jnc     nobump
        push    bx
        mov     bx,es
        add     bh,10h          ; <add bx,1000h>
        mov     es,bx
        pop     bx
nobump:
        retn

[mailed and posted]

 
 
 

Announce: new boot utilities

Post by Joseph H All » Fri, 13 Mar 1998 04:00:00




>Great job on the boot utilities!
>Looking at bootext2.asm version 2, I found ways to save 57 bytes. This
>may provide enough space for other features.

Wow! So there are other crazy bit counters out there... :-)  I would like to
add a prompt for the name of the kernel to load and handling of arguments,
so this will help.

Quote:>[...improvements...]

--

int a[1817];main(z,p,q,r){for(p=80;q+p-80;p-=2*a[p])for(z=9;z--;)q=3&(r=time(0)
+r*57)/7,q=q?q-1?q-2?1-p%79?-1:0:p%79-77?1:0:p<1659?79:0:p>158?-79:0,q?!a[p+q*2
]?a[p+=a[p+=q]=q]=q:0:0;for(;q++-1817;)printf(q%79?"%c":"%c\n"," #"[!a[q-1]]);}
 
 
 

Announce: new boot utilities

Post by Albert D. Cahal » Mon, 16 Mar 1998 04:00:00




>> Great job on the boot utilities!

>> Looking at bootext2.asm version 2, I found ways to save 57 bytes.
>> This may provide enough space for other features.

> Wow! So there are other crazy bit counters out there... :-)
> I would like to add a prompt for the name of the kernel to
> load and handling of arguments, so this will help.

Subdirectory support would be good. Boot stuff belongs in /boot.
The prompt (or menu, which is better) can be done by a second
stage loader. The hard part is loading a file in /boot. If you
can do that, other (less efficient) hackers can do the rest.

At least now we can have a second-stage in /. Somebody on the
reiserfs mailing list has code to support gcc compiled code.
It looks like a friendly loader is within reach.

Another use for the bytes: there are new BIOS calls that can
be used to read beyond the 1023-cyl limit. It would be great
to only need the first block of a bootable Linux filesystem
below that limit.