Translation

(itstool) path: sect3/title

Configuration Options
4/210
Context English Chinese (Simplified) (zh_CN) State
Building a NanoBSD Image 构建 NanoBSD 映像
A <application>NanoBSD</application> image is built using a simple <filename>nanobsd.sh</filename> shell script, which can be found in the <filename><replaceable>/usr</replaceable>/src/tools/tools/nanobsd</filename> directory. This script creates an image, which can be copied on the storage medium using the <citerefentry><refentrytitle>dd</refentrytitle><manvolnum>1</manvolnum></citerefentry> utility. <application>NanoBSD</application> 映像是通过使用非常简单的 <filename>nanobsd.sh</filename> shell 脚本来构建的, 这个脚本可以在 <filename><replaceable>/usr</replaceable>/src/tools/tools/nanobsd</filename> 目录中找到。 这个脚本建立的映像文件, 可以用 <citerefentry><refentrytitle>dd</refentrytitle><manvolnum>1</manvolnum></citerefentry> 工具复制到存储介质上。
The necessary commands to build a <application>NanoBSD</application> image are: 构建 <application>NanoBSD</application> 映像所需的命令是:
<prompt>#</prompt> <userinput>cd /usr/src/tools/tools/nanobsd</userinput> <co xml:id="nbsd-cd"/>
<prompt>#</prompt> <userinput>sh nanobsd.sh</userinput> <co xml:id="nbsd-sh"/>
<prompt>#</prompt> <userinput>cd /usr/obj/nanobsd.full</userinput> <co xml:id="nbsd-cd2"/>
<prompt>#</prompt> <userinput>dd if=_.disk.full of=/dev/da0 bs=64k</userinput> <co xml:id="nbsd-dd"/>
<prompt>#</prompt> <userinput>cd /usr/src/tools/tools/nanobsd</userinput> <co xml:id="nbsd-cd"/>
<prompt>#</prompt> <userinput>sh nanobsd.sh</userinput> <co xml:id="nbsd-sh"/>
<prompt>#</prompt> <userinput>cd /usr/obj/nanobsd.full</userinput> <co xml:id="nbsd-cd2"/>
<prompt>#</prompt> <userinput>dd if=_.disk.full of=/dev/da0 bs=64k</userinput> <co xml:id="nbsd-dd"/>
Change the current directory to the base directory of the <application>NanoBSD</application> build script. 进入 <application>NanoBSD</application> 构建脚本的主目录。
Start the build process. 开始构建过程。
Change the current directory to the place where the built images are located. 进入构建好的映像文件所在的目录。
Install <application>NanoBSD</application> onto the storage medium. 在存储介质上安装 <application>NanoBSD</application>。
Customizing a NanoBSD Image 定制 NanoBSD 映像
This is probably the most important and most interesting feature of <application>NanoBSD</application>. This is also where you will be spending most of the time when developing with <application>NanoBSD</application>. 这可能是 <application>NanoBSD</application> 最为重要, 同时也是您最感兴趣的功能。 同时, 您在开发 <application>NanoBSD</application> 应用时, 这也是相当耗时的过程。
Invocation of the following command will force the <filename>nanobsd.sh</filename> to read its configuration from <filename>myconf.nano</filename> located in the current directory: 执行下面的命令将使 <filename>nanobsd.sh</filename> 从当前目录中的 <filename>myconf.nano</filename> 文件读取配置:
<prompt>#</prompt> <userinput>sh nanobsd.sh -c myconf.nano</userinput> <prompt>#</prompt> <userinput>sh nanobsd.sh -c myconf.nano</userinput>
Customization is done in two ways: 定制过程包含两步:
Configuration options 配置选项
Custom functions 定制函数
Configuration Options 配置选项
buildworld buildworld
installworld installworld
With configuration settings, it is possible to configure options passed to both the <_:buildtarget-1/> and <_:buildtarget-2/> stages of the <application>NanoBSD</application> build process, as well as internal options passed to the main build process of <application>NanoBSD</application>. Through these options it is possible to cut the system down, so it will fit on as little as 64MB. You can use the configuration options to trim down FreeBSD even more, until it will consists of just the kernel and two or three files in the userland. 通过对配置进行设置, 可以配置用以传递给 <application>NanoBSD</application> 构建过程中 <_:buildtarget-1/> 和 <_:buildtarget-2/> 阶段的联编和安装选项, 以及 <application>NanoBSD</application> 的主构建过程中的选项。 通过使用这些选项可以削减系统的尺寸, 使之能够放入 64MB 的存储。 您还可以进一步通过这些选项来削减 FreeBSD, 直到它只包含内核以及两三个用户环境文件为止。
The configuration file consists of configuration options, which override the default values. The most important directives are: 配置文件中包含用以代替默认值的配置选项。 最重要的语句包括:
<literal>NANO_NAME</literal> — Name of build (used to construct the workdir names). <literal>NANO_NAME</literal> ── 本次构建的名称 (用于创建工作目录的名字)。
<literal>NANO_SRC</literal> — Path to the source tree used to build the image. <literal>NANO_SRC</literal> ── 用以联编和构建映像的源码树的位置。
<literal>NANO_KERNEL</literal> — Name of kernel configuration file used to build kernel. <literal>NANO_KERNEL</literal> ── 用以联编内核的配置文件的名字。
<literal>CONF_BUILD</literal> — Options passed to the <_:buildtarget-1/> stage of the build. <literal>CONF_BUILD</literal> ── 用于传递给 <_:buildtarget-1/> 构建阶段的选项。
<literal>CONF_INSTALL</literal> — Options passed to the <_:buildtarget-1/> stage of the build. <literal>CONF_INSTALL</literal> ── 用于传递给 <_:buildtarget-1/> 构建阶段的选项。
<literal>CONF_WORLD</literal> — Options passed to both the <_:buildtarget-1/> and the <_:buildtarget-2/> stage of the build. <literal>CONF_WORLD</literal> ── 用以传递给 <_:buildtarget-1/> 和 <_:buildtarget-2/> 这两个构建阶段的选项。
<literal>FlashDevice</literal> — Defines what type of media to use. Check <filename>FlashDevice.sub</filename> for more details. <literal>FlashDevice</literal> ── 定义所用的介质类型。 要了解进一步的细节, 请参考 <filename>FlashDevice.sub</filename> 文件。
Custom Functions 功能定制
It is possible to fine-tune <application>NanoBSD</application> using shell functions in the configuration file. The following example illustrates the basic model of custom functions: 通过在配置文件中使用 shell 函数可以进一步微调 <application>NanoBSD</application>。 下面的例子展示了定制函数的基本模式:
cust_foo () (
echo "bar=baz" &gt; \
${NANO_WORLDDIR}/etc/foo
)
customize_cmd cust_foo
cust_foo () (
echo "bar=baz" &gt; \
${NANO_WORLDDIR}/etc/foo
)
customize_cmd cust_foo
A more useful example of a customization function is the following, which changes the default size of the <filename>/etc</filename> directory from 5MB to 30MB: 下面是一个更贴近实际的例子, 它将默认的 <filename>/etc</filename> 目录尺寸, 从 5MB 调整为 30MB:

Loading…

No matching activity found.

Browse all component changes

Glossary

English Chinese (Simplified) (zh_CN)
No related strings found in the glossary.

Source information

Source string comment

(itstool) path: sect3/title

Source string location
article.translate.xml:226
String age
a year ago
Source string age
a year ago
Translation file
articles/zh_CN/nanobsd.po, string 44