Difference between revisions of "Comboot/chain.c32"

From Syslinux Wiki
Jump to: navigation, search
Line 1: Line 1:
 
[[Category:Release Documentation]]
 
[[Category:Release Documentation]]
 
[[Category:Comboot]]
 
[[Category:Comboot]]
( Included in syslinux 3.71 )
+
'''chain.c32''' is a COM32 module for Syslinux. It can chainload MBRs, partition boot sectors, Windows bootloaders (ntldr, setupldr.bin and bootmgr), MS-DOS and PC-DOS io.sys, Freedos kernel.sys, isolinux.bin (only from ISOLINUX), grldr of grub4dos or a bootsector saved to a file. It can also swap BIOS drive numbers or hide partitions.
  
(from chain.c comment)
+
All options as available in chain.c32 of Syslinux 3.85:
 +
<pre>
 +
Usage:  chain.c32 hd<disk#> [<partition>] [options]
 +
        chain.c32 fd<disk#> [options]
 +
        chain.c32 mbr:<id> [<partition>] [options]
 +
        chain.c32 boot [<partition>] [options]
  
 +
Options: file=<loader>      load file, instead of boot sector
 +
        isolinux=<loader>  load another version of ISOLINUX
 +
        ntldr=<loader>    load Windows NTLDR, SETUPLDR.BIN or BOOTMGR
 +
        cmldr=<loader>    load Recovery Console of Windows NT/2K/XP
 +
        freedos=<loader>  load FreeDOS kernel.sys
 +
        msdos=<loader>    load MS-DOS io.sys
 +
        pcdos=<loader>    load PC-DOS ibmbio.com
 +
        seg=<segment>      jump to <seg>:0000 instead of 0000:7C00
 +
        swap              swap drive numbers, if bootdisk is not fd0/hd0
 +
        hide              hide primary partitions, except selected partition
 +
        sethidden          set the FAT/NTFS hidden sectors field
 +
</pre>
  
Chainload a hard disk (currently rather braindead.)
+
 
 +
== Numbering of Drives and Partitions ==
 +
 
 +
 
 +
=== Drive numbering ===
 +
 
 +
Hard drive numbering starts at 0:
 +
* <tt>'''hd0'''</tt> : first hard drive (as seen by the BIOS)
 +
* <tt>'''hd1'''</tt> : second hard drive
 +
* <tt>'''hd2'''</tt> : third hard drive
 +
* ...
 +
 
 +
Floppy drive numbering starts at 0:
 +
* <tt>'''fd0'''</tt> : first floppy drive
 +
* <tt>'''fd1'''</tt> : second floppy drive
 +
 
 +
The drive from which Syslinux is booted can be referred too with the parameter:
 +
<tt>'''boot'''</tt>
 +
 
 +
 
 +
=== Partition numbering ===
 +
 
 +
Partition numbers (short):
 +
* 1-4 : primary partitions
 +
* 5 and higher : logical partitions
 +
* 0 : MBR (default.)
 +
 
 +
Partition numbers (long):
 +
* <tt>'''0'''</tt> : '''MBR''' (default)
 +
* <tt>'''1'''</tt> : first '''primary''' partition
 +
* <tt>'''2'''</tt> : second primary partition
 +
* <tt>'''3'''</tt> : third primary partition
 +
* <tt>'''4'''</tt> : fourth primary partition
 +
* <tt>'''5'''</tt> : first '''logical''' partition
 +
* <tt>'''6'''</tt> : second logical partition
 +
* <tt>'''7'''</tt> : third logical partition
 +
* <tt>'''8'''</tt> : fourth logical partition
 +
* <tt>'''9'''</tt> : fifth logical partition
 +
* <tt>'''10'''</tt> : sixth logical partition
 +
* <tt>'''11'''</tt> : seventh logical partition
 +
* <tt>'''12'''</tt> : eighths logical partition
 +
* ...
 +
 
 +
=== Examples ===
  
 
<pre>
 
<pre>
Usage: chain hd<disk#> [<partition>] [options]
+
UI menu.c32
      chain fd<disk#> [options]
+
 
      chain mbr:<id> [<partition>] [options]
+
LABEL boot_hd0
      chain boot [<partition>] [options]
+
MENU LABEL Boot from first hard drive
 +
COM32 chain.c32
 +
APPEND hd0
 +
 
 +
LABEL boot_hd1
 +
MENU LABEL Boot from second hard drive
 +
COM32 chain.c32
 +
APPEND hd1
 +
 
 +
LABEL boot_fd0
 +
MENU LABEL Boot from first floppy drive
 +
COM32 chain.c32
 +
APPEND fd0
 +
 
 +
LABEL boot_syslinux_drive
 +
MENU LABEL Boot the drive from which Syslinux is booted (hard drive or floppy drive)
 +
COM32 chain.c32
 +
APPEND boot
 +
 
 +
LABEL boot_hd2_2
 +
MENU LABEL Boot second primary partition from thirth hard drive
 +
COM32 chain.c32
 +
APPEND hd2 2
 +
 
 +
LABEL boot_hd1_5
 +
MENU LABEL Boot first logical partition from second hard drive
 +
COM32 chain.c32
 +
APPEND hd1 5
 +
 
 +
