	Install notes for Gujin-2.x
	---------------------------

 Please first note that Gujin is available under the GPL license version 2.
 That means you can freely get and read the source code (the free side) but
 also that I cannot afford buying thousand of different hardware
 configurations and test everywhere.
 As with any bootloader - backup first! The full license is given in
 the file GPL.txt.
 Please also note that PCs with SATA hard drives should have an IDE
 interface register compatible with ATA systems - at least considering the
 SATA specifications. Well, I have seen at least one SATA _not_ compatible,
 so you would better use only the EBIOS interface on those PCs, mostly
 when installing on your hard drive. I.e. on these (few) PCs, using
 "gujin --disk=IDE:..." is then not recomended.

 I know you just done this full backup. I also know you would not like to use
 the emergency restore procedure, so we will proceed step by step. Note that
 I will only describe the installation on a Linux system; if you have another
 Unix Intel IA32 based system it may work; if you have another operating
 system, it is time to try out one of those bootable CDROM which boot Linux
 without installing anything on the hard drive.

 If you are a professionnal of bootloader installation but cannot read
 my english, jump directly to "<VERY short version>" at the end of this file.

 In two words, if you want to upgrade from version >= 0.9, you have
 to _exactly_ do this - do not skip the first step:
 POWER DOWN the PC
 Power up the PC to boot the old version of Gujin installed on the hard drive
 Select uninstall at end of the setup screen
 Select a kernel too boot (HPA will not be set because of the uninstall)
 In Linux, in the uncompressed install directory, type "./gujin /dev/hda0"
 Type 'yes' to confirm the creation of the B.E.E.R. partition

 The different file needed are in the install.tar.gz file:
$ tar xzf install-2.8.6.tar.gz 
$ ls -l install
total 32184
-r-xr-xr-x 1 etienne etienne     9616 Oct 10 20:32 addhole
-r-------- 1 etienne etienne  1474560 Oct 10 20:32 boot.144
-r--r--r-- 1 etienne etienne     3908 Oct 10 20:31 cleandisk.kgz
-r-xr-xr-x 1 etienne etienne  1214037 Oct 10 20:32 gujin
-r-xr-xr-x 1 etienne etienne  1349212 Oct 10 20:31 gujin64
-r-------- 1 etienne etienne   342016 Oct 10 20:32 gujin.bcd
-r--r--r-- 1 etienne etienne    11031 Oct 10 20:32 gujin.cmd
-r-xr-xr-x 1 etienne etienne     9616 Oct 10 20:32 gujin-cmdline
-r-------- 1 etienne etienne   341024 Oct 10 20:32 gujin.exe
-r--r--r-- 1 etienne etienne  2600960 Oct 10 20:32 gujin.iso
-r-xr-xr-x 1 etienne etienne    26000 Oct 10 20:32 gzcopy
-r--r--r-- 1 etienne etienne      787 Oct 10 20:31 hello_32bits.kgz
-r--r--r-- 1 etienne etienne     1109 Oct 10 20:31 hello_32bits_r.kgz
-r--r--r-- 1 etienne etienne      513 Oct 10 19:08 hello_64bits.kgz
-r--r--r-- 1 etienne etienne      719 Oct 10 20:31 hello_64bits_r.kgz
-r--r--r-- 1 etienne etienne      629 Oct 10 20:31 hello_bios.kgz
-r--r--r-- 1 etienne etienne     1817 Oct 10 20:31 hello_gpl.kgz
-r--r--r-- 1 etienne etienne    38884 Oct 10 20:32 install.txt
-r-------- 1 etienne etienne    51232 Oct 10 20:32 mingujin.exe
-r-------- 1 etienne etienne    63488 Oct 10 20:32 minigujin.bcd
-r-xr-xr-x 1 etienne etienne    13712 Oct 10 20:32 showmap
-r-------- 1 etienne etienne   598016 Oct 10 20:32 USB1Gb.img
-r-------- 1 etienne etienne   630784 Oct 10 20:32 USB2Gb.img
-r-------- 1 etienne etienne  8163328 Oct 10 20:32 USB4Gb.img
-r-------- 1 etienne etienne 15962112 Oct 10 20:32 USB8Gb.img

