Difference between revisions of "Cmd.c32"
(Introduction and usage examples of cmd.c32.) |
m (Wiki formatting.) |
||
Line 5: | Line 5: | ||
<!-- macros --> | <!-- macros --> | ||
== Introduction == | == Introduction == | ||
− | '''cmd.c32''' executes its arguments as if they were typed in directly at the Syslinux prompt. It is commonly used to reference other labels within a cfg file. It can also partially replace the need for a global append directive and/or variables in a cfg file. Let's see some examples. | + | '''cmd.c32''' executes its arguments as if they were typed in directly at the Syslinux prompt. |
+ | It is commonly used to reference other labels within a cfg file. | ||
+ | It can also partially replace the need for a global append directive and/or variables in a cfg file. | ||
+ | Let's see some examples. | ||
<br /> | <br /> | ||
Line 28: | Line 31: | ||
− | The following boot methods are equivalent alternatives: | + | The following boot methods are equivalent alternatives: |
− | A_ Start the second entry in the above menu. Or, | + | |
− | B_ Select the first entry in the above menu; press <tt>[<nowiki/>TAB]</tt>; typing in "<tt> livemedia</tt>" results in something like "< | + | * A_ Start the second entry in the above menu. Or, |
− | C_ In a clean "boot:" prompt, type in "<tt>live</tt>"; <tt>[<nowiki/>ENTER]</tt>. Or, | + | * B_ Select the first entry in the above menu; <!-- |
− | D_ In a clean "boot:" prompt, type in "<tt>normal livemedia</tt>"; <tt>[<nowiki/>ENTER]</tt>. | + | --> press {{nowrap|1=<tt>[<nowiki/>TAB]</tt>;}} <!-- |
+ | --> typing in {{nowrap|1="<tt> livemedia</tt>"}} <!-- | ||
+ | --> results in something like <!-- | ||
+ | --> {{nowrap|1="<code>.linux bzImage initrd=initrd.img option_1 option_2 option_3 livemedia</code>";}} <!-- | ||
+ | --> press {{nowrap|1=<tt>[<nowiki/>ENTER]</tt>.}} Or, | ||
+ | * C_ In a clean "boot:" prompt, type in "<tt>live</tt>"; <tt>[<nowiki/>ENTER]</tt>. Or, | ||
+ | * D_ In a clean "boot:" prompt, type in {{nowrap|"<tt>normal livemedia</tt>";}} <tt>[<nowiki/>ENTER]</tt>. | ||
<br /> | <br /> | ||
− | == Example (I) | + | == Example (I) == |
The following label entry is also equivalent: | The following label entry is also equivalent: | ||
Line 44: | Line 53: | ||
# Equivalent to typing "normal livemedia" in CLI. | # Equivalent to typing "normal livemedia" in CLI. | ||
</pre> | </pre> | ||
− | By using <tt>cmd.c32</tt> in the cfg file, editing the '<tt> | + | By using <tt>cmd.c32</tt> in the cfg file, |
+ | editing the '<tt>APPEND</tt>' line in the '<tt>normal</tt>' boot entry | ||
+ | will directly affect any other boot entry that includes {{nowrap|1='<tt>cmd.c32 normal</tt>'.}} | ||
<br /> | <br /> | ||
− | == Example (II) | + | == Example (II) == |
The following cfg file: | The following cfg file: | ||
Line 104: | Line 115: | ||
</pre> | </pre> | ||
− | Editing the second cfg file is simpler: just change the '<tt>normal</tt>' boot entry. | + | Editing the second cfg file is simpler: |
+ | just change the '<tt>normal</tt>' boot entry. | ||
<br /> | <br /> | ||
− | == Example (III) | + | == Example (III) == |
− | Let's take the last boot entry from the above | + | Let's take the last boot entry from the above {{nowrap|[[#Example (II)]]:}} |
<pre> | <pre> | ||
LABEL es | LABEL es | ||
Line 116: | Line 128: | ||
</pre> | </pre> | ||
− | In the menu, select this entry and press <tt>[<nowiki/>TAB]</tt> so to edit the command line before acting on it. The CLI will show: | + | In the menu, |
+ | select this entry and press {{nowrap|1=<tt>[<nowiki/>TAB]</tt>}} | ||
+ | so as to edit the command line before acting on it. | ||
+ | The CLI will show: | ||
<pre> >.com32 cmd.c32 normal kbrd=es </pre> | <pre> >.com32 cmd.c32 normal kbrd=es </pre> | ||
which is shorter than the original: | which is shorter than the original: | ||
<pre> >.linux bzImage initrd=initrd.img option_1 option_2 option_3 kbrd=es </pre> | <pre> >.linux bzImage initrd=initrd.img option_1 option_2 option_3 kbrd=es </pre> | ||
− | This example shows one '''disadvantage''' of using <tt>cmd.c32</tt>. To get a command line such as: | + | This example shows one '''disadvantage''' of using <tt>cmd.c32</tt>. |
+ | To get a command line such as: | ||
<pre> >.linux bzImage initrd=initrd.img option_3 kbrd=es </pre> | <pre> >.linux bzImage initrd=initrd.img option_3 kbrd=es </pre> | ||
− | the user needs to select the first entry, '<tt>normal</tt>', press <tt>[<nowiki/>TAB]</tt> and edit the whole command by deleting the unwanted options ('<tt>option_1 option_2</tt>') and typing in the additional wanted ones ('<tt>kbrd=es</tt>'). | + | the user needs to select the first entry, '<tt>normal</tt>', |
+ | press <tt>[<nowiki/>TAB]</tt> and edit the whole command | ||
+ | by deleting the unwanted options {{nowrap|('<tt>option_1 option_2</tt>')}} | ||
+ | and typing in the additional wanted ones {{nowrap|1=('<tt>kbrd=es</tt>').}} | ||
<br /> | <br /> | ||
− | == Example (IV) | + | == Example (IV) == |
More than one additional option can be added to the original label. | More than one additional option can be added to the original label. | ||
Line 136: | Line 155: | ||
<br /> | <br /> | ||
− | == Example (V) | + | == Example (V) == |
Changing the <tt>INITRD</tt> is possible. Let's follow the explanation. | Changing the <tt>INITRD</tt> is possible. Let's follow the explanation. | ||
Line 150: | Line 169: | ||
<pre> >.linux bzImage initrd=initrd.img option_1 option_2 option_3 </pre> | <pre> >.linux bzImage initrd=initrd.img option_1 option_2 option_3 </pre> | ||
− | Since the last <tt>INITRD</tt> in a boot command overrides previous ones, then the following command (with an additional '<tt>initrd=new.img</tt>'): | + | Since the last <tt>INITRD</tt> in a boot command overrides previous ones, |
+ | then the following command (with an additional {{nowrap|1='<tt>initrd=new.img</tt>'):}} | ||
<pre> >.linux bzImage initrd=initrd.img option_1 option_2 option_3 initrd=new.img </pre> | <pre> >.linux bzImage initrd=initrd.img option_1 option_2 option_3 initrd=new.img </pre> | ||
Line 165: | Line 185: | ||
<br /> | <br /> | ||
− | == Example (VI) | + | == Example (VI) == |
Merging more than one <tt>INITRD</tt> is possible. | Merging more than one <tt>INITRD</tt> is possible. | ||
Line 171: | Line 191: | ||
The command line: | The command line: | ||
<pre> >.linux bzImage option_1 option_2 option_3 initrd=initrd.img,new.img </pre> | <pre> >.linux bzImage option_1 option_2 option_3 initrd=initrd.img,new.img </pre> | ||
− | uses both, <tt>initrd.img</tt> and <tt>new.img</tt>. The following entry is equivalent: | + | uses both, <tt>initrd.img</tt> and <tt>new.img</tt>. |
+ | The following entry is equivalent: | ||
<pre> | <pre> | ||
LABEL new_initrd_merged | LABEL new_initrd_merged | ||
Line 177: | Line 198: | ||
APPEND normal initrd=initrd.img,new.img | APPEND normal initrd=initrd.img,new.img | ||
</pre> | </pre> | ||
− | since the original '<tt>initrd=initrd.img</tt>' in '<tt>normal</tt>' is "replaced" by the last '<tt>initrd=initrd.img,new.img</tt>'. | + | since the original '<tt>initrd=initrd.img</tt>' in '<tt>normal</tt>' |
+ | is "replaced" by the last '<tt>initrd=initrd.img,new.img</tt>'. | ||
<br /> | <br /> |
Revision as of 18:58, 24 February 2017
Contents
Introduction
cmd.c32 executes its arguments as if they were typed in directly at the Syslinux prompt. It is commonly used to reference other labels within a cfg file. It can also partially replace the need for a global append directive and/or variables in a cfg file. Let's see some examples.
The following code shows a typical boot menu.
UI menu.c32 LABEL normal LINUX bzImage INITRD initrd.img APPEND option_1 option_2 option_3 LABEL live LINUX bzImage INITRD initrd.img APPEND option_1 option_2 option_3 livemedia # The "live" label entry adds one additional option # in comparison to the "normal" label entry.
The following boot methods are equivalent alternatives:
- A_ Start the second entry in the above menu. Or,
- B_ Select the first entry in the above menu; press [TAB]; typing in " livemedia" results in something like "
.linux bzImage initrd=initrd.img option_1 option_2 option_3 livemedia
"; press [ENTER]. Or, - C_ In a clean "boot:" prompt, type in "live"; [ENTER]. Or,
- D_ In a clean "boot:" prompt, type in "normal livemedia"; [ENTER].
Example (I)
The following label entry is also equivalent:
LABEL live COM32 cmd.c32 APPEND normal livemedia # Equivalent to typing "normal livemedia" in CLI.
By using cmd.c32 in the cfg file, editing the 'APPEND' line in the 'normal' boot entry will directly affect any other boot entry that includes 'cmd.c32 normal'.
Example (II)
The following cfg file:
UI menu.c32 LABEL normal LINUX bzImage INITRD initrd.img APPEND option_1 option_2 option_3 LABEL us LINUX bzImage INITRD initrd.img APPEND option_1 option_2 option_3 kbrd=us LABEL de LINUX bzImage INITRD initrd.img APPEND option_1 option_2 option_3 kbrd=de LABEL fr LINUX bzImage INITRD initrd.img APPEND option_1 option_2 option_3 kbrd=fr LABEL es LINUX bzImage INITRD initrd.img APPEND option_1 option_2 option_3 kbrd=es
is equivalent to:
UI menu.c32 LABEL normal LINUX bzImage INITRD initrd.img APPEND option_1 option_2 option_3 LABEL us COM32 cmd.c32 APPEND normal kbrd=us LABEL de COM32 cmd.c32 APPEND normal kbrd=de LABEL fr COM32 cmd.c32 APPEND normal kbrd=fr LABEL es COM32 cmd.c32 APPEND normal kbrd=es
Editing the second cfg file is simpler: just change the 'normal' boot entry.
Example (III)
Let's take the last boot entry from the above #Example (II):
LABEL es COM32 cmd.c32 APPEND normal kbrd=es
In the menu, select this entry and press [TAB] so as to edit the command line before acting on it. The CLI will show:
>.com32 cmd.c32 normal kbrd=es
which is shorter than the original:
>.linux bzImage initrd=initrd.img option_1 option_2 option_3 kbrd=es
This example shows one disadvantage of using cmd.c32. To get a command line such as:
>.linux bzImage initrd=initrd.img option_3 kbrd=es
the user needs to select the first entry, 'normal', press [TAB] and edit the whole command by deleting the unwanted options ('option_1 option_2') and typing in the additional wanted ones ('kbrd=es').
Example (IV)
More than one additional option can be added to the original label.
LABEL live_fr COM32 cmd.c32 APPEND normal livemedia kbrd=fr
Example (V)
Changing the INITRD is possible. Let's follow the explanation.
The 'normal' entry:
LABEL normal LINUX bzImage INITRD initrd.img APPEND option_1 option_2 option_3
is seen in CLI as:
>.linux bzImage initrd=initrd.img option_1 option_2 option_3
Since the last INITRD in a boot command overrides previous ones, then the following command (with an additional 'initrd=new.img'):
>.linux bzImage initrd=initrd.img option_1 option_2 option_3 initrd=new.img
is in fact equivalent to:
>.linux bzImage option_1 option_2 option_3 initrd=new.img
So the following entry in the cfg file:
LABEL new_initrd COM32 cmd.c32 APPEND normal initrd=new.img
uses 'initrd=new.img' instead of the original 'initrd=initrd.img'.
Example (VI)
Merging more than one INITRD is possible.
The command line:
>.linux bzImage option_1 option_2 option_3 initrd=initrd.img,new.img
uses both, initrd.img and new.img. The following entry is equivalent:
LABEL new_initrd_merged COM32 cmd.c32 APPEND normal initrd=initrd.img,new.img
since the original 'initrd=initrd.img' in 'normal' is "replaced" by the last 'initrd=initrd.img,new.img'.