2012年2月20日 星期一

SysLinux


Syslinux Project 包含 lightweight bootloaders 
1. MS-DOS FAT filesystems (SYSLINUX), 
2. network booting (PXELINUX), 
3. bootable "El Torito" CD-ROMs (ISOLINUX), 
4. Linux ext2/ext3/ext4 or btrfs filesystems (EXTLINUX). 
5. The project also includes MEMDISK, a tool to boot legacy operating systems (such as DOS) from nontraditional media; it is usually used in conjunction with PXELINUX and ISOLINUX.


SYSLINUX searches for the SYSLINUX.CFG file in the following order:
/boot/syslinux/syslinux.cfg
/syslinux/syslinux.cfg
/syslinux.cfg

All filenames inside the config file are assumed to be relative to the directory SYSLINUX.CFG is in, unless preceded with a slash or backslash.
syslinux.cfg 是 text file in UNIX or DOS format.
 Keywords 是 case insensitive. 

--------------------------------------------------------
SysLinux 是一個 Linux based 的 boot loader,可以在 FAT16 中使用,USB大部分使用 FAT16

1.需在 MBR 中寫入 SysLinx 與 ldlinux.sys
2.在 USB 中 copy 進去
    a. vmlinuz -> kernel
    b. initrd.img
    c. syslinux.cfg (sysLinux 的設定檔)
    若想為這些改名,注意 sysLinux 只支援 8.3 的檔名


3.  syslinux.cfg 設定檔案應該含有下列兩行:
    default vmlinuz
    append initrd=initrd.gz ramdisk_size=12000 root=/dev/rd/0 init=/linuxrc rw
    請注意,根據開機的映像大小,在必要的時候,您可能需要增大 ramdisk_size 參數的數值。
    如果開機失敗,您可以嘗試添加 devfs=mount,dall 到 "append" 那一行。

4. 添加 ISO 映像
現在您需要把任意一個 Linux ISO 映像放入您的 USB 隨身碟內 。這樣的一個映像檔的副檔名必須是 .iso

------------------------------------------------------------------

SYSLINUX uses the syntax:
LABEL mylabel
  KERNEL mykernel
  APPEND myoptions
All options here apply to PXELINUX, ISOLINUX and EXTLINUX as well as SYSLINUX unless otherwise noted.

syslinux.cfg example:

DEFAULT linux
LABEL linux
  SAY Now booting the kernel from SYSLINUX...
  KERNEL vmlinuz.img
  APPEND ro root=/dev/sda1 initrd=initrd.img



INCLUDE filename


LABEL command: The default LABEL is "linux", but you can change this with the "DEFAULT" keyword.


KERNEL file: File SYSLINUX will boot. The "kernel" doesn't have to be a Linux kernel, it can be a boot sector or a COMBOOT file.

 none or other Linux kernel image
 .0  PXE bootstrap program (NBP) [PXELINUX only]
 .bin  "CD boot sector" [ISOLINUX only]
 .bs  Boot sector [SYSLINUX only]
 .bss  Boot sector, DOS superblock will be patched in [SYSLINUX only]
 .c32  COM32 image (32-bit COMBOOT)
 .cbt  COMBOOT image (not runnable from DOS)
 .com  COMBOOT image (runnable from DOS)
 .img  Disk image [ISOLINUX only]

LINUX image

You can use this, instead of using KERNEL file to boot a linux kernel image.

BOOT image

Bootstrap program (.bs, .bin)

BSS image

BSS image (.bss)

PXE image

PXE Network Bootstrap Program (.0)

FDIMAGE image

Floppy disk image (.img)

COMBOOT image

COMBOOT program (.com, .cbt)

COM32 image

COM32 program (.c32)

CONFIG file

CONFIG will restart the boot loader using a different configuration file.
Load new config file:
LABEL new_config
CONFIG /
Set Syslinux' home dir to and load new config file:
LABEL new_config2
CONFIG / 


APPEND options...

Adds one or more options to the kernel command line. These are added to both automatic and manual boots. The options are added at the very beginning of the kernel command line, usually permitting explicitly entered kernel options to override them. This is the equivalent of the LILO "append" option.
If you enter multiple APPEND statements in a single menu entry, only the last one will be used.

[edit]APPEND -

Append nothing. APPEND with a single hyphen as argument in a LABEL section can be used to override a global APPEND.

IPAPPEND flag_val [PXELINUX only]

