Gujin is a PC boot loader which can analyze your filesystems. It finds the Linux kernel images available, as well as other bootable partitions (for *BSD, MS-DOS, Windows, etc.), and displays a graphical menu for selecting which system to boot. Because it understand the structure of Linux kernel images, Gujin does not need LILO and can even load very big kernels. There is no need to execute anything after making a new kernel: just copy the kernel image file into the "/boot" directory. Gujin is written almost entirely in C with GCC, and it fully executes in real mode to be as compatible as possible.
1. Use a precompiled configuration
2. Recompile your own configuration
3. Content of "standard.tgz"
4. FAQ
5. TODO
1. Use a precompiled configuration:
- Download the file "standard-0.5.tgz", un-tar it "mkdir standard; cd standard; tar -xzf ../standard-0.5.tgz" or open it with winzip if you have another operating system.
- Select the image/executable you want to try: begin with "full.img.gz"/"full.exe", you can play with others later.
- Insert a clean 1.44Mb floppy on your drive, the data on this floppy will be erased.
- Do "zcat full.img.gz > /dev/fd0", or if you do not have "zcat", type "gunzip -c full.img.gz > /dev/fd0"
If you have an error accessing the drive and are using automount/supermount, try "umount /mnt/floppy" before the zcat.
If you are using another OS, try "rawrite.exe" (after decompressing "full.img.gz" to "full.img" again using winzip), see:
http://uranus.it.swin.edu.au/~jn/linux/rawwrite.htm.
- If you have DOS/Windows (excluding NT), you can now copy "full.exe" on the floppy, for instance "mcopy full.exe a:"
- Reboot your computer keeping the floppy in place, you can then play with the mouse.
- If you have a DOS installation, boot its Master Boot Record to play with "A:\full.exe".
- The other files you get in "standard.tgz" are described later in paragraph 3.
- If your version of DOSEMU / Xdos is not too old, you may try "zcat full.img.gz > /var/lib/dosemu/floppyimage" and then "dos -A 2>/dev/null" or "xdos -A".
See also "/etc/dosemu.conf" ($_vbootfloppy="floppyimage +hd") and "/etc/mtools.conf" (drive o: file="/var/lib/dosemu/floppyimage").
2. Recompile your own configuration:
- Download gujin-0.5.tar.gz and read the (beginning of) file "Makefile"; you will be able to comment/uncomment lines to select your own configuration (support of VESA, of EDID, of serial terminal like VT420, language...).
To rebuild, you will also need e2fsprogs-1.25.tar.gz at:
http://prdownloads.sourceforge.net/e2fsprogs/e2fsprogs-1.25.tar.gz
It is better to have GCC-2.95.3 or newer (GCC-3.0.2), egcs-2.91.* may work, gcc-2.7.* will not.
It is necessary to have binutils-2.9.5.0.33.tar.gz or better, I use binutils-2.11.2 ("make" will check that).
- create a directory structure like this:
projet/
projet/gujin-0.5.tar.gz
projet/e2fsprogs-1.25.tar.gz
projet/binutils-*.tar.gz (if you want to rebuild it)
projet/gcc-*.tar.gz (if you want to rebuild it)
- Go in "projet" directory and type "tar -xzf gujin-0.5.tar.gz" which creates the "projet/gujin" directory, go in it.
- Type "make" without parameter, this recreate dependencies, file "code16.h" and link "main.c", and show you some possible parameters.
- If you want to rebuild the compiler and/or the assembler and linker (binutils), type "make toolchain" and have a cup of coffee.
You do _not_ need to be root for this - and it will _not_ install the compiler/binutils as default, just locally.
Note that when "make" is called without parameters, it displays the version of compiler and binutils which will be used.
- Now, you can (as "make" says you), type things like: "make /dev/fd0" or "make boot.exe" or "make boot.com" or "make /dev/fd0.com1"...
and you can then reboot your computer.
- You can also type "make standard.tgz" to re-produce the precompiled file.
3. Content of "standard.tgz"
First few things:
- I am not sure to build the configuration you really need in this "demonstration" file - edit by hand if you want to add or remove some support.
- All the images (*.img) are for 1.44 Mb floppies, use the "instboot" executable for other formats.
- All the images contains the FAT and root directory: the executable size is not as big as the file size.
- The floppy used should not have "bad sectors".
- For most configurations, there is two independant files: the image (*.img) to be copied to the floppy in raw format (do _not_ use the DOS command "copy" nor drag and drop for this one !), and the standard DOS executable file (*.exe) which is a standard file to be copied the way you want, but needs at least DOS to run.
So once decompressed, the file "standard.tgz" contains:
- full.img.gz / full.exe : that is the complete configuration, the one I tested the most; you probably do not need all that.
- french.img.gz / french.exe : same as "full.img.gz / full.exe" but the messages are in French.
- medium.img.gz / medium.exe : same as "full.img.gz / full.exe" but the support for the "mini-debug", the serial (VT420) support, and the analysis of the I/O ports used by the video card are removed.
- small.img.gz / small.exe : same as "medium.img.gz / medium.exe" but the mouse support, the support of 4 BPP (16 color) graphic and 24 bit VESA modes, the VESA_HARDWINDOW analysis which cannot be used right now by Linux, the support for the VGA only cards, and the verbose messages are removed.
Note that even some 486 refuse to boot if the video card is not VESA 1.0+ compliant, so it should be quite safe to remove the VGA support.
- tiny.img.gz : same as "small.img.gz" but the support for DOS executable, the E2FS and FAT 16 support (so can only load a kernel/initrd on a floppy, will not probe HDs nor bootsectors), the saving of parameters in between boots and the menu (it will boot the first image found) are removed.
Take care, nothing here recognises the long filename on FAT12/FAT16, copy your boot file on the floppy as a 8+3 name, "vmlinuz" (and "initrd") will be fine.
- tester.img.gz / tester.exe : Just to test most of the hardware, not really documented. It can be used to measure the access speed to video memory, select which ASSEMBLY_* is best, measure the refresh frequency of the screen...
There is also these few DEBUG setup: They put information on a DOS file to be useable by everybody. Just create a DOS bootable floppy ("format /s a:" under DOS) and copy the executable to this floppy. Then, you boot out of this floppy and execute the file. It will do the same as the bootloader but also create a file named "\DBG" (stay in "A:\") to store a lot of information.
If you have a problem with Gujin, I need this DBG file to debug!
Note that you need to either exit Gujin (^C or ^D will do) or run a kernel to flush and close the file properly: do not reboot.
There is different executable (very few are here) because of size restrictions, and readability of the DBG file.
Advise: do not play too much with these files under DOSEMU, I already crashed few virtual disks...
- dbgvideo.exe : to debug the video (VGA and VESA) subsystem.
- dbgdisk.exe : to debug the disk (BIOS, EBIOS and IDE) subsystem.
- dbgload.exe : to show which parameters are passed to Linux.
4. FAQ
Q1. When I reboot my computer, I do not see anything changed, Gujin is not started.
Check that you have selected "floppy before hard drive" in the boot order in your BIOS set-up.
Q2. I would like to start the Linux kernel in graphic mode...
Linux seems to start correctly but the screen is black/white/strange after message "Starting kernel."...
It is possible not to switch to text mode when starting a kernel, this is a configuration option, in the config screen menu.
The problem is that Gujin can not (right now) detect if the kernel can/need to start in text or in graphic mode (framebuffer compiled in or not, and which number of BPP are supported).
To start in graphic, follow these steps:
First check that your kernel is compiled with VESA framebuffer support, supporting _all_ the BitPerPixel you can switch to on the Gujin interface.
Now double check that your video board is VESA 2 compilant, Linux cannot handle right now the memory window switching of VESA 1 boards.
Then (and only then) you can uncheck the "force_textmode" option in the setup screen.
Note that most standard kernels in Linux distributions are not compiled with framebuffer support, or only with 4 BPP support, so use this option with care.
Note also that some distribution default kernel can _only_ start in graphic mode.
This feature is a hack - later I would like to put all this kind of kernel description in the "comment" field of the gzip file.
Q3. Do I still need LILO, loadlin, GRUB... when using Gujin?
No, Gujin is not only a boot loader but also a Linux system loader; for instance you can load system files (vmlinuz) of unlimited size (well, below the size of your physical memory), and so do not really need to use modules even when your kernel is very big. You can also run another loader (i.e. LILO or the FreeBSD loader or the DOS/Win95/Win98/WinNT loader) from Gujin.
The source code is not derived from any other bootloader, that is a complete rewrite, from scratch (memcpy(), printf(), malloc() ... are all rewritten).
Note that there is different LILO versions named (bootsector at offset 3) slightly differently: LILO, zLILO, lbaLILO and even the old ILO.
Q4. Why should I use Gujin?
Some of the reasons I think of:
- The floppy (and later the hard drive) do not depend on the physical position of the file on the drive: you can create a new kernel, copy it in /boot, rename it (as long as its name begin with "vmlinuz", "zImage" or "bzImage") and just reboot. The bootsector do not need to be modified each time you build a new kernel (risk of unbootable system).
- The bootsector (first 512 bytes) saves register initial value (mostly dl and es:di), you should be able to load whatever OS (WinNT...) without _any_ problem.
- The complete process is protected by checksums, so you can detect easily bad sectors on the floppy, or recover from a bad/corrupted vmlinuz (its CRC32 is checked before the "big jump").
- Gujin is nearly completely written in C, so easily modifiable/extendable: it does few things differently considering the version of Linux loaded...
- You can boot in graphic all the time, even with a old PC with only a VESA1 or VGA-only video card.
- The video mode used by the kernel is easier to select.
- Most of the subsystems are written using BIOS _or_ direct hardware access, so it will work if it is either BIOS compatible or hardware compatible. I hope it already works on more PCs than other bootloader do.
- The mouse (PS2 or 3 types of serial mouse on COM1..COM4) is detected at the right time and used. This info is passed to the kernel.
- I am fed up executing linux/arch/i386/boot/{bootsect.s,setup.s,video.s}
- I want to build a floppy distribution, with max 22Kb of bootloader and an easy way to change the kernel-*.gz/initrd*.gz
Q5. My Hard Disks are detected two times.
On a usual PC, the Hard Drives are IDE (not SCSI) and are detected using the BIOS interface _and_ using the IDE interface.
Because the BIOS interface may not access the total content of the drive (buggy or too old) - you can use the IDE interface; and because there may be some trick on your partition table (a small software intercepting INT13) which will break IDE interface you can use the BIOS interface.
You can select what to probe in the setup screen, this will be saved on the boot medium (if not write protected).
Q6. Where is the configuration file?
I do not like configuration files, there is none. Moreover, when a PC has two or three distributions installed, where should Gujin look for this configuration file? In which root filesystem?
So you can use the same floppy disk to boot any PC you want.
Note that (very) few informations are stored in the beginning of file BOOTxxx.SYS, like the preferred text and graphic video modes. On another PC, this video mode may be invalid - so you can force the video mode at beginning (when the first line is being displayed) by pressing "Control"; a message saying "video mode set to simple text" will be displayed.
To erase all information stored on the floppy, like the setup selection, press CAPS-LOCK before the first line has been completely printed.
Do not try to modify the file BOOTxxx.SYS or to rewrite it: the complete boot process is protected by checksums.
Q7. Which kind of floppy can I use?
360K, 1.2M, 720K, 1.44M, 2.88M (untested)
1.68 Mbytes floppies are supported if your BIOS is able to read sectors over 18 on a floppy, your BIOS do not need to be able to read more than 18 sectors.
Note that you can type under Linux (when mtools installed):
"mdir -a a:" and you will see the hidden file "BOOTxxx.SYS" where xxx will be 144 for a 1.44 Mb floppy.
There is no problem to add files to this floppy, that is a real MSDOS FAT12 partition.
To save space, you can reduce the number of root entries (total number of files/directories in root), increase the number of sector per cluster, or reduce the number of FAT.
Reducing the number of FAT (to 1) decrease the compatibility, DOS is no more able to read the floppy, but mtools works perfectly.
Try: ./instboot --disk=144 --sectorpercluster=4 --rootdirentry=16 --nbfat=1 boot /dev/fd0
The "--rootdirentry=" shall be a multiple of 512/32=16.
Q8. Can the test crash my hard drive?
Gujin is a GPL software, so without guaranties of any kind, but because it is not writing to the hard drives, the risk is very small.
I still need to write an installer on the hard drive, to not need a floppy disk to boot the PC; this software will be more risky.
Q9. Why all my disks are scanned at the start-up of Gujin?
Gujin is looking for all files named "vmlinuz*", "kernel-*", "zImage*" or "bzImage*" in every E2FS or FAT12/16 partitions, either in the root directory or in a subdirectory named exactly "boot" - to show you a menu where you can click.
There is also in this menu the different bootsector that you can use - for instance if you want to run LILO.
So, you can power-up a PC with a fresh Linux installation on a new hard disk, and directly run it.
Q10. Can Gujin load an initrd?
Yes, it will load the file "initrd*" if it exist in the same directory as the file "vmlinuz*" selected. If there is more than one "initrd*", the file with the nearest ending as "vmlinuz*" will be loaded. For instance, if you are clicking on file "vmlinuz-2.4.0" and there is two files in "/boot" named "initrd-2.gz" and "initrd-2.4.gz", the later is loaded.
The initrd file has to be a GZIP compressed file, i.e. with the first two bytes "0x8B1F" (to check its CRC32).
Q11. The kernel starts correctly - but then stops with the message
"Kernel panic: VFS: Unable to mount root fs on ..." - what is the problem?
Can Gujin find alone the root partition of a kernel?
By default, the kernel file (vmlinuz-2.2.xx) contains the root partition to mount first as "/" - it is set to the current root of the machine compiling the kernel.
On most distribution (if you are using the distribution default kernel), this is a SCSI hard drive, like /dev/sda3 - and LILO will change it depending on "/etc/lilo.conf".
This default root can be seen by "rdev /boot/vmlinuz", and can be set by (for instance) "rdev /boot/vmlinuz /dev/hda2".
If the default root of a vmlinuz file is zero - or is a SCSI disk on a PC which has no SCSI disk, then Gujin tries to find a valid root partition:
If the "vmlinuz" file is in a "/boot" directory and the filesystem is E2FS, the root is the current partition; else Gujin looks for a directory which contains a subdirectory "/boot" in each E2FS partition - then it declares it as the root partition.
This will fail for complex PC with different installations of Linux, or with very old PC (SCSI disk detection) but then it is so easy to type the right "rdev" command...
Q12. Why, on this "old" PC, the root filesystem is only guessed on the IDE interface?
Because Gujin will not try to guess the relationship between a BIOS drive (0x80, 0x81...) and an IDE drive (IDE at I/O 0x1F0, 0x170, 0x1E8...).
For new PCs a BIOS field describe on which IDE the BIOS drive is, but not on 386/486 BIOSes.
Q13. Can Gujin replace loadlin?
When you type "make boot.exe" (or "make boot.com" if the file is smaller than 64 Kbytes), you get an MSDOS executable which is able to load a vmlinuz and an initrd file.
Note that in DOSEMU and WinNT/whatever they call that now, the kernel file is loaded correctly but the DOS emulator stops the execution of Gujin when it tries to switch to protected mode, and that cannot be "corrected"!
In the default configuration (no BIG_MALLOC and text or VESA1 video modes), the executable is 100% compatible with MSDOS, and so the "subst.exe" and network redirector software should work.
Q14. How can I debug a problem in Gujin?
Well, because I do not see a solution to plug-in a debugger, at least at an acceptable price, you can use the built-in logger, by defining the DEBUG variable in Makefile to send log messages to a serial or parallel (printer) port, or to a DOS file (if boot.exe), or to the screen, to know where exactly is the problem.
Note that pressing keys '1' to '5' displays some debugging info like malloced memory report, video modes available... Those will be removed soon.
Q15. Is Gujin ready and stable enough for production?
Well, it is up to you to say! I still have to write some new features (like the hard disk installer), but there are probably still some bugs I am not aware of...
To write this software I had to re-write nearly everything, up to the memory and string management functions (malloc, memcpy, strlen, printf...); the only standard thing is E2FS.
I really welcome success story, bug report (or better patches) at:
etienne.lorrain@masroudeau.com
If you have compiled yourself the code, please check before reporting a bug that it is still present after a "make proper dep /dev/fd0".
Q16. What are letters between brackets at the top of the screen?
It defines the way the video memory is accessed:
[VGA] : all characters are displayed using _only_ VGA BIOS functions
[INT] : in VESA modes, use the interrupt to change graphic window
[FCT] : in VESA modes, use the function to change graphic window
[hard] : My recorder works - access I/O ports to change graphic window
[hardc] : Same as [hard] but array is compressed (VESA 1.* default)
[lin] : Linear window used in real mode (VESA 2+ default)
[nowin] : The complete video memory fit in 64 Kbytes (VESA 1 or 2+)
There could be two [hardc][hardc] to say that a separate read window and a write window are used.
It is abnormal to have something else than [lin] on VESA 2 or VESA 3 cards - but maybe for 16 color modes, or when VESA2 support is removed from the configuration in the setup screen or the Makefile.
Q17. I have messages like "last partition over disk limit detected", what does it mean?
It is probably with hard disks using BIOS or EBIOS interface.
It means your BIOS cannot access the entire content of this disk. If the access is using BIOS, your hard disk has probably over 1024 sectors; if access uses EBIOS, your Extended BIOS may not be able to access more than 8 Gbytes.
In the later case, double-check the BIOS set-up: the autodetect feature of your BIOS (accessed at boot time) may not detect more than 16383 cylinders.
Try to set manually the cylinder field correctly. If you cannot, use only the IDE interface on this drive.
This message also appear when your [E]BIOS is reporting a size a bit smaller than the real disk size, and you have created the last partition under Linux:
The [E]BIOS will probably not be able to read a file if it is mapped in the last few Mbytes of the drive - but that is not usually a problem.
Q18. Why the name Gujin ?
Gpl Use of the Jnp INstruction.
I do not think anybody has used this 80x86 assembly instruction (jump if no parity) during the last 10 years, mostly for a GPL software. It saved me a byte in the bootsector - and there is only 0x1B6-0x3E = 376 bytes available there to do a lot of things, even if you have, on your PC, multi-gigabytes of RAM and few hundred of gigabytes of Hard Drives!
Q19. I have errors while Gujin loads, during this line:
Gujin1, Gujin2....ERROR.
or:
Gujin1, Gujin2.......CHECKSUM ERROR.
and it eventually loads after few tries.
Well, try another floppy disk. Also there is sometime quite a lot of dust in the floppy driver... but that is a cheap device.
If you want to check, you can boot Linux and type:
You will probably get something like:
floppy0: data CRC error: track 2, head 0, sector 17, size 2
floppy0: data CRC error: track 2, head 0, sector 17, size 2
cat: /dev/fd0: input/output error
Q20. How to quickly test a serial interface configuration (without a VT420)?
First, you need a twisted serial cable.
These instructions are using the "tiny" configuration, so that you do not need a real terminal emulator software able to use the serial ports.
Build first the tiny configuration with "make tiny".
Install it on a floppy with "./instboot boot /dev/fd0 --serial=com1"
Copy one kernel to the floppy, by "mcopy /boot/vmlinuz* a:vmlinuz"
Check the default speed of the serial line with "stty < /dev/ttyS0", it should be 9600 because it is the default of "instboot.c" and the maximum of the BIOS.
It is better to switch the serial line to raw mode with "stty -raw -icrnl < /dev/ttyS0".
Look at what arrives on COM1 with "cat /dev/ttyS0", you can stop this "cat" by "^C" at the end of the test.
Put the floppy in another PC connected to your current PC on COM1/ttyS0 and power ON this PC.
After some time you will see the boot messages of your PC. Note that you cannot really do something usefull without a real terminal emulator connected on /dev/ttyS0, and note also that message concerning the modem at the beginning: if you set up an ATDT sequence, you can remote boot through a modem (distant computer).
Q21. You said that I can boot a very large kernel - but I can not even get it to compile!
There is a test in "linux/arch/i386/boot/tools/build.c" to abort the generation of a kernel bigger than 2.5 MB uncompressed, because those kernel cannot be loaded by LILO.
If (and only if) you have a 2.4.1 or later kernel, it does not matter: you will still have in the top Linux directory the file "vmlinux".
Type:
objcopy -O binary -R .note -R .comment -S /usr/src/linux/vmlinux kernel-4
gzip -9 kernel-4
Then copy this "kernel-4.gz" to "/boot" and reboot. (8+3 filenames only)
If you want to boot a 2.2 kernel, you will have to remove the test in "build.c".
Q22. My Joystick does not work.
Move it first in the 4 directions (to its maximum position) for calibration.
Yes, you have to recalibrate it at each reboot - takes easily a tenth of a second!
5. TODO
- Fix bugs, clean source and optimise the code size.
- Write the HD installer. It has to either create a file on an E2FS or FAT12/16 partition or in free space on the HD (like the end of disk). It stores there the code _and_ a safety copy of the old bootloader, so a simple click on the menu is able to uninstall the bootloader (even if no system is loaded, for instance because the partition has been removed).
- Test that correct message is displayed when used on an 80286 or 8086.
- Remove the "write" code of E2FS library if I do not plan to use it.
- Negotiate a way to give information to the kernel, like the mouse found, I/O ports used by video card... Dynamical initrd building?
- Find out when a standard DOS bootsector will display "not bootable, press a key to continue" and remove them from the list.
- Manage multi DOS boot by hiding partitions - leave a TSR for some DOS boot.
- Support FAT32 and long filenames on FAT12/FAT16
- Write an ATAPI interface, support ISO9660 filesystem.
- Check serial getsize() when bad emulation (and maybe code: ESC [ 100 D )
- Is there (and what is) a problem with soft RAID hard drives?
- Code the keyboard language to type the extra command line parameters (and give it as a vmlinuz parameter).
- Find people speaking other languages to complete file "messages.h"
- Do a better-looking interface. A penguin should run at 100 mph around the screen showing the user where to click -:)
And also:
- serial getcontrol aborted on 'r'
- Automagic selection of kernel depending on the processor detected.
- disable running on 80386 if !defined (__i386__).
- check if already mounted (automount)?
- mkfloppy.exe or mkfd144.exe instead of rawrite
- Check VGA ET400 frequency
- Better/bigger/ANSI font - Go and get one of the /usr/X11/... font?
- Generate a DOS device driver "boot.sys" instead of a "boot.exe" executable? (useful to set it in "config.sys")
- A way to disable the automatic ide[0-9]=0x... command line parameter?
- Generate those ide[0-9]=0x... if the DOS boot.exe is used.
- Find why Linux kernel crash after startup at the first "sti()" if emm386.sys is in "ON" state (EMM386 AUTO solves it).
- Is there a special procedure to stop Windows95/98 before running the kernel (INT0x2F, ax=0x1609).
- Create a tiny.exe to load DOS file(s) given as parameters and add other parameters as Linux command line arguments.
- Upgrade my English to a better version -:)