1 chain.c32 documentation 2 3Although syslinux is capable of (very simple) native chainloading (through .bss 4and .bs options - see doc/syslinux.txt), it also features a very roboust and 5rich com32 module designed for such purpose. 6 7Chain module can perform few basic tasks: 8 9- load and jump to a sector 10- load and jump to a file (also loading a sector for other purposes) 11- prepare handover data to use by a file / boot sector 12- fix different options in a file / sector / partition entries 13- perform a "service-only" run 14 15It can chainload data from both GPT and DOS partitions, as well as boot the 16first sector from a raw disk. 17 18In more details, the rough overview of code is as follows: 19 201. Parse arguments. 212. Find drive and/or partition to boot from. 223. Perform partition-level patching - for example hiding, unhiding, fixing chs values, etc. 234. Load a file to boot from. 245. Load a sector to boot from, if it doesn't conflict with #5. 256. Prepare handover area, if it doesn't conflict with #5 & #6. 267. Prepare registers. 278. Patch loaded file if necessary. 289. Patch loaded sector if necessary. 2910. Chainload. 30 31In most basic form, syslinux loads specified boot sector (or mbr, if not 32specified) at 0:0x7c00, prepares handover area as a standard mbr would do, and 33jumps to 0:0x7c00. 34 35A "service-only" run is possible when either: 36 37- 'break' is in effect 38 39or 40 41- 'nofile' and 'nomaps' (or 'nosect') are in effect 42 43This is useful for invocations such as: 44 45chain.c32 hdN M setbpb save break 46chain.c32 hdN fixchs break 47chain.c32 hdN unhideall break 48 49Please see respective options for more details. 50 51 52Module invocation: 53 54chain [drive/partition] [options] 55 56In case of repeated arguments, rightmost ones take precedence. 57 58 59 DRIVE / PARTITION SPECIFICATION 60 61Drive can be specified as 'hd#', 'fd#', 'boot', 'mbr', or 'guid'. 62 63- 'mbr' will select a drive by its signature. 64- 'guid' will select a drive by its guid (GPT only). 65- 'boot' is the drive syslinux was booted from. This is the default value, if 66 nothing else is specified. 67- 'hd#' and 'fd#' are standard ways to specify drive number as seen by bios, 68 starting from 0. 69 70Option 'guid' is shared with partition selection (see below). If you happen 71to have non-unique guids, they are searched in disk0, partitions of disk0, 72disk1 ... order. 73 74'mbr' and 'guid' take extra parameter - you should use ':' or '=' as a 75delimiter. 76 77Partition can be specified as '#', 'guid', 'label' or 'fs'. 78 79- 'guid' option will select a partition by a guid (not a type guid !) 80- 'label' will select a partition by a label (searching is done in 81 disk order) 82- 'fs' will select a partition from which syslinux was executed 83- '#' is the standard method. Partitions 1-4 are primary, 5+ logical, 0 = boot 84 MBR (default). 85 86If you use a number to select a partition it should be specified after a drive 87using space or comma as delimiters (after 'hd#', 'fd#', 'mbr', 'guid' or 'boot'). 88 89 90 OPTIONS 91 file=<file> 92 *nofile 93 94It's often convenient to load a file directly and transfer control to it, 95instead of the sector from the disk. Note, that the <file> must reside on 96syslinux partition. 97 98If you choose this option without specifying any addresses explicitly (see 99options 'sect=' and 'seg='), the file will cause sector to not be loaded at all 100(as their memory placement would overlap). 101 102 seg=<segment>:<offset>:<ip> 103 *seg=0:0x7c00:0x7c00 104 105This triplet lets you alter the addresses a file will use. It's loaded at 106<segment:offset>, the entry point is at <segment:ip>. When you chainload some 107other bootloader or kernel, it's almost always mandatory. 108 109The defaults, if option is not specified, are 0:0x7c00:0x7c00 110If any of the fields are omitted (e.g. 0x2000::), they default to 0. 111 112 sect=<segment>:<offset>:<ip> 113 *sect=0:0x7c00:0x7c00 114 nosect 115 nosect sets: nomaps 116 117This triplet lets you alter the addresses a sector will use. It's loaded at 118<segment:offset>, the entry point is at <segment:ip>. This option is mostly 119used in tandem with 'file=' and 'seg=' options, as some loaders/kernels will 120expect relocated sector at some particular address (e.g. DRKM). 121 122'nosect' will cause sector to not be loaded at all. In plenty cases, when a file 123is being chainloaded, sector is not necessary. 124 125The defaults if option is not specified, are 0:0x7c00:0x7c00. 126If some of the fields are omitted (e.g. 0x2000::), they default to 0. 127 128 *maps 129 nomaps 130 131In some cases, it's useful to fix BPB values in NTFS/FATxx bootsectors and 132evntually write them back, but otherwise boot sector itself is not necessary to 133continue booting. 'nomaps' allows that - a sector will be loaded, but won't be 134mmapped into real memory. Any overlap tests (vs. handover or file areas) are 135not performed, being meaningless in such case. 136 137 setbpb 138 *nosetbpb 139 140Microsoft side of the world is paritculary sensitive to certain BPB values. 141Depending on the system and chainloading method (sector or file), some or all 142of those fields must match reality - and after e.g. drive clonning or 143when using usb stick in different computers - that is often not the case. 144 145The "reality" means: 146 147"hidden sectors" - valid offset of the partition from the beginning of the disk 148"geometry" - valid disk geometry as reported by BIOS 149"drive" - valid drive number 150 151This option will automatically determine the type of BPB and fix what is possible 152to fix, relatively to detected BPB. If it's impossible to detect BPB, function 153will do nothing. 154 155 filebpb 156 *nofilebpb 157 158Chainloaded file can simply be an image of a sector. In such case, it could be 159useful to also fix its BPB values. 160 161 save 162 *nosave 163 save sets: strict=2 164 165Fixing BPB values only in memory might not be enough. This option allows 166writing of the corrected sector. You will probably want to use this option 167together with 'setbpb'. 168 169- this option never applies to a loaded file 170- chain module will not save anything to disk by default (besides options such 171 as hide or fixchs - so options related directly to partition entries) 172- writing is only performed, if the values actually changed 173 174 *hand 175 nohand 176 177By default, a handover area is always prepared if possible - meaning it doesn't 178overlap with other areas. It's often not necessary though - usually, a 179chainloaded file or kernel don't care about it anymore, so a user can disable 180it explicitly with this option. 181 182 hptr 183 *nohptr 184 185In case when both file and sector are loaded, ds:si and ds:bp will point to 186sector address before the chainloading. This option lets user force those 187registers to point to handover area. This is useful when both the file and the 188sector are actually a sector's image and the sector is mmapped. 189 190 swap 191 *noswap 192 193This option will install a tiny stub code used to swap drive numbers, if the 194drive we use during chainloading is not fd0 or hd0. 195 196 hide[all] 197 unhide[all] 198 *nohide 199 [un]hide[all] sets: strict=2 200 201In certain situations it's useful to hide partitions - for example to make sure 202DOS gets C:. 'hide' will hide hidable primary partitions, except the one we're 203booting from. Similary, 'hideall' will hide all hidable partitions, except the 204one we're booting from. Hiding is performed only on the selected drive. Options 205starting with 'un' will simply unhide every partition (primary ones or all). 206Writing is only performed, if the os type values actually changed. 207 208 fixchs 209 *nofixchs 210 fixchs sets: strict=2 211 212If you want to make a drive you're booting from totally compatible with current 213BIOS, you can use this to fix all partitions' CHS numbers. Good to silence e.g. 214FreeDOS complainig about 'logical CHS differs from physical' of sfdisk about 215'found (...) expected (...). Functionally seems to be mostly cosmetic, as 216Microsoft world - in cases it cares about geometry - generally sticks to values 217written in bootsectors. And the rest of the world generally doesn't care about 218them at all. Writing is only performed, if the values actually got changed. 219 220 keepexe 221 *nokeepexe 222 223If you're booting over a network using pxelinux - this lets you keep UNDI 224stacks in memory (pxelinux only). 225 226 warn 227 *nowarn 228 229This option will wait for a keypress right before continuing the chainloading. 230Useful to see warnings emited by the chain module. 231 232 prefmbr 233 *noprefmbr 234 235In the case of presence of non-standard hybrid MBR/GPT layout, this flag makes 236chain module prefer MBR layout over GPT. 237 238 strict[=<0|1|2>] 239 *strict=1 240 relax 241 242Those options control the level of sanity checks used during the traversal of 243partition table(s). This is useful in buggy corner cases, when the disk size is 244reported differently across different computers or virtual machines (if it 245happens at all, the size usually differs by 1 sector). Normally the partition 246iterator would report an error and abort in such case. Another case scenario is 247disk corruption in some later EMBR partition. 248 249- strict=0 inhibits any checks 250- strict=1 enables checks, but ignores those that involve disk size 251- strict=2 enables all checks 252- relax and nostrict are equivalent to strict=0 253- norelax and strict are equivalent to strict=2 254 255 256 break 257 *nobreak 258 break sets: nofile nomaps nohand 259 260It is possible to trigger a "service-only" run - The chain module will do 261everything requested as usual, but it will not perform the actual chainloading. 262'break' option disables handover, file loading and sector mapping, as these 263are pointless in such scenario (although file might be reenabled in some future 264version, if writing to actual files becomes possible). Mainly useful for 265options 'fixchs', '[un]hide[all]' and setbpb. 266 267 isolinux=<file> 268 sets: file=<file> nohand nosect isolinux 269 270Chainload another version/build of the ISOLINUX bootloader and patch the loader 271with appropriate parameters in memory. This avoids the need for the 272-eltorito-alt-boot parameter of mkisofs, when you want more than one ISOLINUX 273per CD/DVD. 274 275 ntldr=<file> 276 sets: file=<file> seg=0x2000 setbpb nohand 277 278Prepares to load ntldr directly. You might want to add 'save' option to store 279corrected BPB values. 280 281 cmldr=<file> 282 sets: file=<file> seg=0x2000 setbpb nohand cmldr 283 284Prepares to load recovery console directly. In-memory copy of bootsector is 285patched with "cmdcons\0". Remarks the same as in 'ntldr='. 286 287 reactos=<file> 288 sets: file=<file> seg=0:0x8000:0x8100 setbpb nohand 289 290Prepares to load ReactOS's freeldr directly. You might want to add 'save' 291option to store corrected BPB values. 292 293 freedos=<file> 294 sets: file=<file> seg=0x60 sect=0x1FE0 setbpb nohand 295 296Prepares to load freedos kernel directly. You will likely want to add 'save' 297option, as those kernels seem to require proper geometry written back to disk. 298Sector address is chosen based on where freedos' bootsectors relocate themselves, 299although it seems the kernel doesn't rely on it. 300 301You might also want to employ 'hide' option, if you have problems with properly 302assigned C: drive. 303 304 pcdos=<file> 305 msdos=<file> 306 sets: file=<file> seg=0x70 sect=0x8000 setbpb nohand 307 308Similary to 'freedos=', This prepares to load MSDOS 2.00 - 6.xx or derivatives. 309Sector address is chosen arbitrarily. Otherwise comments as above. 310 311 msdos7=<file> 312 sets: file=<file> seg=0x70::0x200 sect=0x8000 setbpb nohand 313 314Only for MSDOS 7+ versions (98se ~ 7.xx, Me ~ 8.xx). Comments as above. 315TODO/TEST 316 317 drmk=<file> 318 sets: file=<file> seg=0x70 sect=0x2000:0:0 setbpb nohand 319 320This is used for loading of *only* Dell's DOS derivatives. It does require boot 321sector at 0x2000 and overall valid BPB values. As in other DOS-ish cases, 322likely candidates for use are 'save' and 'hide'. 323 324 grub=<file> [grubcfg=<config>] 325 sets: file=<file> seg=0x800::0x200 nohand nosect grub 326 327Chainloads grub legacy's stage2, performing additional corrections on the file 328in memory. Additionally, alternate config file can be specified through 329'grubcfg=' option 330 331 grldr=<file> 332 sets: file=<file> nohand nosect grldr 333 334Chainloads GRUB4DOS grldr, performing additional corrections on the file 335in memory. 336 337 bss=<file> 338 sets: file=<file> nomaps setbpb bss 339 340This emulates syslinux's native BSS option. This loads both the file and the 341sector, adjusts BPB values in the loaded sector, then copies all possible BPB 342fields to the loaded file. Everything is made with reference to the selected 343disk/partition. 344 345 bs=<file> 346 sets: file=<file> nosect filebpb 347 348This emulates syslinux's native BS option. This loads the file and if possible 349- adjusts its BPB values. Everything is made with reference to the selected 350disk/partition. 351 352