The flag_val is an OR of the following options:
1: indicates that an option of the following format should be generated and added to the kernel command line:
ip=:::
... based on the input from the DHCP/BOOTP or PXE boot server.
The use of this option is not recommended. If you have to use it, it is probably an indication that your network configuration is broken. Using just ip=dhcp on the kernel command line is a preferrable option, or, better yet, run dhcpcd/dhclient, from an initrd if necessary.
2: indicates that an option of the following format should be generated and added to the kernel command line:
BOOTIF=
... in dash-separated hexadecimal with leading hardware type (same as for the configuration file; see PXELINUX documentation).
This allows an initrd program to determine which interface the system booted from.
LABEL label 
KERNEL image
  APPEND options...
  IPAPPEND flag_val [PXELINUX only] 
... indicates that if "label" is entered as the kernel to boot, SYSLINUX should instead boot "image", and the specified APPEND and IPAPPEND options should be used instead of the ones specified in the global section of the file (before the first LABEL command.) The default for "image" is the same as "label", and if no APPEND is given the default is to use the global entry (if any). Up to 128 LABEL entries are permitted. (for ISOLINUX, 64 LABEL entries.)

LOCALBOOT type [ISOLINUX, PXELINUX]

With PXELINUX, specifying "LOCALBOOT 0" instead of a "KERNEL" option means invoking this particular label will cause a local disk boot instead of booting a kernel.
  1. The argument 0 means perform a normal boot. 
  2. The argument 4 will perform a local boot with the Universal Network Driver Interface (UNDI) driver still resident in memory. 
  3. the argument 5 will perform a local boot with the entire PXE stack, including the UNDI driver, still resident in memory. 
  4. All other values are undefined. 
  • If you don't know what the UNDI or PXE stacks are, don't worry, you don't want them, just specify 0.

With ISOLINUX, the "type" specifies the local drive number to boot from; 
  • 0x00 is the primary floppy drive and 
  • 0x80 is the primary hard drive. 
  • The special value -1 causes ISOLINUX to report failure to the BIOS, which, on recent BIOSes, should mean that the next device in the boot sequence should be activated.

INITRD initrd_file

Starting with version 3.71, an initrd can be specified in a separate statement (INITRD) instead of as part of the APPEND statement. 
This functionally appends "initrd=initrd_file" to the kernel command line.
It supports multiple filenames separated by commas. This is mostly useful for initramfs, which can be composed of multiple separate cpio or cpio.gz archives
Note: all files except the last one are zero-padded to a 4K page boundary. This should not affect initramfs.

DEFAULT command

Sets the default command line. If SYSLINUX boots automatically, it will act as if the entries after DEFAULT had been typed in at the "boot:" prompt, except that the option "auto" is automatically added, indicating an automatic boot.
If no configuration file is present, or no DEFAULT entry is present in the config file, the default kernel name is "linux", with no options.

[edit]UI module options...

Selects a specific user interface module (typically menu.c32 or vesamenu.c32). The command-line interface treats this as a directive that overrides the DEFAULT and PROMPT directives.

[edit]PROMPT flag_val

If flag_val is 0, display the boot: prompt only if the Shift or Alt key is pressed, or Caps Lock or Scroll lock is set (this is the default). If flag_val is 1, always display the boot: prompt.

[edit]NOESCAPE flag_val

If flag_val is set to 1, ignore the Shift/Alt/Caps Lock/Scroll Lock escapes. Use this (together with PROMPT 0) to force the default boot selection.

[edit]NOCOMPLETE flag_val

If flag_val is set to 1, the Tab key does not display labels at the boot: prompt.

[edit]IMPLICIT flag_val

If flag_val is 0, do not load a kernel image unless it has been explicitly named in a LABEL statement. The default is 1.

ALLOWOPTIONS flag_val

If flag_val is 0, the user is not allowed to specify any arguments on the kernel command line. The only options recognized are those specified in an APPEND statement. The default is 1.

[edit]TIMEOUT timeout

Indicates how long to pause at the boot: prompt until booting automatically, in units of 1/10 s. The timeout is cancelled when any key is pressed, the assumption being the user will complete the command line. A timeout of zero will disable the timeout completely. The default is 0.
NOTE: The maximum possible timeout value is 35996. (Just under an hour.)

[edit]TOTALTIMEOUT timeout

Indicates how long to wait until booting automatically, in units of 1/10 s. This timeout is *not* cancelled by user input, and can thus be used to deal with serial port glitches or "the user walked away" type situations. A timeout of zero will disable the timeout completely. The default is 0.
Both TIMEOUT and TOTALTIMEOUT can be used together, for example:
# Wait 5 seconds unless the user types something, but
# always boot after 15 minutes.
TIMEOUT 50
TOTALTIMEOUT 9000