$ md5sum install/*
4972bbfe80f98a034d62e4b7bb7fdb05  install/addhole
93174985eeb0f8330ab08fe8805ba8aa  install/boot.144
f8b169eead81698b5f23b1fa3c85dd9e  install/cleandisk.kgz
43eab7db0adf2e69809c737211815a39  install/gujin
ffc1256c289ad130551ba9b1ba5a4338  install/gujin64
38f69411ea51b7b8bac20665c33418ac  install/gujin.bcd
fea09d321fea9b2f2ce9cad7cbe9e2c3  install/gujin.cmd
f75be97f6aae5b187ad6f7bcb83f5cd1  install/gujin-cmdline
e9db01fe74fa09ff9136a03fa453b553  install/gujin.exe
ba970df7a0a874d8e9ebd46b871e6103  install/gujin.iso
b56baba0cafafcafaadd73561bc99759  install/gzcopy
2b3e96e0fdbd5719c3080dc62368dc50  install/hello_32bits.kgz
0b3086af4ce0d69edfb0520d7d3f3e1e  install/hello_32bits_r.kgz
324dda87bffa82ee14d8436e5c3d8544  install/hello_64bits.kgz
d294e5f7484e05f338b3e35ca90bcd02  install/hello_64bits_r.kgz
fcaf6fb0bafd2e1b27bd0ae50b88e1a4  install/hello_bios.kgz
e32397b9e1dac6e1c6a7760d778a9cd4  install/hello_gpl.kgz
0aff8a04cdd1666fac02134229241e93  install/mingujin.exe
ef1bfe462049b457085508234101b442  install/minigujin.bcd
4ee54b7a98685990e1246c722625a698  install/showmap
3ac26954aeb18d2afdd1b03119921621  install/USB1Gb.img
bdecae2839f023218db129fde238181f  install/USB2Gb.img
aebbb4b6ecfb649b40b41ab60ece36ab  install/USB4Gb.img
e296dd78a6f66cbd383d2b0fdd64f846  install/USB8Gb.img

 First extract them in a directory:
$ tar -xzf install.tar.gz
$ cd install
$ ls -l

 You have:
 - The Gujin installer "gujin" and its 64 bits version "gujin64" which contains
 pre-compiled bootloader executable - for instance you can type
 "./gujin /boot/gujin.ebios" to install the standard way other bootloader
 do.
 - The demo iso image "gujin.iso" that you can write to a CDROM to
 boot your PC and see what Gujin can do.
 - The file gujin.cmd which contains docs on how to supply command
 lines to kernel, and real-world examples on how to start kernel/initrd
 inside well-known CDROM live distributions.
 - The file "mingujin.exe" which is standalone because it is the only Gujin
 flavour which has an image supporting only DOS.
 - The files boot.144, gujin.bcd and gujin.exe if you cannot run the installer
 "./gujin gujin.*". In short you can "cat boot.144 > /dev/fd0",
 "cp gujin.bcd /tmp/cdrom ; genisoimage -no-emul-boot \
	-boot-load-size 4 -b gujin.bcd /tmp/cdrom | cdrecord -"
 and start DOS (MyComputer->floppy->format->Create a MSDOS startup disk and
 cut&paste gujin.exe to the resulting floppy) to do "A:\gujin.exe".
 - Some USB thumb drive images to "dd" to a real USB.
 - this install.txt file.
 - the gzcopy to copy GZIP compressed files while adding/removing/displaying
 the content of their comment fields and few other details.
 - a utility to show the sector position of a file on the disk (showmap)
 and to create a contiguous file on EXT2/3FS to be able to generate a
 file to be used as a floppy image, for instance /boot/msdos.bdi (addhole).
 - few examples of compressed ELF file (extension *.kgz) which are
 directly run-able from any version of Gujin (gujin.exe, mingujin.exe or
 installed on a disk).

 Lets first talk about the first file named "mingujin.exe", to treat the less
 interesting stuff first... Just boot from a DOS bootable floppy (with or
 without himem.sys, emm386.sys, smartdrive...) and type on the command line:
mingujin c:\vmlinuz c:\initrd.img root=/dev/hda4
 It does not do much: just loads the kernel, the initial ram disk if needed,
uncompress them, and pass the end of the line as the kernel parameters.
 If you do not want to load any initial ram disk, just replace the name
 with a minus sign:
mingujin.exe c:\vmlinuz - root=/dev/hda3
 Note that if the initrd filename contains an equal sign, it is assumed that
 this is a parameter, and loading an initrd is also cancelled.
 Note that you can use any path you want - those files are just loaded with
 the DOS interface - 8+3 letters filename. There isn't any analysis of the
 video mode or of the root filesystem - you have to provide them yourself.
 Mingujin.exe is just the smallest possible executable to load a Linux kernel.
 You can switch to a VESA mode with for instance "mingujin.exe /V=1024x768x24 ...",
 and get a list of video modes with "mingujin /V", but no real check is done for
 the validity of this mode for the kernel loaded.
 
 I have to say that it is not possible to load Linux from a DOS window in
 MS Windows 9x, and you do not want it because it would exit MS Windows
 without closing files. You can still "reboot to DOS" or proceed like drivers
 installer for MS Windows Me (dialog box to restart the system).
 
 I also have to say that it will not work with some very old versions of
 EMM386.EXE (before MS Windows 95) - but it will work with most of them.
 The very old version will just need "emm386 OFF" at DOS prompt before
 running Gujin loader "mingujin.exe".

 A bit more interesting is to load a kernel without DOS support, but we still
 do not want to touch the hard disk because you (not me) are not confident
 enough. Then the right solution is to use a floppy, you need to have one
 without bad sectors (as reported after a DOS "format a:" or Linux
 "fdformat /dev/fd0").
 Under Linux, you may need to be root if your floppy device is only accessible
 to root, or you can try a chmod (chmod a+rw /dev/fd0):
ls -l /dev/fd0
brw-rw-rw-    1 etienne  floppy     2,   0 Feb 23  2002 /dev/fd0
    ^^ ^^ <--- bits to look at
 Note that some distribution have an automounter and you will need
 to "umount /mnt/fd0" to be able to read and write the floppy.

 So (and whatever the size of the floppy, it is autodetected), you just need
 to type in a terminal:
./gujin /dev/fd0
 You can, while you are here, ask for help:
./gujin -h
./gujin -ha
 So that you will learn the "-w" i.e. "--verbose" option to get more detail
 of what is done, and the useful "-f" or "--full" to initialise the
 complete floppy.

 After this is finished, you will have a standard floppy disk with one
 hidden/system file named "boot144.sys" as reported by "mdir -a a:".
 The three digits "144" say that the floppy was 1.44 Mbytes, I could have
 had "288", "720", "360", "168", "120" with other kinds of floppy.
 Note that this file "boot144.sys" is position dependent on the floppy,
 you cannot erase it or copy it to another floppy.

 If you do not want to use the ./gujin installer each times you make a
 new floppy, you can create a floppy image:
./gujin --full boot.144
 and you can then compress it:
gzip -9 boot.144
 So you can use it like:
zcat boot.144.gz > /dev/fd0
 Note that I used "--full" to fill in completely the image, so its
 uncompressed size is exactly 1.44 Mbytes. It is important because the image
 is floppy size dependent, and so you will have an error if you try to put
 this image on a 720 Kbytes floppy - the two floppy kind look the same!
 It is also important for some tools to write bootable CDROM, with a
 virtual 2.88 Mbytes floppy, to access it (when not compressed) with mtools
 (see file "/etc/mtools.conf"), and if you want to use a PC emulator
 (like DOSEMU ...) to either test Gujin or your emulator.
 You can then reboot your PC with the floppy inside the floppy drive and
 you should boot Gujin for the first time.
 If you do not want to reboot but just want a demo, you can install the
 DOSEMU package and run "xdosemu -A", or define the floppy image boot.144
 as virtual A: for DOSEMU.

 Note that this bootable floppy is neither kernel nor distribution dependent,
 it will detect any Linux kernel in /boot directory and propose a menu for
 you to select which kernel you want.
 You just need _one_ recovery floppy from now on.
 The best is for me to let you play with this floppy few minutes - just note
 that by default nothing can be written to any disk (as a safety) and to
 enable writes you need to go to the "setup" screen and tick a box.
 Note also that by default Linux starts in text mode - the last used text
 mode - to start with a framebuffer you need to tick another box.
 You may also need to check the kernel parameter passed to Linux (see at end
 of Gujin setup screen) to increase/reduce verbosity of the kernel startup
 procedure.
 There is a lot more to say about all these options - but it will not fit
 in this introduction and I hope most things are intuitive.

 The floppy images you produce with "./gujin" can be used to produce bootable
 CDROM in floppy emulation mode, by typing something like (distribution
 dependant):
ln -s /dev/hdc /mnt/cdrom
mkdir /tmp/cdrom
cp boot.144 /tmp/cdrom
mkisoimage -R -b boot.144 /tmp/cdrom | cdrecord -v -
 If you do not have "cdrecord", try "wodim" (same parameters).
 Booting CDROM in floppy emulation mode is not working on all PC BIOSes,
 people usually prefer to use the no-emulation mode:
./gujin gujin.bcd
cp gujin.bcd /tmp/cdrom
mkisoimage -R -no-emul-boot -boot-load-size 4 -b gujin.bcd /tmp/cdrom | cdrecord -
 More information in the file Makefile, look for targets CD288FD and CDnoemul.

 I have here to talk about the "tinystd.bin" file (embedded inside the ./gujin 
 executable), i.e. the floppy you get when typing:
./gujin -t tinystd.bin /dev/fd0 --full
 This is the minimum bootloader able to load a kernel and an initial RAM disk
 out a FAT12/16 filesystem, like the one created on the floppy. So to have a
 basic installer (no video mode fancy stuff), you just mcopy the file "vmlinuz*"
 and "initrd*" to the floppy created, and you reboot.
 The PC loads Gujin, then search for the usual filenames on the boot floppy
 only, and load the first kernel found. You have to use tinyusb.bin if you
 have partitions - for instance on USB thumb drives, and tinycdrom.bin if
 you want to do the same on a CDROM or DVD (do not forget --stop_emulation=0).
 The first successfully loaded kernel (after checking processor restriction...)
 is run without any confirm - anyway the C functions to read the keyboard are
 not even linked-in. To see the command line of the Linux kernel, just press
 and keep the control key alone when the last file is being loaded.
 In Gujin-1.4, FAT16 probing has been added to enable a floppy like
 partition scheme on a USB thumb drive.
 You get this loader for 38 Kbytes, not bad if you are planning to do
 a 2.88 Mbytes virtual floppy on a bootable CDROM.

 After version 2.5, it is also possible to give as target of the ./gujin installer
 an ISO image, so that this ISO image file will be modified to enable to copy
 it onto a SD card or USB key and boot like a CDROM.
 Basically a new FAT filesystem (by default FAT12 of 320 Kbytes) is
 concatenated at the end of the ISO file and the first 512 bytes of the ISO
 file (usually blank) is replaced by the first sector of the FAT filesystem.
 You have what I call an ISO+FAT filesystem image, and you can mount each of
 them with the standard mount -o loop (add offset=size_of_iso_in_byte for FAT).
 The installer also build the sector load chain, so it cannot be just a "dd" 
 command. The added FAT contains the full Gujin bootloader which will detect 
 the ISO image, create the simulated disk of El-Torito and run it automatically.
 The simpler is to test, for instance download the easypeasy-1.1.iso 
 distribution (save easypeasy-1.1.iso in a safe place, and work on
 a temporary copy - the *.iso file will be modified) and type (after inserting 
 a SD card of sufficient size into the "special" SD slot):
./gujin easypeasy-1.1.iso
umount /dev/mmcblk0
cat easypeasy-1.1.iso > /dev/mmcblk0
sync
 If you want to use a USB key or do not have the "special" SD slot but only a 
 USB SD card adapter, detect on which /dev/sd* port it is, and type instead:
umount /dev/sdg
cat easypeasy-1.1.iso > /dev/sdg
sync
 If you insert that card/key into an EeePC (with an up-to-date BIOS), you will 
 first boot Gujin (first displayed line) and automatically (if you do not press 
 a key) boot the El-Torito bootloader.
 Obviously this SD card or USB key is erased by this process, do not use a key 
 with important files on it.
 As usual, some PC may not boot SD cards, or SD cards in USB adapter, or USB 
 drive - you can try on those:
./gujin easypeasy-1.1.iso --disk=EBIOS:0x80,auto
 If you find another use for the FAT filesystem created, you can increase its 
 size by the standard --fs=FAT:<nb_sectors> parameter (leave as default all
 other parameters, just give nb_sectors).
 If your favorite distribution boots, but stops after some time because it
 does not find the root filesystem (i.e. the rest of the distribution files) on
 any inserted CDROM, you may tell the distribution manager to mount his
 root filesystem by filesystem name instead of forcing "/dev/cdrom".
 If you are deseperably looking to report a bug, you can also complain
 that such a distribution on a SD card open the CDROM tray in the power
 down process.
 Important note: some distribution automounter will detect such a device
 with this modified ISO file as a FAT filesystem and display a window where
 you can read and write files. DO NOT write anything if you do not see the
 file boot.bio - there is a bug somewhere in the automounter and the
 filesystem is not mounted with the right parameters - I do not know where
 you will end writing. Technically, the detection of the filesystem by the 
 automounter should detect the ISO9660 filesystem because it should fail to 
 detect the FAT filesystem (first byte of FAT is not the Media Descriptor).
 The automounter could detect the FAT filesystem only if it did not assume
 that the Hidden Sectors field is equal to the start of partition/device.
 I have to write a bug report, but first I have to find who to send it to...
 feel free to do it yourself.
 The mount command may be confused by a so small FAT if using the
 default 320 Kbytes, but anyway you cannot really do anything with
 that filesystem if you do not inccrease its size.

 I hope now that you are getting really interested - you want to have this
 thing on your hard disk, you do not like floppies...
 More importantly, you seem to have a correct hard disk that Gujin understand
 correctly (without warnings), your hardware is stable and you do not
 overclock this test PC.
 For the following test, you need a small free primary partition, anywhere
 on the hard disk, where the extended BIOS can read (reduce your last
 partition containing the swap...). It has to be a primary partition because
 the default MBR does not search active extended partitions.
 You do not need to be root once you have created the small partition, so
 other partitions will be safe. So just create a 16 Mbytes (in between
 360 Kbytes and 256 Mbytes) partition of type FAT16 and activate it (the
 activate flag of fdisk - only one partition shall be active) - I call
 mine /dev/hda4 - replace the digit by the right number!
 Then you enable Read/Write access for anyone: chmod a+rw /dev/hda4
 Now go back to standard user mode, you no more need root access.
 Note that this small partition will be erased by the install procedure,
 like the floppy you used before - so DO NOT use a partition with some
 important files on it.
 Just type:
./gujin /dev/hda4
 If everything is right, ./gujin ask for a confirmation before creating the
 filesystem, you have to answer by the three letters 'y','e','s'.
 If you are curious, I invite you to add the -w/--verbose option, and/or
 the --fill option to re-initialise every sectors on this FAT filesystem.
 Like for the floppy, you can read this partition with mtools (/etc/mtools)
 or even mount it with "msdos" or "vfat" filesystem type.
 The file created is bootebio.sys, because you used by default the Extended
 BIOS interface, which can usually read hard disks up to 132 Gbytes or more.
 If you are testing on this old 386 PC, I just say you how to use the
 standard bios for now:
./gujin /dev/hda4 -disk=bios:0x80 --verbose

 If you now reboot your PC, and have a standard MBR (fdisk /mbr) or select
 to boot this partition using your old bootloader (hint: use the previous Gujin
 floppy!), you will see Gujin starting - a lot faster than with the floppy !
 Note that if you are using the previous Gujin floppy to start this partition,
 you have to go to setup and tick the box to display all MBR, because
 Gujin will have detected that this partition does not contains the DOS
 bootable file IO.SYS nor IBMBIO.SYS so probably cannot be started...

 You will say me soon - What ? using "fdisk /mbr" ?
 I answer: yes - else you need read/write access on the whole disk, and
 that is only the next step:
 So reboot your preferred Linux distribution, then connect as root to
 enable read/write access to /dev/hda:
chmod a+rw /dev/hda
ls -l /dev/hda
 Now disconnect and reconnect as a standard user (use the "su" command, it
 is faster). Note that each time you add rights like this, the test is more
 risky if everything crash. This time you just type:
./gujin /dev/hda4 --mbr-device=/dev/hda
 It does exactly the same, but saves the old MBR in a safe place (the end of
 bootebio.sys file) and copy the new Gujin aware MBR at sector zero and in a
 safety place (the begin of bootebio.sys file).
 You can now reboot the PC, it will automatically load Gujin located
 on /dev/hda4.
 Note that Gujin is only using the first sector of the hard drive and some
 sectors of /dev/hda4 - it can be installed on older hard drives with less
 than 63 sectors per track unlike other bootloaders.
 Note that this Gujin aware MBR does not need the Gujin partition to be
 a primary partition, it will perfectly work with extended partitions like
 /dev/hda9.
 Few unusual tips:
  - The Gujin Master Boot Record does not care of the "bootable" flag of
  partitions - but it can manage hidden/unhidden FAT partition and change
  the "bootable" flag depending on which system is selected for boot.
  - If the partition table is modified (you have added or removed some
  partition using any operating system), Gujin detects it and proposes
  you to update the backup. Most of the time you will do it by just typing
  return - but you can also type space to _restore_ the old partition table.
  Just having the active flag or some hidden partition will not trigger
  this question. Another similar question will appear if the MBR code has
  been modified. It is useful if you have completely crashed your hard drive
  or if you have installed another operating system, just put any Gujin
  floppy/bootable CDROM and ask to restore the MBR, then reboot.
  - You can unchain this Gujin MBR and replace it with the previous MBR
  content with the last operation on the setup screen once in Gujin, so that
  you are really uninstalling Gujin from this hard disk. Erasing the FAT
  partition created with ./gujin will completely erase Gujin. It is
  probably the best way either to uninstall or to upgrade Gujin, unchain it
  first and then boot Linux. There is still not any way in the installer
  ./gujin to upgrade Gujin to a newer version but keep the previous MBR
  to uninstall with the initial LILO/GRUB.
  - Newer PC BIOS will detect if the MBR, i.e. first sector of the master
  hard disk of the primary IDE, is bootable or not, and if not bootable
  (HD not working or first sector not containing special marker like any
  partition active) will skip this hard disk in the BIOS count. The slave
  disk of the primary IDE is then called drive 0x80, instead of the
  usual 0x81. It can be used to install Gujin on the two hard drives as
  disk 0x80 - the EBIOS will choose the first working hard drive.
  - If you do not know which number to put after "-DISK=EBIOS:", use
  "-DISK=EBIOS:0x80,auto" when you have a partition table and
  "-DISK=BIOS:0x0,auto" when you have a floppy/partition image;
  the first number is put in a field of the MBR and the second
  is used to load the second stage of Gujin - when the second
  number is "auto" the register DL is used to autodetect the boot
  disk.

 While we are here, some people will report non-working Extended BIOS, or
 they do not want to use the BIOS/EBIOS for whatever reason. This is done
 at install time:
./gujin /dev/hda4 --disk=ide:hda
 will detect the capabilities of your hard disk (can it do lba or lba48
 or only chs) and setup the access to load Gujin at boot without using the
 disk BIOS at all. The verbose mode is as always a lot more descriptive.
 Note that you may need to be root because:
$ ls -ld /proc/ide/hde/identify
-r--------    1 root     root            0 Feb 13 21:02 /proc/ide/hde/identify

 Note that by default Gujin reprint the command line with the final
 parameters, so that you can cut and paste to make small modifications:
$ ./gujin /dev/hdb1 --disk=ide:hdb
Reprint: gujin /dev/hdb1  \
Reprint:    --geometry=3072384,62496,16,63,512,12594960,0,16,63,0 \
Reprint:    --disk=IDE:lba28,0x1F0,0x3F6,1 --fs=FAT:3072384,64,71,1,2,16,0x80,0xF8 \

 If you are planning to invert the two hard drives master/slave and you want
 to install as if hdb were master, you just cut and paste and modify
 "--disk=IDE:lba28,0x1F0,0x3F6,1" to "--disk=IDE:lba28,0x1F0,0x3F6,0",
 i.e. 0 for master. You could also have typed: "--disk=IDE:lba,ide0,master"
 Another important tip is to use /dev/null as a target, and a partition as
 the source, like:
./gujin /dev/null --geometry=/dev/hdb1 --disk=ide:hdb --verbose
 So then you will see what the installer intend to do, without touching
 your hard drive.
 If you have only one way to boot your PC (one Redmond system for now),
 you may be interested with the "--quickboot" parameter to quickly boot,
 read the ./gujin help.
 The standard default configuration for a new blank disk would be with:
./gujin /dev/hda0 --quickboot=1
 which boot the only O.S. detected without any user action, until the
 user install another operating system or press CapsLock before Gujin loads.

 You will say me soon - What ? using a precious partition only for Gujin ?
 I answer: yes, as long as you did not check the core is correctly working.
 The following is working for me for the last few years - but being the most
 complex (on a technical standpoint, the simplest for standard user), there
 can be a bug in hardware which prevent doing that. I am still waiting
 for someone to tell me about such a possible bug...
 The magic keyword is BEER - unfortunately not as in free BEER, but as in:
 Boot Engineer Extension Record - or more precisely T13/1367D, a standard
 in your local T13/ATA/ATAPI shop.
 Basically, the partition located at the end of the disk is not referenced
 in your partition table - so does not take one slot there. It is
 referenced in [the last/one of the eight last] sectors of the disk and
 the bootloader is hiding this extra partition and the BEER description
 by an ATA/IDE command to report a hard disk of a smaller size, just before
 running the Linux kernel or the partition boot record.
 It is then more difficult to make a hard disk unusable by a small command:
 on current hardware (HD bigger than 4 Mbytes) the partition table can be
 restored even after a "cat /dev/zero > /dev/hda". DO NOT TRY the last command
 if you do not know what it means.
 Sure, you first need to free some space (360 Kbytes to 512 Mbytes, 32 Mbytes
 by default on an empty hard disk) because the installer will never
 erase space taken by other partitions, but it is quite usual to have some
 space there if you used BIOS/DOS based partition managers (they leave
 the last cylinder(s) unused), or you can install Gujin on any new hard disk
 before its first use, or plan some free space at end when partitioning.
 If you want to set up your first IDE hard disk this way, you type:
./gujin /dev/hda0
 Note that adding a zero after a hard disk like /dev/hda would reference
 partition zero when partitions always begin at one - that is my way to name
 the BEER partition. You can also manually:
./gujin /dev/null --verbose --geometry=/dev/hdb1 --disk=ide:hdb \
			--beer-device=/dev/hdb --mbr-device=/dev/hdb
 Note that if you install a BEER description and a BEER partition on a SCSI
 device or a (very) old IDE drive without the HPA feature, this partition at
 end will not be protected so you should take care to not overwrite it next
 time you use a disk partitionner like fdisk.
 Note also that this BEER partition can also contain Linux kernels.

 Take care not to install Gujin twice on the same hard disk, creating two
 partitions at the end of the hard disk because the second install did not
 detect (it cannot know) that the first one has hidden the end of the disk.
 The second install would hide another block at end of the hard disk - but
 this second Gujin would never be run. If you want to upgrade, _cold_ boot
 your PC, select uninstall at the end of the setup menu in Gujin, cold reboot
 your PC again to load the previous bootloader and reinstall Gujin in Linux.

 Note also that, depending on the "keep on reset" feature of the hard drive,
 you may need to power OFF your PC to reboot and not only press the reset
 button, because the hard drive will itself forbid read access to this
 (previously protected) area containing the bootloader!
 A power OFF will always reset the High Protected Area, so you should be safe.

 Remember now to set back permissions on the hard drives as non write-able
 by anybody - before reconnecting to Internet...

If you have a USB pen Hard Drive and you want to boot from it,
you have first to make sure your motherboard BIOS can boot from it.
Remember that "booting from USB" is a simple sentence, but then
the motherboard BIOS need a special driver for each of those:
- USB CDROM with an El-Torito bootable CDROM inserted (USB/ATAPI interface)
- USB floppy drive with a standard bootable 1.44 Mb floppy inserted
- USB real external hard drive (USB/IDE interface)
- USB memory card adapter (compactflash, XD, SD...)
- USB network adapter to do PXE boot
- USB pen Hard Drive.

If you know your motherboard BIOS can boot from your USB pen HD,
and the BIOS is treating such a disk as a hard disk, i.e. BIOS number 0x80,
you can set it up by (this will erase everything on your disk)
(replace /dev/sda by your USB device; check that no partition is mounted):
dd if=/dev/zero of=/dev/sda bs=512 count=64 # blank the head of the disk
./gujin /dev/sda --disk=BIOS:0x80 --mbr-device=/dev/sda
You can also treat it as the native way to install Gujin if you have some
empty space (partition wise) at the end of the USB pen disk:
./gujin /dev/sda0 --disk=BIOS:0x80
Or even install it on a small partition at end:
./gujin /dev/sda4 --quickboot=1 --disk=BIOS:0x80 -w

If your motherboard BIOS is treating this disk as a floppy disk to
boot from, then you need to change the BIOS number - and maybe to
remove the partition table system to have data which looks like a big
floppy (i.e. no --mbr-device= parameter):
./gujin /dev/sda --disk=BIOS:0x00

Note that you may have less problem if your (Dell/Intel) motherboard BIOS
can manage the Extended BIOS (geometry is then no more a problem)
for hard disk, then you type:
dd if=/dev/zero of=/dev/sda bs=512 count=64 # blank the head of the disk
./gujin /dev/sda --disk=EBIOS:0x80 --mbr-device=/dev/sda \
				--partition_index=1
You may have mode chance with --partition_index=4 on some BIOSes,
and/or --single_sector_load.

If you do not know which BIOS disk number to use, just use
"--disk=BIOS:0x00,auto" when you do not use a partition table,
and use "--disk=BIOS:0x80,auto" when you define a partition table,
it works for all BIOSes I have (since gujin-v1.7).
Some (all?) BIOS treat USB partition table differently than hard
disk or floppy, and when you boot a drive prepared with:
./gujin /dev/sda --disk=BIOS:0x80,auto --mbr-device=/dev/sda
then Gujin display "CHECKSUM ERROR", more visible if you use:
./gujin /dev/sda --disk=BIOS:0x80,auto --mbr-device=/dev/sda --read_retry
Then, your BIOS consider the first partition of your USB
drive as a floppy, and so offset all sector number by the
start of the partition. The LBA is 0 for the first sector
of the partition. You should then use (since gujin-v1.7):
./gujin /dev/sda --disk=BIOS:0x80,auto --mbr-device=/dev/sda --read_retry --usb_hdd
If you want to use tinystd.img on a COMPACT FLASH floppy image,
with a COMPACT FLASH to IDE adatpter as /dev/hdd, you would use:
./gujin -t tinystd.bin /dev/hdd --disk=BIOS:0x80,auto --cmdline="" --read_retry
then mount /dev/hdd as vfat and copy your kernel/initrd there.
Tinystd.img does not manage partitions so you cannot use it in /dev/hdd1.

Note that you probably do not want to rewrite (initialise to zero)
the content of the filesystem on a USB pen so do not add the "--full"
parameter, but you can increase verbosity with "-w" if you want.

A quick patch can help you check if the first sector of the USB drive
is ever loaded and executed - you have to have a look at compilation
switch ONLY_PRINT_GEOMETRY in boot.c and recompile, then install
as usual.
This patch just display two lines, the first is the content of the
initial DX register - its lower byte shall be the DISK BIOS number
you are booting from (0x??00 for floppy, 0x??80 for hard drive).
The second line contains value of registers after executing BIOS
interrupt 0x13 / ah=0x08, i.e. asking the caracteristics of the
simulated drive. For instance if you install this patched bootsector
to a floppy, you get:
Initial DX=0x0000
INT13/08: CX=0x4F12 carry=0x0000 AX=0x0000 DX=0x0101 BX=0x0004 DI=0x41E0
and then the PC waits for power off.

The important thing displayed is the 6 lower bits of CX register
(i.e. CX & 0x003F) which is the maximum sector (per track) number,
and the upper byte of DX (i.e. DX & 0xFF00) which is the maximum
head number.
They have to appear at least in the second part of --geometry 
parameter of ./gujin - as the number of sector per track and
number of heads. The sector per track parameter starts at one so
the number is also the maximum, but the number of heads parameter
start as zero so you have to add one to the maximum to get the
total number value to give to ./gujin.
For instance, if you read, while booting this ONLY_PRINT_GEOMETRY
bootsector, that your pen drive is simulated by your motherboard BIOS
using a maximum sector (per track) number of "CX & 0x003F = 0x20 = 32"
and a maximum head number of "(DX & 0xFF00) >> 8 = 0x3F = 63" - so a
total of 64 heads (counting head 0), and trying to install (as root)
displays:
# ./gujin /dev/sda --disk=BIOS:0x80 \
	--cmdline="" --mbr-device=/dev/sda --partition_index=1
Reprint: gujin /dev/sda  \
Reprint:    --cmdline="" \
Reprint:    --geometry=121980,60,2,60,512,122040,0,2,60,512 \
Reprint:    --disk=BIOS:0x80 --fs=FAT:121980,4,9,1,2,16,0x80,0xF8 \
Reprint:    --mbr-device=/dev/sda

Then you cut&paste and replace the end of --geometry by:

# ./gujin /dev/sda --cmdline="" \
	--geometry=121980,60,2,60,512,122040,0,64,32,512 \
	--disk=BIOS:0x80 --fs=FAT:121980,4,9,1,2,16,0x80,0xF8 \
	--mbr-device=/dev/sda
and install by typing "yes".

Remember also that the Gujin installer will not erase a
partition table if it finds the boot sector signature on the first
sector; if you want to create a single partition on your USB pen
drive, treating it like a hard disk, you have to erase yourself the
first sector (and maybe the empty sectors before the first partition)
by (if your USB pen drive is on /dev/sda):
umount /dev/sda*
dd if=/dev/zero of=/dev/sda bs=512 count=1	# MBR only
dd if=/dev/zero of=/dev/sda bs=512 count=256	# empty sectors also


  Have fun, and thanks for all the fish,
  Etienne.




<VERY short version>
If you know what you are doing, have a hard disk with a bit of
free space at end (few Mbytes are usual for Windows based fdisk),
and want to install the Gujin bootloader on the MBR of your primary
hard disk, boot Linux (from POWER OFF) and execute as root:
./gujin /dev/hda0 --full
Answer "yes" to the filesystem creation if no major warnings are
displayed.
This way of installing does create a B.E.E.R. record and a B.E.E.R.
partition that I am used to call with digit 0 following the disk
device: /dev/hdx0 .

If you do not have any free space at the end of your first disk,
that is you have setup your partitions with Linux tools, then you
need to free some space by reducing the last partition (in terms
of disk position) - a kind of 64 Mbytes free at end will be fine.
That can be done (reducing filesystems) by other tools, or just
by backuping the partition content to another filesystem before
reducing the disk partition and restoring its content.
If the last partition was a primary partition, you can proceed
and install Gujin - but if it was an extended partition (i.e. a
partition defined inside a special primary partition called
the extended partition) you also need to reduce the size of the
containning extended partition. I did not find any good tools for
that, so if you boot (from POWER OFF) your PC using Gujin, the
last command in the setup will show you the upper and lower
limit of the extended partition and enable you to change it
to any valid value (check that Gujin setup is not "read-only").
64 Mbytes of disks is approximatively 130000 sectors of 512 bytes.

If you want to uninstall Gujin from the MBR, boot the disk where
is located Gujin, select "uninstall" in its setup screen, and boot a
Linux distribution or windows. You will then be able to modify LILO
or GRUB or FDISK if the version you re-installed (by desintalling
Gujin) is incorrect (for instance re-execute LILO if you have changed
the kernel in /boot since using Gujin). You can also re-install a newer
version of Gujin or increase the size of the BEER partition
(./gujin /dev/hda0 will create a new BEER record and
a new and empty BEER partition over the old one).
This way of un-installing does NOT remove the BEER record nor
the BEER partition, but because Gujin is no more booting the system
those area can be used by the operating system.
Gujin will not lock the HMA nor freeze IDE passwords when booting
Linux if it has just been uninstalled, since version 0.9.

If someone erased your MBR and so your system can no more boot,
put another Gujin bootable floppy disk or CDROM. This new Gujin
will detect that the Hard Drive MBR and its copy are not identical and
propose you to restore the MBR or update the MBR copy (referenced
in the B.E.E.R. record).
The "write enable" option has to be checked in the setup screen, if
it was not enable it manually and type Control-R to reprobe.
Then you can redo a POWER cycle (OFF then ON) with your restored
initial MBR. The same and independant process exists for partition
tables: if someone erased them you will have the choice of restoring,
updating or do nothing next time Gujin boots.

 Note that you may get a error at loading of the first sector of
gujin2, i.e. continous display of the line (with option --read_retry):
Gujin1, gujin2. ERROR!
if you reboot with Ctrl-Alt-Del or by the RESET button because then
the disk may not be reset-ed, and the HMA protected area will not
be reset-ed neither. Just power down completely your PC to reboot.
 The POWER OFF is needed because the IDE interface and the hard
drives are not reset-ed by the reset button of your PC - they cannot
detect that this button has been pressed - but they will detect the
lack of power supply!

</VERY short version>

<legal>
MS Windows and MS-DOS are trademarks of Microsoft.
Linux is a trademark of Linus Torvalds.
</legal>