LABEL boot_hd3_0
 +
MENU LABEL Boot MBR of fourth hard drive (same as "APPEND hd3")
 +
COM32 chain.c32
 +
APPEND hd3 0
 
</pre>
 
</pre>
... e.g. "chain hd0 1" will boot the first partition on the first hard disk.
+
 
 
   
 
   
 
   
 
   
 
The mbr: syntax means search all the hard disks until one with a specific MBR serial number (bytes 440-443) is found.
 
The mbr: syntax means search all the hard disks until one with a specific MBR serial number (bytes 440-443) is found.
 
   
 
   
Partitions 1-4 are primary, 5+ logical, 0 = boot MBR (default.)
+
 
 
   
 
   
 
Options:
 
Options:

Revision as of 23:55, 14 February 2010

chain.c32 is a COM32 module for Syslinux. It can chainload MBRs, partition boot sectors, Windows bootloaders (ntldr, setupldr.bin and bootmgr), MS-DOS and PC-DOS io.sys, Freedos kernel.sys, isolinux.bin (only from ISOLINUX), grldr of grub4dos or a bootsector saved to a file. It can also swap BIOS drive numbers or hide partitions.

All options as available in chain.c32 of Syslinux 3.85:

Usage:   chain.c32 hd<disk#> [<partition>] [options]
         chain.c32 fd<disk#> [options]
         chain.c32 mbr:<id> [<partition>] [options]
         chain.c32 boot [<partition>] [options]

Options: file=<loader>      load file, instead of boot sector
         isolinux=<loader>  load another version of ISOLINUX
         ntldr=<loader>     load Windows NTLDR, SETUPLDR.BIN or BOOTMGR
         cmldr=<loader>     load Recovery Console of Windows NT/2K/XP
         freedos=<loader>   load FreeDOS kernel.sys
         msdos=<loader>     load MS-DOS io.sys
         pcdos=<loader>     load PC-DOS ibmbio.com
         seg=<segment>      jump to <seg>:0000 instead of 0000:7C00
         swap               swap drive numbers, if bootdisk is not fd0/hd0
         hide               hide primary partitions, except selected partition
         sethidden          set the FAT/NTFS hidden sectors field


Numbering of Drives and Partitions

Drive numbering

Hard drive numbering starts at 0:

  • hd0 : first hard drive (as seen by the BIOS)
  • hd1 : second hard drive
  • hd2 : third hard drive
  • ...

Floppy drive numbering starts at 0:

  • fd0 : first floppy drive
  • fd1 : second floppy drive

The drive from which Syslinux is booted can be referred too with the parameter: boot


Partition numbering

Partition numbers (short):

  • 1-4 : primary partitions
  • 5 and higher : logical partitions
  • 0 : MBR (default.)

Partition numbers (long):

  • 0 : MBR (default)
  • 1 : first primary partition
  • 2 : second primary partition
  • 3 : third primary partition
  • 4 : fourth primary partition
  • 5 : first logical partition
  • 6 : second logical partition
  • 7 : third logical partition
  • 8 : fourth logical partition
  • 9 : fifth logical partition
  • 10 : sixth logical partition
  • 11 : seventh logical partition
  • 12 : eighths logical partition
  • ...

Examples

 UI menu.c32

 LABEL boot_hd0
 MENU LABEL Boot from first hard drive
 COM32 chain.c32
 APPEND hd0

 LABEL boot_hd1
 MENU LABEL Boot from second hard drive
 COM32 chain.c32
 APPEND hd1

 LABEL boot_fd0
 MENU LABEL Boot from first floppy drive
 COM32 chain.c32
 APPEND fd0

 LABEL boot_syslinux_drive
 MENU LABEL Boot the drive from which Syslinux is booted (hard drive or floppy drive)
 COM32 chain.c32
 APPEND boot

 LABEL boot_hd2_2
 MENU LABEL Boot second primary partition from thirth hard drive
 COM32 chain.c32
 APPEND hd2 2

 LABEL boot_hd1_5
 MENU LABEL Boot first logical partition from second hard drive
 COM32 chain.c32
 APPEND hd1 5

 LABEL boot_hd3_0
 MENU LABEL Boot MBR of fourth hard drive (same as "APPEND hd3")
 COM32 chain.c32
 APPEND hd3 0


The mbr: syntax means search all the hard disks until one with a specific MBR serial number (bytes 440-443) is found.


Options:

  • file=<loader>: loads the file <loader> **from the SYSLINUX filesystem** instead of loading the boot sector.
  • seg=<segment>: loads at and jumps to <seg>:0000 instead of 0000:7C00.
  • ntldr=<loader>: equivalent to -seg 0x2000 -file <loader>, used with WinNT's loaders
  • freedos=<loader>: equivalent to -seg 0x60 -file <loader>, used with FreeDOS kernel.sys.
  • msdos=<loader>:
  • pcdos=<loader>: equivalent to -seg 0x70 -file <loader>, used with DOS io.sys.
  • swap: if the disk is not fd0/hd0, install a BIOS stub which swaps the drive numbers.
  • hide: change type of primary partitions with IDs 01, 04, 06, 07, 0b, 0c, or 0e to 1x, except for the selected partition, which is converted the other way.