[edit]ONTIMEOUT kernel options...

Sets the command line invoked on a timeout. Normally this is the same thing invoked by DEFAULT. If this is specified, then DEFAULT is used only if the user presses to boot.

[edit]ONERROR kernel options...

If a kernel image is not found (either it doesn't exist, or IMPLICIT is set), run the specified command. The faulty command line is appended to the specified options, so if the ONERROR directive reads:
ONERROR xyzzy plugh 
... and the command line entered by the user is:
foo bar baz 
... SYSLINUX will execute the following as if it were entered by the user:
xyzzy plugh foo bar baz

SERIAL port [[baudrate] flowcontrol]

Enables a serial port to act as the console. "port" is a number (0 = /dev/ttyS0 = COM1, etc.) or an I/O port address (e.g. 0x3F8). If "baudrate" is omitted, the baud rate defaults to 9600 bps. The serial parameters are hardcoded to 8 bits, no parity and 1 stop bit.
"flowcontrol" is a combination of the following bits:
0x001 - Assert DTR
0x002 - Assert RTS
0x010 - Wait for CTS assertion
0x020 - Wait for DSR assertion
0x040 - Wait for RI assertion
0x080 - Wait for DCD assertion
0x100 - Ignore input unless CTS asserted
0x200 - Ignore input unless DSR asserted
0x400 - Ignore input unless RI asserted
0x800 - Ignore input unless DCD asserted
All other bits are reserved.
Typical values are:
    0 - No flow control (default)
0x303 - Null modem cable detect
0x013 - RTS/CTS flow control
0x813 - RTS/CTS flow control, modem input
0x023 - DTR/DSR flow control
0x083 - DTR/DCD flow control
For the SERIAL directive to work properly, it must be the first directive in the configuration file.
NOTE: "port" values from 0 to 3 mean the first four serial ports detected by the BIOS. They may or may not correspond to the legacy port values 0x3F8, 0x2F8, 0x3E8, 0x2E8.

[edit]CONSOLE flag_val

If flag_val is 0, disable output to the normal video console. If flag_val is 1, enable output to the video console (this is the default.) Some BIOSes try to forward this to the serial console which can make a total mess of things, so this option lets you disable the video console on these systems.

[edit]FONT filename

Load a font in .psf format before displaying any output (except the copyright line, which is output as ldlinux.sys itself is loaded.) SYSLINUX only loads the font onto the video card. If the .psf file contains a Unicode table, it is ignored. This only works on EGA and VGA cards. Hopefully, it does nothing on others.

[edit]KBDMAP keymap

Install a simple keyboard map. The keyboard remapper used is very simplistic (it simply remaps the keycodes received from the BIOS, which means that only the key combinations relevant in the default layout -- usually U.S. English -- can be mapped) but should at least help people with QWERTZ or AZERTY keyboard layouts and the locations of = and , (two special characters used heavily on the Linux kernel command line.)
The included program keytab-lilo.pl from the LILO distribution can be used to create such keymaps. The file keytab-lilo.doc contains the documentation for this program.
Syslinux also ships a comboot module named kbdmap.c32 which allows changing the keyboard mapping on the fly, making it possible to add a keyboard-selection menu and/or keyboard-selection labels from within the syslinux config file.

[edit]SAY message

Prints the message on the screen.

[edit]DISPLAY filename

Displays the indicated file on the screen at boot time (before the boot: prompt, if displayed). Please see the section below on DISPLAY files.
NOTE: If the file is missing, this option is ignored. 

[edit]F[1-12] filename

F1 filename
F2 filename
  ...etc...
F9 filename
F10 filename
F11 filename
F12 filename 
Displays the indicated file on the screen when a function key is pressed at the boot: prompt. This can be used to implement pre-boot online help (presumably for the kernel command line options).
Please see the section below on DISPLAY files.
When using the serial console, press  to get to the help screens:
<1>   to get the F1 screen
<2>   to get the F2 screen
   ...etc...
<9>   to get the F9 screen
 (or <0>) to get the F10 screen
   to get the F11 screen
   to get the F11 screen
   to get the F12 screen

[edit]Is There A Way To Define Constants Or Variables?

At present, there is no way to define constants or variables in the configuration file. That feature will be added eventually.

Can SYSLINUX Handle Large Kernels?

SYSLINUX supports large kernels (bzImage format), eliminating the 500K size limit of the zImage kernel format. bzImage format kernels are detected automatically and handled transparently to the user.
SYSLINUX also supports a boot-time-loaded ramdisk (initrd). An initrd is loaded from a DOS file if the option "initrd=filename" (where filename is the filename of the initrd image; the file must be located in the root directory on the boot floppy) is present on the processed command line (after APPEND's have been added, etc.). If several initrd options are present, the last one has precedence; this permits user-entered options to override a config file APPEND. Specifying "initrd=" without a filename inhibits initrd loading. The file specified by the initrd= option will typically be a gzipped filesystem image.
EXAMPLE (extlinux):
 APPEND ro root=/dev/hda1 initrd=/boot/initrd.img
NOTE: One of the main advantages of SYSLINUX is that it makes it very easy to support users with new or unexpected configurations, especially in a distribution setting. If initrd is used to extensively modularize the distribution kernel, it is strongly recommended that a simple way of adding drivers to the boot floppy be provided. The suggested manner is to let the initrd system mount the boot floppy and look for additional drivers in a predetermined location.
To bzImage and recent zImage kernels, SYSLINUX 1.30 and higher will identify using the ID byte 0x31. PXELINUX identifies using the ID byte 0x32, ISOLINUX 0x33, and EXTLINUX 0x34. The ID range 0x35-0x3f is reserved for future versions of derivatives of SYSLINUX.

[edit]What is the DISPLAY File Format?

DISPLAY and function-key help files are text files in either DOS or UNIX format (with or without ). In addition, the following special codes are interpreted:

[edit]Clear the screen, home the cursor:

   =  = ASCII 12
Note that the screen is filled with the current display color.
Set the display colors to the specified background and foreground colors:
   =  = ASCII 15
where and are hex digits, corresponding to the standard PC display attributes:
0 = black               8 = dark grey
1 = dark blue           9 = bright blue
2 = dark green          a = bright green
3 = dark cyan           b = bright cyan
4 = dark red            c = bright red
5 = dark purple         d = bright purple
6 = brown               e = yellow
7 = light grey          f = white
Picking a bright color (8-f) for the background results in the corresponding dark color (0-7), with the foreground flashing.
Colors are not visible over the serial console.
Example: color.txt file:
^O9eBlinking Yellow on Blue Background
# xxd color.txt
0000000: 0f39 6542 6c69 6e6b 696e 6720 5965 6c6c  .9eBlinking Yell
0000010: 6f77 206f 6e20 426c 7565 2042 6163 6b67  ow on Blue Backg
0000020: 726f 756e 640a                           round.

[edit]Display graphic from filename:

filename   =  = ASCII 24
If a VGA display is present, enter graphics mode and display the graphic included in the specified file. The file format is an ad hoc format called LSS16; the included Perl program "ppmtolss16" can be used to produce these images. This Perl program also includes the file format specification.
The image is displayed in 640x480 16-color mode. Once in graphics mode, the display attributes (set by code sequences) work slightly differently: the background color is ignored, and the foreground colors are the 16 colors specified in the image file. For that reason, ppmtolss16 allows you to specify that certain colors should be assigned to specific color indices.
Color indices 0 and 7, in particular, should be chosen with care: 0 is the background color, and 7 is the color used for the text printed by SYSLINUX itself.

[edit]Return to text mode:

   =  = ASCII 25
If we are currently in graphics mode, return to text mode. Select to which modes to print a certain part of the message:
..  .. = ASCII 16-23
These codes can be used to select which modes to print a certain part of the message file in. Each of these control characters select a specific set of modes (text screen, graphics screen, serial port) for which the output is actually displayed:
Character                       Text    Graph   Serial
------------------------------------------------------
 =  = ASCII 16     No      No      No
 =  = ASCII 17     Yes     No      No
 =  = ASCII 18     No      Yes     No
 =  = ASCII 19     Yes     Yes     No
 =  = ASCII 20     No      No      Yes
 =  = ASCII 21     Yes     No      Yes
 =  = ASCII 22     No      Yes     Yes
 =  = ASCII 23     Yes     Yes     Yes
For example:
Text modeGraphics modeSerial port
will actually print out which mode the console is in!

[edit]End of file:

   =  = ASCII 26
End of file (DOS convention).

[edit]Beep:

   =  = ASCII 7
Beep the speaker.

[edit]Write DISPLAY file with IsoLinux Mate

IsoLinux Mate (ILM) is a Windows 32-bit executable that makes it easier to write a DISPLAY file.
With ILM you can insert color commands, insert ASCII graphics with "not a real on-screen keyboard", preview your work, ..





沒有留言: