<title>Gujin boot/Linux/system loader</title>
<meta content="program to start your PC and run Linux, Windows, *BSD from floppies, CDROMs, DVDs, hard disks..." name="Description">
<meta content="MBR bootloader bootmanager fdisk partition real-mode GCC Linux" name="Keywords">
Version v2.8.5
Here is the description you can find at
Freshmeat:
Gujin is a PC boot loader which can analyze your partitions and filesystems.
It finds the Linux kernel images available, as well as other bootable
partitions (for *BSD, MS-DOS, Windows, etc.), files (*.kgz) and bootable
disk images (*.bdi), and displays a graphical menu for selecting which
system to boot.
Gujin boots Linux kernel using the documented interface, like LILO and GRUB,
so it doesn't need any other pre-installed bootloader. It can also directly
load gzip'ed ELF32 or ELF64 files, with a simple interface to collect
real-mode BIOS data.
There is no need to execute anything after making a new kernel: just copy
the kernel image file into the "/boot" directory, with a standard name.
Gujin is written almost entirely in C with GCC, and it fully executes in
real mode to be as compatible as possible.
And here is Gujin's OSDev Wiki, and Linux Wiki.
A patch which has never been merged due to lack of interest, and would solve the "ISO not able to locate its own "source" iso file", valid for most distributions: Casper Gujin patch.
You can download the source code (you will need also gcc-4.5.1/gmp-5.0.1/mpfr-2.4.2/mpc-0.8.1/binutils-2.20.1 to get the same binaries), download the pre-compiled pack for installation, the RPM or DEB packages (generated by the distribution toolchain), and/or the precompiled standard/debug executable in here.
If you have any question about Gujin, please ask them on a public list/forum (the ones on sourceforge should do the job, or use the list "gujin-users" at "lists.sourceforge.net" if you do not want to register SourceForge), I simply cannot find the time to answer same questions by E-mail more than once, and then spend time to write FAQs. Why Ask Questions in Public?
Want to do something your grandchildrens will thank you for?
STOP eating fish! See The End Of The Line DVD.
Do not forget the other freedom, The Freedom of Information.
Your Right To Know for U.K., read the book!
Or freedominfo.org for other countries.
The day I support Europe institutions is the day they enforce a strong Freedom of Information Act, see
RMR.
The number of choices seems to be a problem for new users, because the installer tries to support every possible need - but it is in fact quite simple.
dpkg -i gujin*.deb
".yum localinstall gujin*.rpm
".
This method also handle upgrading Gujin, by uninstalling the previous version and
installing the new one. Unlike the Grub package, you can safely uninstall the Gujin
package and your system will stay bootable using the bootloader which was previously
installed./boot/gujin.cmd
if it detects
special booting options in /proc/cmdline
. See file gujin.cmd
in install*.tar.gz for real world examples.
For all other choices, you need to execute the Gujin installer as root in a console.
To get that executable, you either install the package as previously, or copy the
executable from the file install*.tar.gz in the /sbin
directory.
If you install manually, also copy the manual file gujin.8 in /usr/share/man/man8/.
If you want to have the Gujin package installed (to access /sbin/gujin
installer) but
keep Grub/LILO as your main bootloader, just type:
/sbin/gujin --remove /boot/gujin.ebios
after installing the package.
If you want to know which bootloader is currently installed in a device, just type:
/sbin/gujin --report /dev/sda
/sbin/gujin /media/usbdisk/gujin.ebios
/dev/sdX
with X being a letter), remove all
partitions of that device (gparted or fdisk) and then type:
/sbin/gujin --mbr /dev/sdX
/dev/sdX
with X being a letter), check that
the device do not have any partition defined, and then type:
/sbin/gujin /dev/sdX
/sbin/gujin -t tinyext4.bin /boot/minigujin.ebios
/sbin/gujin gujin.bcd --cmdline=""
/sbin/gujin -t minigujin.bcd --stop_emulation=2 --cmdline=""
/sbin/gujin
, but they are
not needed in the general case, and you should ignore them if its is the first
time you are trying the Gujin bootloader.
The documentation (FAQ & HowTo) is in file README.htm in the source tar file.
Gujin also has its "man" page in section 8: "man 8 gujin"
Note also the file "install.txt" and the help given by --help/-h option of the
"gujin" and "gzcopy" software included.
You basically have three flavour of the same Gujin bootloader, pre-compiled inside the "gujin" installer executable for ease of use:
The "gujin" installer uses this standard bootloader if the "-t" option is not given,
and (try to) autodetect the intended format of the output using the filename
extension or the characteristics of the device.
Just type one of those in a Linux console (insert parameter --lang=fr for french version):
./gujin /boot/gujin.ebios # install the second stage in contiguous file /boot/gujin.ebios and update the MBR (RAID still not supported)
./gujin gujin.exe # for DOS executable
./gujin eltoritobootableimage.iso # to be able to copy that image to SD card or USB drive
./gujin boot.144 --full # For 1.44 Mb floppy image, for instance use with "mkisoimage -b boot.144", see Makefile target CD144FD
./gujin gujin.bcd # For Bootable CD in no emulation mode, use with "mkisoimage -no-emul-boot -boot-load-size 4 -b gujin.bcd"
./gujin /dev/fd0 # autodetect the floppy in /dev/fd0 and format a new FAT12 with Gujin
./gujin /dev/hdg3 # format a Gujin-bootable FAT16/32 filesystem on /dev/hdg3; this partition needs to be activated by the MBR (MBR is not modified)
./gujin --mbr /dev/sda11 # format a Gujin-bootable FAT16/32 filesystem on /dev/sda11 and replace the code of the MBR to run Gujin from /dev/sda11 (keeping the partition table)
./gujin /dev/sda0 # install Gujin into a B.E.E.R partition at end of the disk /dev/sda (needs empty space there) and set the MBR (keeping the partition table)
The uninstall method (i.e. replacing the MBR with the original one) is handled by Gujin itself in its
setup menu at boot time, but if you have used the "contiguous file method" (i.e. /boot/gujin.ebios) you
can also desinstall by "./gujin --remove=/boot/gujin.ebios
".
You can get some information on your installed bootloader using "./gujin --report=/dev/sda
".
If you want to format the complete disk (i.e. erase/initialise the MBR and the partition table), for instance
to create a bootable USB drive, you have to umount and manually clear first the beginning of the device by:
umount /dev/sdg*
And then invoke ./gujin to create either a disk image or a floppy image (with or without partition table):
dd if=/dev/zero of=/dev/sdg bs=512 count=63 # triple check the output device of= parameter!!!
./gujin /dev/sdg --disk=BIOS:0x00,auto # (super)floppy image
If your PC BIOS is new enough to support the Extended BIOS interface on USB disks, you can
forget the parameter "
./gujin /dev/sdg --disk=BIOS:0x80,auto --mbr # disk image
--disk=BIOS:0x?0,auto
", the installer will defaults to "--disk=EBIOS:0x?0,auto
".
Laptops like DELL PRECISION M70 will not boot if "--disk=BIOS:" is used (i.e. Extended BIOS only), netbook like EeePc will not boot
if "--disk=EBIOS:" is used (i.e. BIOS only for USB keys).
If the only machine you can boot (after a disaster day) is a windows machine and you need a bootable
floppy/USB stick as soon as possible, you can get file boot.144 or USB*Gb.img in install.tar.gz and get
dd for windows
(documentation).
You then type dd --list
to list all drives available on your PC, look for "Removable media"
on this list, you should have something like:
\\?\Device\Harddisk9\Partition0 link to \\?\Device\Harddisk9\DR36 Removable media other than floppy. Block size = 512 size is 1048576000 bytesWhere
Partition0
means the whole disk. Check that by unplugging the USB stick, the corresponding entry disappear.dd if=..\USB1Gb.img of=\\?\Device\Harddisk9\Partition0 --progressTake extreme care in selecting the right disk: it will destroy every files on that disk, if you have selected the wrong disk there isn't any recovery possible (never ever select a fixed hard disk), your windows PC would never boot again.
To use the target "eltoritobootableimage.iso", you just need a bootable ISO image like ubuntu-9.10-desktop-i386.iso.
If that image is written in a USB thumb drive like "cat ubuntu-9.10-desktop-i386.iso > /dev/sdc ; sync
", it will not
produce a bootable USB thumb drive. Moreover, some PC (like my EeePc) do not accept to boot a USB device
if a partition table is present, so most of the usual methods found on Internet to create a bootable USB drive do not
work (on my EeePc).
The solution is simple, just type "./gujin ubuntu-9.10-desktop-i386.iso
", it will modify the file ubuntu-9.10-desktop-i386.iso
so that you can do "cat ubuntu-9.10-desktop-i386.iso > /dev/sdc ; sync
" and have a bootable USB disk.
The modifications are just changing the first 512 bytes of ubuntu-9.10-desktop-i386.iso, and add a very small
FAT12 filesystem at the end, so the modified file ubuntu-9.10-desktop-i386.iso is still a valid ISO image and can
be written to a DVD and that does not affect El-Torito booting. The modifications are reversible by "--remove=" parameter.
The "gujin" installer has a lot of options (seen by typing "./gujin -ha"), for instance the --full option for floppies
and the -w option to have a verbose installation, the --read_retry, --cmdline="", --single_sector_load,
--partition_index=[1-4]... parameters.
The "gujin" installer produces the file "/boot/gujin.cmd" when it detects that command line parameters are
needed by the Linux kernel, reading file "/proc/cmdline". You can review that file and edit as needed.
Note also some binary debug versions of file "boot.bin" which can be transformed
into dbgdisk.exe, dbgfs.exe, dbgload.exe... for debugging (creates a file named "DBG" when
run under DOS - the file needs to be closed properly, for instance type ^C).
mingujin.exe D:\boot\vmlinuz D:\boot\initrd root=/dev/hda3 <other kernel parameters>
or (the "initrd=" parameter has to follow the kernel name, always as 2nd parameter):
mingujin.exe D:\boot\vmlinuz initrd=D:\boot\initrd root=/dev/hda3 <other kernel parameters>
If you do not have an initial RAM disk to load, either use a minus "-" sign or use
a parameter which cannot be a filename because it contains an equal "=" sign:
mingujin.exe D:\boot\vmlinuz - root=/dev/hdb5 <other kernel parameters>
The <kernel parameters> needs at least a "root=/dev/hd..." parameter,
this flavour will not try to probe anything, and return to DOS if an
error happens before Linux takes control of the PC.
./gujin -t tinystd.bin /dev/fd0
mcopy vmlinuz-2.6.10 a:
mcopy initrd-2.6.10 a:
mdir a:
And then reboot by Control-Alt-Del or a power cycle. It should load the
kernel and the initrd and start Linux.
One of the problem of using Gujin is that there is only one command line editable and
stored, so it is difficult to manage multiple distributions with different command lines.
I have added a small executable named "gujin-cmdline" to insert an "embedded command line"
into some free space of vmlinuz files (i.e. the end of the bootsector). The starting marker
is simply "cmdline:" and the string has to be zero terminated, it has to be located below
the first vmlinuz parameter. The maximum space there is currently 296 bytes.
This embedded command line can only be edited under Linux, use as:
./gujin-cmdline /boot/bzImage+2.6.24 # to display this embedded command line
Gujin will erase this field from memory before running the kernel, so Linux will
never see the difference. Other bootloaders will not see any difference neither.
./gujin-cmdline /boot/bzImage+2.6.24 "root=/dev/sda6" # to set it
In short, to make all this possible, I wrote a GCC interface to the PC BIOS
and all the library functions needed to easily boot a kernel.
I also wrote a DOS interface to be used if you booted a rescue DOS floppy or
if you choose "return to DOS" in Windows 3.x/9x. This DOS software should work
everywhere but will not be able to start Linux in a Windows DOS box -
you do not want to do that anyways (too many open files not properly closed,
so a scandisk at boot).
I am using a completely re-written GZIP (decompression only) library, 100%
compatible with
GZIP and
zlib
and a small Linux/UNIX "gzcopy" application to edit the comment field of
GZIP files.
The main reason for the rewrite is a smaller program size, it has been
seriously tested (10 CD-ROM full of .tar.gz decompressed and CRC checked),
but if anyone find a problem (else than CDROM not readable or a file
renamed to *.gz after being compressed with another tool) I will be glad
to hear from it.
I am also using a completely re-written E2/3/4FS (read only, only fixed size inodes)
library, a DOS FAT12/16/32 (read only) and a ISO9660 library to search for and load kernels;
they have been tested extensively (E2FS, E3FS with 1 & 4 Kbytes blocks, lot of
DOS filesystems, CDROM and DVDROM), no problem has been found.
There isn't any NTFS nor CDROM/UDF support.
The system to access the video interface, which can handle in graphic modes
CGA/EGA only, VGA only, VESA1 only and VESA2+ video card is unique to Gujin.
Four types of mouse are detected, for fun you can even have a joystick on
a VT320 when using the serial interface - I have to make a screen shoot
one day!
The size of this bootloader (only one file) is in between 50 and 250 Kbytes,
depending on the compile time options.
Screenshots are not easy to take in the real BIOS environment, but
fortunately DosEmu is here,
to give you some idea of what you get, just before switching to graphic (if verbose mode is active):
You should check at least once that this information is correct, for instance note that here, I have a partition 45667938 sectors (i.e. 21 Gbytes) bigger than the filesystem it contains (a 22 Gbytes partition where I copied the Damn Small Linux bootable CDROM by "cat /dev/cdrom ⊃ /dev/hda8" - obviouly a lot of wasted space for this 100 Mb CDROM); you can then uncheck the "verbose" box in the setup screen for a "quick" boot.
Just after switching to graphic, you will see something like this if you
have a Linux distribution with a memtest floppy image and three kernels, a Redmond system,
a CDROM image inside a partition, and the demo standalone *.kgz on a floppy:
Then, if a mouse/joystick has been detected, you can click to one of the
highlighted fields to either switch to another video mode or boot a kernel,
else you can use the keyboard interface (keys '+', '-','/', '*' ... , and function keys).
Note that those kernels have been found automagically, they are not described
in any "/etc/gujin.conf" file: this file do not and will never exist.
If you press "space" or the "setup" field (on the top right), you can
setup the display and remove some fields (click on checkboxes):
So you get by re-clicking setup or re-pressing space:
The setup screen has a lot more checkboxes, to search kernel and/or MBR,
to search on floppy disks or on BIOS disks or only on IDE...:
To show a screenshot of Gujin menu with CDROM/DVDs, I need to use another
emulator: Bochs.
This one is slower but simulate correctly the (first session only) of CDROMs.
If you want to generate more complex CDROMs than this one, you should read the
few commands lines of target "CDall" and/or "CD_BDI" in file Makefile.
You can also change the language used at run time by typing
Control T - look at "messages.h" file to help supporting/correcting
your own language...
At the end (press the end key or click on the button) you get some
command, last one being "uninstall" to remove Gujin and restore the
old boot process. Here, that option is not enabled because dosemu
has booted from a floppy, so there isn't any saved boot sector:
You can also get more unusual video modes, like text mode 40x25:
16 colors video modes in VGA only graphic:
or even 4 colors video modes (2 Bit Per Pixel but in dosemu):
Yes, that is the same software, the same floppy!
By the way, if you do, on a test floppy:
put this floppy in the PC to boot, and link the two PCs by
a crossed serial line (fully wired null-modem) (with or without
two modems and a phone line in between), you can type:
./gujin --full /dev/fd0 --serial=com1,9600,n,8,1
The "serial initialisation failed" is due to no answer received whatsoever when interrogating the terminal type - Gujin then assumes a monochrome VT100 terminal. If you have a more powerful terminal, like a color VT430, or a VT420 which can do 132 columns and 48 lines, be sure to connect it before the identification code is asked (physical terminal autodetection).
You can start minicom/GtkTerm/PuTTY and set it to /dev/ttyS0, 9600 bauds,
no parity 8 bits, no hardware flow control and get:
Active/clickable fields are underlined, as usual.
Selecting a kernel will really boot it (you will have the console on your serial line) - you will need to setup getty to accept connection on serial line (in /etc/inittab) if you want to connect (see also /etc/securetty).
Have fun!
Comments to Etienne Lorrain.
Donate to gujin boot/system loader
Last modified 2010-12-03
Gujin is hosted by