View | Details | Raw Unified | Return to bug 99992
Collapse All | Expand All

(-)config/chapter.sgml (-94 / +17 lines)
Lines 3-8 Link Here
3
3
4
     $FreeBSD: doc/zh_TW.Big5/books/handbook/config/chapter.sgml,v 1.4 2006/07/08 03:01:13 vanilla Exp $
4
     $FreeBSD: doc/zh_TW.Big5/books/handbook/config/chapter.sgml,v 1.4 2006/07/08 03:01:13 vanilla Exp $
5
     Original revision: 1.213
5
     Original revision: 1.213
6
     Chased revision: 1.217
6
-->
7
-->
7
8
8
<chapter id="config-tuning">
9
<chapter id="config-tuning">
Lines 102-108 Link Here
102
      <sect3>
103
      <sect3>
103
	<title>Base Partitions</title>
104
	<title>Base Partitions</title>
104
105
105
	<para>用 &man.disklabel.8; 或 &man.sysinstall.8; 來規劃檔案系統時,請記住:
106
	<para>用 &man.bsdlabel.8; 或 &man.sysinstall.8; 來規劃檔案系統時,請記住:
106
	  硬碟在傳輸資料方面,(由於結構為碟片因素)外圈會比內圈來得快些。
107
	  硬碟在傳輸資料方面,(由於結構為碟片因素)外圈會比內圈來得快些。
107
	  因此,建議把較小、常會存取的分割區儘量放外圈,而較大的分割區像是 
108
	  因此,建議把較小、常會存取的分割區儘量放外圈,而較大的分割區像是 
108
	  <filename>/usr</filename> 則應放在較內圈。
109
	  <filename>/usr</filename> 則應放在較內圈。
Lines 370-376 Link Here
370
        kill -9 `cat /var/run/utility.pid`
371
        kill -9 `cat /var/run/utility.pid`
371
        ;;
372
        ;;
372
*)
373
*)
373
        echo "Usage: `basename $0` {start|stop}" >&2
374
        echo "Usage: `basename $0` {start|stop}" &gt;&2
374
        exit 64
375
        exit 64
375
        ;;
376
        ;;
376
esac
377
esac
Lines 830-844 Link Here
830
	the supported hardware and even the possible problems that
831
	the supported hardware and even the possible problems that
831
	could occur.</para>
832
	could occur.</para>
832
833
833
      <note>
834
	<para><filename>NOTES</filename> does not exist on
835
	  &os;&nbsp;4.X.  Instead, check the <filename>LINT</filename>
836
	  file for information about various network interfaces.  See
837
	  <xref linkend="kernelconfig-config"> for a more detailed
838
	  summary of <filename>NOTES</filename> versus
839
	<filename>LINT</filename>.</para>
840
      </note>
841
842
      <para>If you own a common card, most of the time you will not
834
      <para>If you own a common card, most of the time you will not
843
	have to look very hard for a driver.  Drivers for common
835
	have to look very hard for a driver.  Drivers for common
844
	network cards are present in the <filename>GENERIC</filename>
836
	network cards are present in the <filename>GENERIC</filename>
Lines 1578-1584 Link Here
1578
      syntax:</para>
1570
      syntax:</para>
1579
1571
1580
    <screen>&prompt.root; <userinput>sysctl kern.maxfiles=5000</userinput>
1572
    <screen>&prompt.root; <userinput>sysctl kern.maxfiles=5000</userinput>
1581
kern.maxfiles: 2088 -> 5000</screen>
1573
kern.maxfiles: 2088 -&gt; 5000</screen>
1582
1574
1583
    <para>Settings of sysctl variables are usually either strings,
1575
    <para>Settings of sysctl variables are usually either strings,
1584
      numbers, or booleans (a  boolean being <literal>1</literal> for yes
1576
      numbers, or booleans (a  boolean being <literal>1</literal> for yes
Lines 1698-1705 Link Here
1698
 	</para>
1690
 	</para>
1699
1691
1700
 	<para>There are various other buffer-cache and VM page cache
1692
 	<para>There are various other buffer-cache and VM page cache
1701
 	  related sysctls.  We do not recommend modifying these values.  As
1693
 	  related sysctls.  We do not recommend modifying these values,
1702
 	  of &os;&nbsp;4.3, the VM system does an extremely good job of
1694
 	  the VM system does an extremely good job of
1703
 	  automatically tuning itself.</para>
1695
 	  automatically tuning itself.</para>
1704
       </sect3>
1696
       </sect3>
1705
1697
Lines 1801-1810 Link Here
1801
	it is mounted.  A good time to enable Soft Updates is before any
1793
	it is mounted.  A good time to enable Soft Updates is before any
1802
	partitions have been mounted, in single-user mode.</para>
1794
	partitions have been mounted, in single-user mode.</para>
1803
1795
1804
      <note><para>As of &os;&nbsp;4.5, it is possible to enable Soft Updates
1805
	at filesystem creation time, through use of the <literal>-U</literal>
1806
	option to &man.newfs.8;.</para></note>
1807
1808
      <para>Soft Updates drastically improves meta-data performance, mainly
1796
      <para>Soft Updates drastically improves meta-data performance, mainly
1809
        file creation and deletion, through the use of a memory cache.  We
1797
        file creation and deletion, through the use of a memory cache.  We
1810
        recommend to use Soft Updates on all of your file systems.  There
1798
        recommend to use Soft Updates on all of your file systems.  There
Lines 2011-2026 Link Here
2011
          connected at once, the resources needed may be similar to a
1999
          connected at once, the resources needed may be similar to a
2012
          high-scale web server.</para>
2000
          high-scale web server.</para>
2013
2001
2014
	<para>Starting with &os;&nbsp;4.5, the system will auto-tune
2002
	<para>The system will auto-tune
2015
	  <literal>maxusers</literal> for you if you explicitly set it to
2003
	  <literal>maxusers</literal> for you if you explicitly set it to
2016
	  <literal>0</literal><footnote>
2004
	  <literal>0</literal><footnote>
2017
	    <para>The auto-tuning algorithm sets
2005
	    <para>The auto-tuning algorithm sets
2018
	      <literal>maxusers</literal> equal to the amount of memory in the
2006
	      <literal>maxusers</literal> equal to the amount of memory in the
2019
	      system, with a minimum of 32, and a maximum of 384.</para>
2007
	      system, with a minimum of 32, and a maximum of 384.</para>
2020
	  </footnote>.  In &os;&nbsp;5.X and above, <literal>maxusers</literal>
2008
	  </footnote>.  When setting this option, you will want to set
2021
	  will default to <literal>0</literal> if not specified.  If you
2022
	  are using an version of &os; earlier than 4.5, or you want to
2023
	  manage it yourself you will want to set
2024
	  <literal>maxusers</literal> to at least 4, especially if you are
2009
	  <literal>maxusers</literal> to at least 4, especially if you are
2025
	  using the X Window System or compiling software.  The reason is that
2010
	  using the X Window System or compiling software.  The reason is that
2026
	  the most important table set by <literal>maxusers</literal> is the
2011
	  the most important table set by <literal>maxusers</literal> is the
Lines 2207-2223 Link Here
2207
	  3500) to get the desired effect.  Reducing these parameters
2192
	  3500) to get the desired effect.  Reducing these parameters
2208
	  should be done as a last resort only.</para>
2193
	  should be done as a last resort only.</para>
2209
2194
2210
	<note>
2211
	  <para>In 4.X and earlier releases of &os; the
2212
	    <literal>inflight</literal> sysctl variables are directly under
2213
	    <varname>net.inet.tcp</varname>.  Their names were
2214
	    (in alphabetic order):
2215
	    <varname>net.inet.tcp.inflight_debug</varname>,
2216
	    <varname>net.inet.tcp.inflight_enable</varname>,
2217
	    <varname>net.inet.tcp.inflight_max</varname>,
2218
	    <varname>net.inet.tcp.inflight_min</varname>,
2219
	    <varname>net.inet.tcp.inflight_stab</varname>.</para>
2220
	</note>
2221
      </sect3>
2195
      </sect3>
2222
    </sect2>
2196
    </sect2>
2223
2197
Lines 2267-2272 Link Here
2267
      space: adding a new hard drive, enabling swap over NFS, and
2241
      space: adding a new hard drive, enabling swap over NFS, and
2268
      creating a swap file on an existing partition.</para>
2242
      creating a swap file on an existing partition.</para>
2269
2243
2244
    <para>For information on how to encrypt swap space, what options
2245
      for this task exist and why it should be done, please refer to
2246
      <xref linkend="swap-encrypting"> of the Handbook.</para>
2247
2270
    <sect2 id="new-drive-swap">
2248
    <sect2 id="new-drive-swap">
2271
      <title>Swap on a New Hard Drive</title>
2249
      <title>Swap on a New Hard Drive</title>
2272
2250
Lines 2283-2292 Link Here
2283
      <title>Swapping over NFS</title>
2261
      <title>Swapping over NFS</title>
2284
2262
2285
      <para>Swapping over NFS is only recommended if you do not have a
2263
      <para>Swapping over NFS is only recommended if you do not have a
2286
	local hard disk to swap to.  Swapping over NFS is slow and
2264
	local hard disk to swap to; NFS swapping will be limited
2287
	inefficient in versions of &os; prior to 4.X.  It is
2288
	reasonably fast and efficient in 4.0-RELEASE and newer.  Even
2289
	with newer versions of &os;, NFS swapping will be limited
2290
	by the available network bandwidth and puts an additional
2265
	by the available network bandwidth and puts an additional
2291
	burden on the NFS server.</para>
2266
	burden on the NFS server.</para>
2292
    </sect2>
2267
    </sect2>
Lines 2300-2352 Link Here
2300
	want, of course.</para>
2275
	want, of course.</para>
2301
2276
2302
      <example>
2277
      <example>
2303
        <title>Creating a Swapfile on &os; 4.X</title>
2278
        <title>Creating a Swapfile on &os;</title>
2304
2305
      <orderedlist>
2306
        <listitem>
2307
          <para>Be certain that your kernel configuration includes
2308
            the vnode driver.  It is <emphasis>not</emphasis> in recent versions of
2309
            <filename>GENERIC</filename>.</para>
2310
2311
          <programlisting>pseudo-device   vn 1   #Vnode driver (turns a file into a device)</programlisting>
2312
        </listitem>
2313
2314
	<listitem>
2315
	  <para>Create a vn-device:</para>
2316
	  <screen>&prompt.root; <userinput>cd /dev</userinput>
2317
&prompt.root; <userinput>sh MAKEDEV vn0</userinput></screen>
2318
	</listitem>
2319
2320
	<listitem>
2321
	  <para>Create a swapfile (<filename>/usr/swap0</filename>):</para>
2322
2323
	  <screen>&prompt.root; <userinput>dd if=/dev/zero of=/usr/swap0 bs=1024k count=64</userinput></screen>
2324
	</listitem>
2325
2326
	<listitem>
2327
	  <para>Set proper permissions on (<filename>/usr/swap0</filename>):</para>
2328
2329
	  <screen>&prompt.root; <userinput>chmod 0600 /usr/swap0</userinput></screen>
2330
	</listitem>
2331
2332
	<listitem>
2333
	  <para>Enable the swap file in <filename>/etc/rc.conf</filename>:</para>
2334
2335
	  <programlisting>swapfile="/usr/swap0"   # Set to name of swapfile if aux swapfile desired.</programlisting>
2336
	</listitem>
2337
2338
	<listitem>
2339
2340
          <para>Reboot the machine or to enable the swap file immediately,
2341
            type:</para>
2342
2343
          <screen>&prompt.root; <userinput>vnconfig -e /dev/vn0b /usr/swap0 swap</userinput></screen>
2344
        </listitem>
2345
      </orderedlist>
2346
2347
      </example>
2348
      <example>
2349
	<title>Creating a Swapfile on &os; 5.X</title>
2350
2279
2351
      <orderedlist>
2280
      <orderedlist>
2352
	<listitem>
2281
	<listitem>
Lines 2380-2386 Link Here
2380
	  <para>Reboot the machine or to enable the swap file immediately,
2309
	  <para>Reboot the machine or to enable the swap file immediately,
2381
            type:</para>
2310
            type:</para>
2382
2311
2383
	  <screen>&prompt.root; <userinput>mdconfig -a -t vnode -f /usr/swap0 -u 0 && swapon /dev/md0</userinput></screen>
2312
	  <screen>&prompt.root; <userinput>mdconfig -a -t vnode -f /usr/swap0 -u 0 &amp;&amp; swapon /dev/md0</userinput></screen>
2384
        </listitem>
2313
        </listitem>
2385
      </orderedlist>
2314
      </orderedlist>
2386
2315
Lines 2419-2430 Link Here
2419
2348
2420
    <para>In this section of the &os; Handbook, we will provide
2349
    <para>In this section of the &os; Handbook, we will provide
2421
      comprehensive information about <acronym>ACPI</acronym>.  References
2350
      comprehensive information about <acronym>ACPI</acronym>.  References
2422
      will be provided for further reading at the end.  Please be aware
2351
      will be provided for further reading at the end.</para>
2423
      that <acronym>ACPI</acronym> is available on &os;&nbsp;5.X and
2424
      above systems as a default kernel module.  For &os;&nbsp;4.9,
2425
      <acronym>ACPI</acronym> can be enabled by adding the line
2426
      <literal>device acpica</literal> to a kernel configuration and
2427
      rebuilding.</para>
2428
2352
2429
    <sect2 id="acpi-intro">
2353
    <sect2 id="acpi-intro">
2430
      <title>What Is ACPI?</title>
2354
      <title>What Is ACPI?</title>
Lines 2446-2453 Link Here
2446
	more control and flexibility to the operating system
2370
	more control and flexibility to the operating system
2447
	(<acronym>OS</acronym>).
2371
	(<acronym>OS</acronym>).
2448
	Modern systems <quote>stretched</quote> the limits of the
2372
	Modern systems <quote>stretched</quote> the limits of the
2449
	current Plug and Play interfaces (such as APM, which is used in
2373
	current Plug and Play interfaces prior to the introduction of
2450
	&os;&nbsp;4.X), prior to the introduction of
2451
	<acronym>ACPI</acronym>.  <acronym>ACPI</acronym> is the direct
2374
	<acronym>ACPI</acronym>.  <acronym>ACPI</acronym> is the direct
2452
	successor to <acronym>APM</acronym>
2375
	successor to <acronym>APM</acronym>
2453
	(Advanced Power Management).</para>
2376
	(Advanced Power Management).</para>
(-)disks/chapter.sgml (-293 / +198 lines)
Lines 100-111 Link Here
100
	  <row>
100
	  <row>
101
	    <entry>非標準規格光碟機</entry>
101
	    <entry>非標準規格光碟機</entry>
102
	    <entry>Mitsumi 光碟機用 <literal>mcd</literal>,
102
	    <entry>Mitsumi 光碟機用 <literal>mcd</literal>,
103
	      Sony 光碟機用 <literal>scd</literal>,
103
	      Sony 光碟機用 <literal>scd</literal>。
104
	      Matsushita/Pansonic 光碟機用 <literal>matcd</literal> 
105
		<footnote>
106
		  <para>2002 年 10 月 5 日 FreeBSD 4.X 移除了 &man.matcd.4; 驅動程式,
107
		  因此 FreeBSD 5.0 及以後的版本不再支援。</para>
108
		</footnote>
109
	    </entry>
104
	    </entry>
110
	  </row>
105
	  </row>
111
	  <row>
106
	  <row>
Lines 164-171 Link Here
164
	看一下 <filename>/var/run/dmesg.boot</filename> 以確認系統是否抓到新硬碟。
159
	看一下 <filename>/var/run/dmesg.boot</filename> 以確認系統是否抓到新硬碟。
165
	繼續剛才的範例,新增的硬碟會是 <devicename>da1</devicename>,
160
	繼續剛才的範例,新增的硬碟會是 <devicename>da1</devicename>,
166
	假設我們想將它掛載到 <filename>/1</filename> 這個位置
161
	假設我們想將它掛載到 <filename>/1</filename> 這個位置
167
	(如果您新增的是 IDE 硬碟的話,4.0 之前的系統是 
162
	(如果您新增的是 IDE 硬碟的話,請用
168
	 <devicename>wd1</devicename>,4.X 及之後的系統則是
169
	 <devicename>ad1</devicename>)。</para>
163
	 <devicename>ad1</devicename>)。</para>
170
164
171
    <indexterm><primary>partitions</primary></indexterm>
165
    <indexterm><primary>partitions</primary></indexterm>
Lines 194-200 Link Here
194
	及 <filename>e</filename> BSD partition。在 dedicated 模式的話,
188
	及 <filename>e</filename> BSD partition。在 dedicated 模式的話,
195
	新硬碟則是 <filename>/dev/da1e</filename>。</para>
189
	新硬碟則是 <filename>/dev/da1e</filename>。</para>
196
190
197
    <para>因為 &man.bsdlabel.8;(在 &os;&nbsp;4.X 稱為 &man.disklabel.8;)
191
    <para>因為 &man.bsdlabel.8;
198
	用 32-bit 整數來儲存 sector(磁區) 數,
192
	用 32-bit 整數來儲存 sector(磁區) 數,
199
	因此限制一個硬碟最大只能有 2^32-1 個 sector,亦即 2TB 的空間。
193
	因此限制一個硬碟最大只能有 2^32-1 個 sector,亦即 2TB 的空間。
200
	而 &man.fdisk.8; 的格式容許起始 sector 編號不超過 2^32-1,
194
	而 &man.fdisk.8; 的格式容許起始 sector 編號不超過 2^32-1,
Lines 216-223 Link Here
216
	  <title>操作 <application>Sysinstall</application></title>
210
	  <title>操作 <application>Sysinstall</application></title>
217
211
218
	  <para>透過 <command>sysinstall</command>
212
	  <para>透過 <command>sysinstall</command>
219
	    (<command>/stand/sysinstall</command> in &os; versions older
213
		的選單介面,您可以輕易為硬碟分割 BIOS partition(slice) 
220
	    than 5.2) 的選單介面,您可以輕易為硬碟分割 BIOS partition(slice) 
221
		和 BSD patition。您必須以 root 身份使用 <command>sysinstall</command>,
214
		和 BSD patition。您必須以 root 身份使用 <command>sysinstall</command>,
222
		要嘛用 root 登入,要嘛用 <command>su</command> 切換到 root。
215
		要嘛用 root 登入,要嘛用 <command>su</command> 切換到 root。
223
		執行 <command>sysinstall</command> 後,選 <Literal>Configure</literal>
216
		執行 <command>sysinstall</command> 後,選 <Literal>Configure</literal>
Lines 300-307 Link Here
300
	
293
	
301
	<screen>&prompt.root; <userinput>dd if=/dev/zero of=/dev/da1 bs=1k count=1</userinput>
294
	<screen>&prompt.root; <userinput>dd if=/dev/zero of=/dev/da1 bs=1k count=1</userinput>
302
&prompt.root; <userinput>fdisk -BI da1</userinput> # 初始您的硬碟。
295
&prompt.root; <userinput>fdisk -BI da1</userinput> # 初始您的硬碟。
303
&prompt.root; <userinput>disklabel -B -w -r da1s1 auto</userinput> # 建立 disklabel。
296
&prompt.root; <userinput>bsdlabel -B -w -r da1s1 auto</userinput> # 建立 bsdlabel。
304
&prompt.root; <userinput>disklabel -e da1s1</userinput> # 編輯 disklabel 以新增 label。
297
&prompt.root; <userinput>bsdlabel -e da1s1</userinput> # 編輯 bsdlabel 以新增 label。
305
&prompt.root; <userinput>mkdir -p /1</userinput>
298
&prompt.root; <userinput>mkdir -p /1</userinput>
306
&prompt.root; <userinput>newfs /dev/da1s1e</userinput> # 如果您新增了多個 label,對每個 label 重覆這個步驟。
299
&prompt.root; <userinput>newfs /dev/da1s1e</userinput> # 如果您新增了多個 label,對每個 label 重覆這個步驟。
307
&prompt.root; <userinput>mount /dev/da1s1e /1</userinput> # 掛載這些新 label。
300
&prompt.root; <userinput>mount /dev/da1s1e /1</userinput> # 掛載這些新 label。
Lines 309-316 Link Here
309
302
310
	<para>如果您新增的是 IDE 硬碟,將 <filename>da</filename>
303
	<para>如果您新增的是 IDE 硬碟,將 <filename>da</filename>
311
	  改成 <filename>da</filename> 即可
304
	  改成 <filename>da</filename> 即可
312
	  <footnote><para>譯註:da 是 direct access,ad 則是 ata disk。</para></footnote>。
305
	  <footnote><para>譯註:da 是 direct access。</para></footnote>。</para>
313
	  而如果是 4.X 之前的系統,用 <filename>wd</filename>。</para>
314
      </sect3>
306
      </sect3>
315
307
316
      <sect3>
308
      <sect3>
Lines 326-333 Link Here
326
	  not understand.</para></footnote>。</para>
318
	  not understand.</para></footnote>。</para>
327
	
319
	
328
	<screen>&prompt.root; <userinput>dd if=/dev/zero of=/dev/da1 bs=1k count=1</userinput>
320
	<screen>&prompt.root; <userinput>dd if=/dev/zero of=/dev/da1 bs=1k count=1</userinput>
329
&prompt.root; <userinput>disklabel -Brw da1 auto</userinput>
321
&prompt.root; <userinput>bsdlabel -Brw da1 auto</userinput>
330
&prompt.root; <userinput>disklabel -e da1</userinput>				# 建立 `e' partition。
322
&prompt.root; <userinput>bsdlabel -e da1</userinput>				# 建立 `e' partition。
331
&prompt.root; <userinput>newfs -d0 /dev/da1e</userinput>
323
&prompt.root; <userinput>newfs -d0 /dev/da1e</userinput>
332
&prompt.root; <userinput>mkdir -p /1</userinput>
324
&prompt.root; <userinput>mkdir -p /1</userinput>
333
&prompt.root; <userinput>vi /etc/fstab</userinput>				# 新增一筆 /dev/da1e 的資訊。
325
&prompt.root; <userinput>vi /etc/fstab</userinput>				# 新增一筆 /dev/da1e 的資訊。
Lines 336-352 Link Here
336
	<para>另一種方法:</para>
328
	<para>另一種方法:</para>
337
329
338
	<screen>&prompt.root; <userinput>dd if=/dev/zero of=/dev/da1 count=2</userinput>
330
	<screen>&prompt.root; <userinput>dd if=/dev/zero of=/dev/da1 count=2</userinput>
339
&prompt.root; <userinput>disklabel /dev/da1 | disklabel -BrR da1 /dev/stdin</userinput>
331
&prompt.root; <userinput>bsdlabel /dev/da1 | bsdlabel -BrR da1 /dev/stdin</userinput>
340
&prompt.root; <userinput>newfs /dev/da1e</userinput>
332
&prompt.root; <userinput>newfs /dev/da1e</userinput>
341
&prompt.root; <userinput>mkdir -p /1</userinput>
333
&prompt.root; <userinput>mkdir -p /1</userinput>
342
&prompt.root; <userinput>vi /etc/fstab</userinput>					# 新增一筆 /dev/da1e 的資訊。
334
&prompt.root; <userinput>vi /etc/fstab</userinput>					# 新增一筆 /dev/da1e 的資訊。
343
&prompt.root; <userinput>mount /1</userinput></screen>
335
&prompt.root; <userinput>mount /1</userinput></screen>
344
336
345
	<note><para>從 &os;&nbsp;5.1-RELEASE 開始,&man.bsdlabel.8; 取代原本的
346
	  &man.disklabel.8; 程式,某些指令參數已經廢棄不用。
347
	  上面範例裡,如果用的是 &man.bsdlabel.8;,<option>-r</option>
348
	  參數應該拿掉。更多的資訊請參考 &man.bsdlabel.8; manual page。
349
	  </para></note>
350
      </sect3>
337
      </sect3>
351
    </sect2>
338
    </sect2>
352
  </sect1>
339
  </sect1>
Lines 430-476 Link Here
430
 	    Add this line to your kernel configuration file, rebuild, and
417
 	    Add this line to your kernel configuration file, rebuild, and
431
 	    reinstall the kernel:</para>
418
 	    reinstall the kernel:</para>
432
419
433
	  <programlisting>pseudo-device   ccd     4</programlisting>
434
435
	  <para>On 5.X systems, you have to use instead the following
436
	    line:</para>
437
438
	  <programlisting>device   ccd</programlisting>
420
	  <programlisting>device   ccd</programlisting>
439
421
440
	  <note><para>In FreeBSD&nbsp;5.X, it is not necessary to specify
441
	    a number of &man.ccd.4; devices, as the &man.ccd.4; device driver is now
442
	    self-cloning &mdash; new device instances will automatically be
443
	    created on demand.</para></note>
444
445
	  <para>The &man.ccd.4; support can also be
422
	  <para>The &man.ccd.4; support can also be
446
	    loaded as a kernel loadable module in FreeBSD 3.0 or
423
	    loaded as a kernel loadable module.</para>
447
	    later.</para>
448
424
449
 	  <para>To set up &man.ccd.4;, you must first use
425
 	  <para>To set up &man.ccd.4;, you must first use
450
 	    &man.disklabel.8; to label the disks:</para>
426
 	    &man.bsdlabel.8; to label the disks:</para>
451
427
452
	  <programlisting>disklabel -r -w ad1 auto
428
	  <programlisting>bsdlabel -r -w ad1 auto
453
disklabel -r -w ad2 auto
429
bsdlabel -r -w ad2 auto
454
disklabel -r -w ad3 auto</programlisting>
430
bsdlabel -r -w ad3 auto</programlisting>
455
431
456
 	  <para>This creates a disklabel for <devicename>ad1c</devicename>, <devicename>ad2c</devicename> and <devicename>ad3c</devicename> that
432
 	  <para>This creates a bsdlabel for <devicename>ad1c</devicename>, <devicename>ad2c</devicename> and <devicename>ad3c</devicename> that
457
  	    spans the entire disk.</para>
433
  	    spans the entire disk.</para>
458
434
459
	  <note><para>Since &os;&nbsp;5.1-RELEASE, the &man.bsdlabel.8;
460
	    utility replaces the old &man.disklabel.8; program.  With
461
	    &man.bsdlabel.8; a number of obsolete options and parameters
462
	    have been retired; in the examples above the option
463
	    <option>-r</option> should be removed.  For more
464
	    information, please refer to the &man.bsdlabel.8;
465
	    manual page.</para></note>
466
467
 	  <para>The next step is to change the disk label type.  You
435
 	  <para>The next step is to change the disk label type.  You
468
 	    can use &man.disklabel.8; to edit the
436
 	    can use &man.bsdlabel.8; to edit the
469
 	    disks:</para>
437
 	    disks:</para>
470
438
471
	  <programlisting>disklabel -e ad1
439
	  <programlisting>bsdlabel -e ad1
472
disklabel -e ad2
440
bsdlabel -e ad2
473
disklabel -e ad3</programlisting>
441
bsdlabel -e ad3</programlisting>
474
442
475
 	  <para>This opens up the current disk label on each disk with
443
 	  <para>This opens up the current disk label on each disk with
476
 	    the editor specified by the <envar>EDITOR</envar>
444
 	    the editor specified by the <envar>EDITOR</envar>
Lines 499-515 Link Here
499
	<sect4 id="ccd-buildingfs">
467
	<sect4 id="ccd-buildingfs">
500
	  <title>Building the File System</title>
468
	  <title>Building the File System</title>
501
469
502
            <para>The device node for
503
	    <devicename>ccd0c</devicename> may not exist yet, so to
504
	    create it, perform the following commands:</para>
505
506
	  <programlisting>cd /dev
507
sh MAKEDEV ccd0</programlisting>
508
509
	  <note><para>In FreeBSD 5.0, &man.devfs.5; will automatically
510
	    manage device nodes in <filename>/dev</filename>, so use of
511
	    <command>MAKEDEV</command> is not necessary.</para></note>
512
513
	  <para>Now that you have all the disks labeled, you must
470
	  <para>Now that you have all the disks labeled, you must
514
	    build the &man.ccd.4;.  To do that,
471
	    build the &man.ccd.4;.  To do that,
515
	    use  &man.ccdconfig.8;, with options similar to the following:</para>
472
	    use  &man.ccdconfig.8;, with options similar to the following:</para>
Lines 788-809 Link Here
788
      </note>
745
      </note>
789
746
790
      <para>Support for USB 2.0 controllers is provided on
747
      <para>Support for USB 2.0 controllers is provided on
791
	&os;&nbsp;5.X, and on the 4.X branch since &os;&nbsp;4.10-RELEASE.
748
	&os;; however, you must add:</para>
792
	You have to add:</para>
793
749
794
      <programlisting>device ehci</programlisting>
750
      <programlisting>device ehci</programlisting>
795
751
796
      <para>to your configuration file for USB 2.0 support.  Note
752
      <para>to your configuration file for USB 2.0 support.  Note
797
	&man.uhci.4; and &man.ohci.4; drivers are still needed if you
753
	&man.uhci.4; and &man.ohci.4; drivers are still needed if you
798
	want USB 1.X support.</para>
754
	want USB 1.X support.</para>
799
800
      <note>
801
	<para>On &os;&nbsp;4.X, the USB daemon (&man.usbd.8;) must be
802
	  running to be able to see some USB devices.   To enable it,
803
	  add <literal>usbd_enable="YES"</literal> to your
804
	  <filename>/etc/rc.conf</filename> file and reboot the
805
	  machine.</para>
806
      </note>
807
    </sect2>
755
    </sect2>
808
756
809
    <sect2>
757
    <sect2>
Lines 1020-1035 Link Here
1020
968
1021
      <screen>&prompt.root; <userinput>mkisofs -R -no-emul-boot -b boot/cdboot -o /tmp/bootable.iso /tmp/myboot</userinput></screen>
969
      <screen>&prompt.root; <userinput>mkisofs -R -no-emul-boot -b boot/cdboot -o /tmp/bootable.iso /tmp/myboot</userinput></screen>
1022
970
1023
      <para>Having done that, if you have <devicename>vn</devicename>
971
      <para>Having done that, if you have <devicename>md</devicename>
1024
	(FreeBSD&nbsp;4.X), or <devicename>md</devicename>
1025
	(FreeBSD&nbsp;5.X)
1026
	configured in your kernel, you can mount the file system with:</para>
972
	configured in your kernel, you can mount the file system with:</para>
1027
973
1028
      <screen>&prompt.root; <userinput>vnconfig -e vn0c /tmp/bootable.iso</userinput>
1029
&prompt.root; <userinput>mount -t cd9660 /dev/vn0c /mnt</userinput></screen>
1030
1031
      <para>for FreeBSD&nbsp;4.X, and for FreeBSD&nbsp;5.X:</para>
1032
1033
      <screen>&prompt.root; <userinput>mdconfig -a -t vnode -f /tmp/bootable.iso -u 0</userinput>
974
      <screen>&prompt.root; <userinput>mdconfig -a -t vnode -f /tmp/bootable.iso -u 0</userinput>
1034
&prompt.root; <userinput>mount -t cd9660 /dev/md0 /mnt</userinput></screen>
975
&prompt.root; <userinput>mount -t cd9660 /dev/md0 /mnt</userinput></screen>
1035
976
Lines 1058-1064 Link Here
1058
999
1059
      <para>Will burn a copy of <replaceable>imagefile.iso</replaceable> on
1000
      <para>Will burn a copy of <replaceable>imagefile.iso</replaceable> on
1060
	<replaceable>cddevice</replaceable>. The default device is
1001
	<replaceable>cddevice</replaceable>. The default device is
1061
	<filename>/dev/acd0</filename> (or <filename>/dev/acd0c</filename> under &os;&nbsp;4.X). See &man.burncd.8; for options to
1002
	<filename>/dev/acd0</filename>.  See &man.burncd.8; for options to
1062
	set the write speed, eject the CD after burning, and write audio
1003
	set the write speed, eject the CD after burning, and write audio
1063
	data.</para>
1004
	data.</para>
1064
    </sect2>
1005
    </sect2>
Lines 1093-1099 Link Here
1093
        <secondary>burning</secondary>
1034
        <secondary>burning</secondary>
1094
      </indexterm>
1035
      </indexterm>
1095
      <screen>&prompt.root; <userinput>cdrecord -scanbus</userinput>
1036
      <screen>&prompt.root; <userinput>cdrecord -scanbus</userinput>
1096
Cdrecord 1.9 (i386-unknown-freebsd4.2) Copyright (C) 1995-2000 J&ouml;rg Schilling
1037
Cdrecord-Clone 2.01 (i386-unknown-freebsd7.0) Copyright (C) 1995-2004 J&ouml;rg Schilling
1097
Using libscg version 'schily-0.1'
1038
Using libscg version 'schily-0.1'
1098
scsibus0:
1039
scsibus0:
1099
        0,0,0     0) 'SEAGATE ' 'ST39236LW       ' '0004' Disk
1040
        0,0,0     0) 'SEAGATE ' 'ST39236LW       ' '0004' Disk
Lines 1173-1187 Link Here
1173
1114
1174
	  <screen>&prompt.root; <userinput>dd if=/dev/acd0 of=/dev/null count=1</userinput></screen>
1115
	  <screen>&prompt.root; <userinput>dd if=/dev/acd0 of=/dev/null count=1</userinput></screen>
1175
1116
1176
	  <note><para>In &os; 4.X, the entries are not prefixed with
1177
	    zero.  If the necessary entries in <filename>/dev</filename>
1178
	    are missing, use <command>MAKEDEV</command> to create
1179
	    them:</para>
1180
1181
	  <screen>&prompt.root; <userinput>cd /dev</userinput>
1182
&prompt.root; <userinput>sh MAKEDEV acd0t99</userinput></screen>
1183
	  </note>
1184
1185
	</step>
1117
	</step>
1186
1118
1187
	<step>
1119
	<step>
Lines 1213-1221 Link Here
1213
        &man.mkisofs.8;, and you can use it to duplicate
1145
        &man.mkisofs.8;, and you can use it to duplicate
1214
	any data CD.  The example given here assumes that your CDROM
1146
	any data CD.  The example given here assumes that your CDROM
1215
	device is <devicename>acd0</devicename>.  Substitute your
1147
	device is <devicename>acd0</devicename>.  Substitute your
1216
	correct CDROM device.  Under &os;&nbsp;4.X, a <literal>c</literal> must be appended
1148
	correct CDROM device.</para>
1217
	to the end of the device name to indicate the entire partition
1218
	or, in the case of CDROMs, the entire disc.</para>
1219
1149
1220
      <screen>&prompt.root; <userinput>dd if=/dev/acd0 of=file.iso bs=2048</userinput></screen>
1150
      <screen>&prompt.root; <userinput>dd if=/dev/acd0 of=file.iso bs=2048</userinput></screen>
1221
1151
Lines 1260-1266 Link Here
1260
	oddly, however.  For example, Joliet disks store all filenames
1190
	oddly, however.  For example, Joliet disks store all filenames
1261
	in two-byte Unicode characters.  The FreeBSD kernel does not
1191
	in two-byte Unicode characters.  The FreeBSD kernel does not
1262
	speak Unicode (yet!), so non-English characters show up as
1192
	speak Unicode (yet!), so non-English characters show up as
1263
	question marks.  (If you are running FreeBSD 4.3 or later, the
1193
	question marks.  (The FreeBSD
1264
	CD9660 driver includes hooks to load an appropriate Unicode
1194
	CD9660 driver includes hooks to load an appropriate Unicode
1265
	conversion table on the fly.  Modules for some of the common
1195
	conversion table on the fly.  Modules for some of the common
1266
	encodings are available via the
1196
	encodings are available via the
Lines 1797-1840 Link Here
1797
1727
1798
	<para>Floppy disks are accessed through entries in
1728
	<para>Floppy disks are accessed through entries in
1799
	  <filename>/dev</filename>, just like other devices.  To
1729
	  <filename>/dev</filename>, just like other devices.  To
1800
	  access the raw floppy disk in 4.X and earlier releases, one
1730
	  access the raw floppy disk, simply use
1801
	  uses
1802
	  <filename>/dev/fd<replaceable>N</replaceable></filename>,
1803
	  where <replaceable>N</replaceable> stands for the drive
1804
	  number, usually 0, or
1805
	  <filename>/dev/fd<replaceable>NX</replaceable></filename>,
1806
	  where <replaceable>X</replaceable> stands for a
1807
	  letter.</para>
1808
1809
	<para>In 5.0 or newer releases, simply use
1810
	  <filename>/dev/fd<replaceable>N</replaceable></filename>.</para>
1731
	  <filename>/dev/fd<replaceable>N</replaceable></filename>.</para>
1811
1732
1812
	<sect4>
1813
	  <title>The Disk Size in 4.X and Earlier Releases</title>
1814
1815
	  <para>There are also <filename>/dev/fd<replaceable>N</replaceable>.<replaceable>size</replaceable></filename>
1816
	    devices, where <replaceable>size</replaceable> is a floppy disk
1817
	    size in kilobytes.  These entries are used at low-level format
1818
	    time to determine the disk size.  1440kB is the size that will be
1819
	    used in the following examples.</para>
1820
1821
	  <para>Sometimes the entries under <filename>/dev</filename> will
1822
	    have to be (re)created.  To do that, issue:</para>
1823
1824
	  <screen>&prompt.root; <userinput>cd /dev &amp;&amp; ./MAKEDEV "fd*"</userinput></screen>
1825
	</sect4>
1826
1827
	<sect4>
1828
	  <title>The Disk Size in 5.0 and Newer Releases</title>
1829
1830
	  <para>In 5.0, &man.devfs.5; will automatically
1831
	    manage device nodes in <filename>/dev</filename>, so use of
1832
	    <command>MAKEDEV</command> is not necessary.</para>
1833
1834
	  <para>The desired disk size is passed to &man.fdformat.1; through
1835
	    the <option>-f</option> flag.  Supported sizes are listed in
1836
	  &man.fdcontrol.8;, but be advised that 1440kB is what works best.</para>
1837
	</sect4>
1838
      </sect3>
1733
      </sect3>
1839
1734
1840
      <sect3>
1735
      <sect3>
Lines 1854-1872 Link Here
1854
	    determine if the disk is good or bad.</para>
1749
	    determine if the disk is good or bad.</para>
1855
1750
1856
	<sect4>
1751
	<sect4>
1857
	  <title>Formatting in 4.X and Earlier Releases</title>
1752
	  <title>Formatting Floppy Disks</title>
1858
1859
	  <para>Use the
1860
	    <filename>/dev/fd<replaceable>N</replaceable>.<replaceable>size</replaceable></filename>
1861
	    devices to format the floppy.  Insert a new 3.5inch floppy
1862
	    disk in your drive and issue:</para>
1863
1864
	  <screen>&prompt.root; <userinput>/usr/sbin/fdformat /dev/fd0.1440</userinput></screen>
1865
1866
	</sect4>
1867
1868
	<sect4>
1869
	  <title>Formatting in 5.0 and Newer Releases</title>
1870
1753
1871
	  <para>Use the
1754
	  <para>Use the
1872
	    <filename>/dev/fd<replaceable>N</replaceable></filename>
1755
	    <filename>/dev/fd<replaceable>N</replaceable></filename>
Lines 1879-1886 Link Here
1879
      </sect3>
1762
      </sect3>
1880
    </sect2>
1763
    </sect2>
1881
1764
1882
1883
1884
    <sect2>
1765
    <sect2>
1885
      <title>The Disk Label</title>
1766
      <title>The Disk Label</title>
1886
1767
Lines 1894-1905 Link Here
1894
	floppy.  The geometry values for the disk label are listed in
1775
	floppy.  The geometry values for the disk label are listed in
1895
	<filename>/etc/disktab</filename>.</para>
1776
	<filename>/etc/disktab</filename>.</para>
1896
1777
1897
      <para>You can run now &man.disklabel.8; like so:</para>
1778
      <para>You can run now &man.bsdlabel.8; like so:</para>
1898
1779
1899
      <screen>&prompt.root; <userinput>/sbin/disklabel -B -r -w /dev/fd0 fd1440</userinput></screen>
1780
      <screen>&prompt.root; <userinput>/sbin/bsdlabel -B -r -w /dev/fd0 fd1440</userinput></screen>
1900
1781
1901
      <note><para>Since &os;&nbsp;5.1-RELEASE, the &man.bsdlabel.8;
1782
      <note><para>Since &os;&nbsp;5.1-RELEASE, the &man.bsdlabel.8;
1902
	utility replaces the old &man.disklabel.8; program.  With
1783
	utility replaces the old &man.bsdlabel.8; program.  With
1903
	&man.bsdlabel.8; a number of obsolete options and parameters
1784
	&man.bsdlabel.8; a number of obsolete options and parameters
1904
	have been retired; in the example above the option
1785
	have been retired; in the example above the option
1905
	<option>-r</option> should be removed.  For more
1786
	<option>-r</option> should be removed.  For more
Lines 1931-1939 Link Here
1931
    <sect2>
1812
    <sect2>
1932
      <title>Using the Floppy</title>
1813
      <title>Using the Floppy</title>
1933
1814
1934
      <para>To use the floppy, mount it with &man.mount.msdos.8; (in
1815
      <para>To use the floppy, mount it with &man.mount.msdos.8;. One can also use
1935
	4.X and earlier releases) or &man.mount.msdosfs.8; (in 5.0 or
1936
	newer releases).  One can also use
1937
	<filename role="package">emulators/mtools</filename> from the ports
1816
	<filename role="package">emulators/mtools</filename> from the ports
1938
	collection.</para>
1817
	collection.</para>
1939
    </sect2>
1818
    </sect2>
Lines 2607-2617 Link Here
2607
	<para>There are only four steps that you need to perform in
2486
	<para>There are only four steps that you need to perform in
2608
	  preparation for any disaster that may occur.</para>
2487
	  preparation for any disaster that may occur.</para>
2609
	<indexterm>
2488
	<indexterm>
2610
    <primary><command>disklabel</command></primary>
2489
    <primary><command>bsdlabel</command></primary>
2611
  </indexterm>
2490
  </indexterm>
2612
2491
2613
	<para>First, print the disklabel from each of your disks
2492
	<para>First, print the bsdlabel from each of your disks
2614
	  (e.g. <command>disklabel da0 | lpr</command>), your file system table
2493
	  (e.g. <command>bsdlabel da0 | lpr</command>), your file system table
2615
	  (<filename>/etc/fstab</filename>) and all boot messages,
2494
	  (<filename>/etc/fstab</filename>) and all boot messages,
2616
	  two copies of
2495
	  two copies of
2617
	  each.</para>
2496
	  each.</para>
Lines 2627-2633 Link Here
2627
	<para>Otherwise, you have to create two custom bootable
2506
	<para>Otherwise, you have to create two custom bootable
2628
	  floppies which have a kernel that can mount all of your disks
2507
	  floppies which have a kernel that can mount all of your disks
2629
	  and access your tape drive.  These floppies must contain:
2508
	  and access your tape drive.  These floppies must contain:
2630
	  <command>fdisk</command>, <command>disklabel</command>,
2509
	  <command>fdisk</command>, <command>bsdlabel</command>,
2631
	  <command>newfs</command>, <command>mount</command>, and
2510
	  <command>newfs</command>, <command>mount</command>, and
2632
	  whichever backup program you use.  These programs must be
2511
	  whichever backup program you use.  These programs must be
2633
	  statically linked.  If you use <command>dump</command>, the
2512
	  statically linked.  If you use <command>dump</command>, the
Lines 2674-2680 Link Here
2674
2553
2675
# place boot blocks on the floppy
2554
# place boot blocks on the floppy
2676
#
2555
#
2677
disklabel -w -B /dev/fd0c fd1440
2556
bsdlabel -w -B /dev/fd0c fd1440
2678
2557
2679
#
2558
#
2680
# newfs the one and only partition
2559
# newfs the one and only partition
Lines 2848-2861 Link Here
2848
  </indexterm>
2727
  </indexterm>
2849
	<indexterm><primary>root partition</primary></indexterm>
2728
	<indexterm><primary>root partition</primary></indexterm>
2850
	<indexterm>
2729
	<indexterm>
2851
    <primary><command>disklabel</command></primary>
2730
    <primary><command>bsdlabel</command></primary>
2852
  </indexterm>
2731
  </indexterm>
2853
	<indexterm>
2732
	<indexterm>
2854
    <primary><command>newfs</command></primary>
2733
    <primary><command>newfs</command></primary>
2855
  </indexterm>
2734
  </indexterm>
2856
	<para>Try to <command>mount</command> (e.g. <command>mount /dev/da0a
2735
	<para>Try to <command>mount</command> (e.g. <command>mount /dev/da0a
2857
	    /mnt</command>)  the root partition of your first disk.  If the
2736
	    /mnt</command>)  the root partition of your first disk.  If the
2858
	  disklabel was damaged, use <command>disklabel</command> to re-partition and
2737
	  bsdlabel was damaged, use <command>bsdlabel</command> to re-partition and
2859
	  label the disk to match the label that you printed and saved.  Use
2738
	  label the disk to match the label that you printed and saved.  Use
2860
	    <command>newfs</command> to re-create the file systems.  Re-mount the root
2739
	    <command>newfs</command> to re-create the file systems.  Re-mount the root
2861
	  partition of the floppy read-write (<command>mount -u -o rw
2740
	  partition of the floppy read-write (<command>mount -u -o rw
Lines 2920-2992 Link Here
2920
      memory-based file systems.</para>
2799
      memory-based file systems.</para>
2921
2800
2922
    <note>
2801
    <note>
2923
      <para>The FreeBSD&nbsp;4.X users will have to use &man.MAKEDEV.8;
2802
      <para>Use &man.devfs.5; to allocate device nodes transparently for the
2924
	to create the required devices.  FreeBSD&nbsp;5.0 and later use
2925
	&man.devfs.5; to allocate device nodes transparently for the
2926
	user.</para>
2803
	user.</para>
2927
    </note>
2804
    </note>
2928
2805
2929
    <sect2 id="disks-vnconfig">
2930
      <title>File-Backed File System under FreeBSD&nbsp;4.X</title>
2931
      <indexterm>
2932
        <primary>disks</primary>
2933
        <secondary>file-backed (4.X)</secondary>
2934
      </indexterm>
2935
2936
      <para>The utility &man.vnconfig.8; configures and enables vnode pseudo-disk
2937
	devices.  A <firstterm>vnode</firstterm> is a representation
2938
	of a file, and is the focus of file activity.  This means that
2939
	&man.vnconfig.8; uses files to create and operate a
2940
	file system.  One possible use is the mounting of floppy or CD
2941
	images kept in files.</para>
2942
2943
      <para>To use &man.vnconfig.8;, you need &man.vn.4; support in your
2944
	kernel configuration file:</para>
2945
2946
      <programlisting>pseudo-device vn</programlisting>
2947
2948
      <para>To mount an existing file system image:</para>
2949
2950
      <example>
2951
	<title>Using vnconfig to Mount an Existing File System
2952
	  Image under FreeBSD&nbsp;4.X</title>
2953
2954
	<screen>&prompt.root; <userinput>vnconfig vn<replaceable>0</replaceable> <replaceable>diskimage</replaceable></userinput>
2955
&prompt.root; <userinput>mount /dev/vn<replaceable>0</replaceable>c <replaceable>/mnt</replaceable></userinput></screen>
2956
      </example>
2957
2958
      <para>To create a new file system image with &man.vnconfig.8;:</para>
2959
2960
      <example>
2961
	<title>Creating a New File-Backed Disk with <command>vnconfig</command></title>
2962
2963
	<screen>&prompt.root; <userinput>dd if=/dev/zero of=<replaceable>newimage</replaceable> bs=1k count=<replaceable>5</replaceable>k</userinput>
2964
5120+0 records in
2965
5120+0 records out
2966
&prompt.root; <userinput>vnconfig -s labels -c vn<replaceable>0</replaceable> <replaceable>newimage</replaceable></userinput>
2967
&prompt.root; <userinput>disklabel -r -w vn<replaceable>0</replaceable> auto</userinput>
2968
&prompt.root; <userinput>newfs vn<replaceable>0</replaceable>c</userinput>
2969
Warning: 2048 sector(s) in last cylinder unallocated
2970
/dev/vn0c:     10240 sectors in 3 cylinders of 1 tracks, 4096 sectors
2971
        5.0MB in 1 cyl groups (16 c/g, 32.00MB/g, 1280 i/g)
2972
super-block backups (for fsck -b #) at:
2973
 32
2974
&prompt.root; <userinput>mount /dev/vn<replaceable>0</replaceable>c <replaceable>/mnt</replaceable></userinput>
2975
&prompt.root; <userinput>df <replaceable>/mnt</replaceable></userinput>
2976
Filesystem  1K-blocks     Used    Avail Capacity  Mounted on
2977
/dev/vn0c        4927        1     4532     0%    /mnt</screen>
2978
      </example>
2979
    </sect2>
2980
2981
    <sect2 id="disks-mdconfig">
2806
    <sect2 id="disks-mdconfig">
2982
      <title>File-Backed File System under FreeBSD&nbsp;5.X</title>
2807
      <title>File-Backed File System</title>
2983
      <indexterm>
2808
      <indexterm>
2984
        <primary>disks</primary>
2809
        <primary>disks</primary>
2985
        <secondary>file-backed (5.X)</secondary>
2810
        <secondary>file-backed</secondary>
2986
      </indexterm>
2811
      </indexterm>
2987
2812
2988
      <para>The utility &man.mdconfig.8; is used to configure and enable
2813
      <para>The utility &man.mdconfig.8; is used to configure and enable
2989
	memory disks, &man.md.4;, under FreeBSD&nbsp;5.X.  To use
2814
	memory disks, &man.md.4;, under FreeBSD.  To use
2990
	&man.mdconfig.8;, you have to load &man.md.4; module or to add
2815
	&man.mdconfig.8;, you have to load &man.md.4; module or to add
2991
	the support in your kernel configuration file:</para>
2816
	the support in your kernel configuration file:</para>
2992
2817
Lines 3002-3008 Link Here
3002
2827
3003
      <example>
2828
      <example>
3004
	<title>Using <command>mdconfig</command> to Mount an Existing File System
2829
	<title>Using <command>mdconfig</command> to Mount an Existing File System
3005
	  Image under FreeBSD&nbsp;5.X</title>
2830
	  Image</title>
3006
2831
3007
	<screen>&prompt.root; <userinput>mdconfig -a -t vnode -f <replaceable>diskimage</replaceable> -u <replaceable>0</replaceable></userinput>
2832
	<screen>&prompt.root; <userinput>mdconfig -a -t vnode -f <replaceable>diskimage</replaceable> -u <replaceable>0</replaceable></userinput>
3008
&prompt.root; <userinput>mount /dev/md<replaceable>0</replaceable> <replaceable>/mnt</replaceable></userinput></screen>
2833
&prompt.root; <userinput>mount /dev/md<replaceable>0</replaceable> <replaceable>/mnt</replaceable></userinput></screen>
Lines 3017-3032 Link Here
3017
5120+0 records in
2842
5120+0 records in
3018
5120+0 records out
2843
5120+0 records out
3019
&prompt.root; <userinput>mdconfig -a -t vnode -f <replaceable>newimage</replaceable> -u <replaceable>0</replaceable></userinput>
2844
&prompt.root; <userinput>mdconfig -a -t vnode -f <replaceable>newimage</replaceable> -u <replaceable>0</replaceable></userinput>
3020
&prompt.root; <userinput>disklabel -r -w md<replaceable>0</replaceable> auto</userinput>
2845
&prompt.root; <userinput>bsdlabel -w md<replaceable>0</replaceable> auto</userinput>
3021
&prompt.root; <userinput>newfs md<replaceable>0</replaceable>c</userinput>
2846
&prompt.root; <userinput>newfs md<replaceable>0</replaceable>a</userinput>
3022
/dev/md0c: 5.0MB (10240 sectors) block size 16384, fragment size 2048
2847
/dev/md0a: 5.0MB (10224 sectors) block size 16384, fragment size 2048
3023
	using 4 cylinder groups of 1.27MB, 81 blks, 256 inodes.
2848
        using 4 cylinder groups of 1.25MB, 80 blks, 192 inodes.
3024
super-block backups (for fsck -b #) at:
2849
super-block backups (for fsck -b #) at:
3025
 32, 2624, 5216, 7808
2850
 160, 2720, 5280, 7840
3026
&prompt.root; <userinput>mount /dev/md<replaceable>0</replaceable>c <replaceable>/mnt</replaceable></userinput>
2851
&prompt.root; <userinput>mount /dev/md<replaceable>0</replaceable>a <replaceable>/mnt</replaceable></userinput>
3027
&prompt.root; <userinput>df <replaceable>/mnt</replaceable></userinput>
2852
&prompt.root; <userinput>df <replaceable>/mnt</replaceable></userinput>
3028
Filesystem  1K-blocks     Used    Avail Capacity  Mounted on
2853
Filesystem 1K-blocks Used Avail Capacity  Mounted on
3029
/dev/md0c        4846        2     4458     0%    /mnt</screen>
2854
/dev/md0a       4710    4  4330     0%    /mnt</screen>
3030
      </example>
2855
      </example>
3031
2856
3032
      <para>If you do not specify the unit number with the
2857
      <para>If you do not specify the unit number with the
Lines 3036-3052 Link Here
3036
	<devicename>md4</devicename>.  For more details about
2861
	<devicename>md4</devicename>.  For more details about
3037
	&man.mdconfig.8;, please refer to the manual page.</para>
2862
	&man.mdconfig.8;, please refer to the manual page.</para>
3038
2863
3039
      <note><para>Since &os;&nbsp;5.1-RELEASE, the &man.bsdlabel.8;
3040
	utility replaces the old &man.disklabel.8; program.  With
3041
	&man.bsdlabel.8; a number of obsolete options and parameters
3042
	have been retired; in the example above the option
3043
	<option>-r</option> should be removed.  For more
3044
	information, please refer to the &man.bsdlabel.8;
3045
	manual page.</para></note>
3046
3047
      <para>The utility &man.mdconfig.8; is very useful, however it
2864
      <para>The utility &man.mdconfig.8; is very useful, however it
3048
	asks many command lines to create a file-backed file system.
2865
	asks many command lines to create a file-backed file system.
3049
	FreeBSD&nbsp;5.0 also comes with a tool called &man.mdmfs.8;,
2866
	FreeBSD also comes with a tool called &man.mdmfs.8;,
3050
	this program configures a &man.md.4; disk using
2867
	this program configures a &man.md.4; disk using
3051
	&man.mdconfig.8;, puts a UFS file system on it using
2868
	&man.mdconfig.8;, puts a UFS file system on it using
3052
	&man.newfs.8;, and mounts it using &man.mount.8;.  For example,
2869
	&man.newfs.8;, and mounts it using &man.mount.8;.  For example,
Lines 3061-3067 Link Here
3061
&prompt.root; <userinput>mdmfs -F <replaceable>newimage</replaceable> -s <replaceable>5</replaceable>m md<replaceable>0</replaceable> <replaceable>/mnt</replaceable></userinput>
2878
&prompt.root; <userinput>mdmfs -F <replaceable>newimage</replaceable> -s <replaceable>5</replaceable>m md<replaceable>0</replaceable> <replaceable>/mnt</replaceable></userinput>
3062
&prompt.root; <userinput>df <replaceable>/mnt</replaceable></userinput>
2879
&prompt.root; <userinput>df <replaceable>/mnt</replaceable></userinput>
3063
Filesystem 1K-blocks Used Avail Capacity  Mounted on
2880
Filesystem 1K-blocks Used Avail Capacity  Mounted on
3064
/dev/md0        4846    2  4458     0%    /mnt</screen>
2881
/dev/md0        4718    4  4338     0%    /mnt</screen>
3065
      </example>
2882
      </example>
3066
2883
3067
      <para>If you use the option <option>md</option> without unit
2884
      <para>If you use the option <option>md</option> without unit
Lines 3071-3117 Link Here
3071
2888
3072
    </sect2>
2889
    </sect2>
3073
2890
3074
    <sect2 id="disks-md-freebsd4">
3075
      <title>Memory-Based File System under FreeBSD&nbsp;4.X</title>
3076
      <indexterm>
3077
        <primary>disks</primary>
3078
        <secondary>memory file system (4.X)</secondary>
3079
      </indexterm>
3080
3081
      <para>The &man.md.4; driver is a simple, efficient means to create memory
3082
	file systems under FreeBSD&nbsp;4.X. &man.malloc.9; is used
3083
	to allocate the memory.</para>
3084
3085
      <para>Simply take a file system you have prepared with, for
3086
	example, &man.vnconfig.8;, and:</para>
3087
3088
      <example>
3089
	<title>md Memory Disk under FreeBSD&nbsp;4.X</title>
3090
3091
	<screen>&prompt.root; <userinput>dd if=<replaceable>newimage</replaceable> of=/dev/md<replaceable>0</replaceable></userinput>
3092
5120+0 records in
3093
5120+0 records out
3094
&prompt.root; <userinput>mount /dev/md<replaceable>0c</replaceable> <replaceable>/mnt</replaceable></userinput>
3095
&prompt.root; <userinput>df <replaceable>/mnt</replaceable></userinput>
3096
Filesystem  1K-blocks     Used    Avail Capacity  Mounted on
3097
/dev/md0c        4927        1     4532     0%    /mnt</screen>
3098
      </example>
3099
3100
      <para>For more details, please refer to &man.md.4; manual
3101
	page.</para>
3102
    </sect2>
3103
3104
    <sect2 id="disks-md-freebsd5">
2891
    <sect2 id="disks-md-freebsd5">
3105
      <title>Memory-Based File System under FreeBSD&nbsp;5.X</title>
2892
      <title>Memory-Based File System</title>
3106
      <indexterm>
2893
      <indexterm>
3107
        <primary>disks</primary>
2894
        <primary>disks</primary>
3108
        <secondary>memory file system (5.X)</secondary>
2895
        <secondary>memory file system</secondary>
3109
      </indexterm>
2896
      </indexterm>
3110
2897
3111
      <para>The same tools are used for memory-based and file-backed
2898
      <para>For a
3112
	file systems: &man.mdconfig.8; or &man.mdmfs.8;.  The storage
2899
	memory-based file system the <quote>swap backing</quote>
3113
	for memory-based file system is allocated with
2900
	should normally be used.  Using swap backing does not mean
3114
	&man.malloc.9;.</para>
2901
	that the memory disk will be swapped out to disk by default,
2902
	but merely that the memory disk will be allocated from a
2903
	memory pool which can be swapped out to disk if needed.  It is
2904
	also possible to create memory-based disk which are
2905
	&man.malloc.9; backed, but using malloc backed memory disks,
2906
	especially large ones, can result in a system panic if the
2907
	kernel runs out of memory.</para>
3115
2908
3116
      <example>
2909
      <example>
3117
	<title>Creating a New Memory-Based Disk with
2910
	<title>Creating a New Memory-Based Disk with
Lines 3170-3182 Link Here
3170
	&man.md.4; devices in using the command <command>mdconfig
2963
	&man.md.4; devices in using the command <command>mdconfig
3171
	-l</command>.</para>
2964
	-l</command>.</para>
3172
2965
3173
      <para>For FreeBSD&nbsp;4.X, &man.vnconfig.8; is used to detach
3174
	the device.  For example to detach and free all resources
3175
	used by <filename>/dev/vn4</filename>:</para>
3176
3177
      <screen>&prompt.root; <userinput>vnconfig -u vn<replaceable>4</replaceable></userinput></screen>
3178
3179
3180
    </sect2>
2966
    </sect2>
3181
  </sect1>
2967
  </sect1>
3182
2968
Lines 3199-3205 Link Here
3199
      <secondary>snapshots</secondary>
2985
      <secondary>snapshots</secondary>
3200
    </indexterm>
2986
    </indexterm>
3201
2987
3202
      <para>FreeBSD&nbsp;5.0 offers a new feature in conjunction with
2988
      <para>FreeBSD offers a feature in conjunction with
3203
	<link linkend="soft-updates">Soft Updates</link>: File system snapshots.</para>
2989
	<link linkend="soft-updates">Soft Updates</link>: File system snapshots.</para>
3204
2990
3205
      <para>Snapshots allow a user to create images of specified file
2991
      <para>Snapshots allow a user to create images of specified file
Lines 3594-3608 Link Here
3594
	</step>
3380
	</step>
3595
3381
3596
	<step>
3382
	<step>
3597
	  <title>Verify the Operating System Version</title>
3598
3599
	  <para>&man.gbde.4; requires FreeBSD 5.0 or higher.</para>
3600
3601
	  <screen>&prompt.root; <userinput>uname -r</userinput>
3602
5.0-RELEASE</screen>
3603
	</step>
3604
3605
	<step>
3606
	  <title>Add &man.gbde.4; Support to the Kernel Configuration File</title>
3383
	  <title>Add &man.gbde.4; Support to the Kernel Configuration File</title>
3607
3384
3608
	  <para>Add the following line to the kernel configuration
3385
	  <para>Add the following line to the kernel configuration
Lines 3742-3750 Link Here
3742
	    initialize the old UFS1 file system, using &man.newfs.8; with
3519
	    initialize the old UFS1 file system, using &man.newfs.8; with
3743
	    the <option>-O2</option> option is recommended.</para>
3520
	    the <option>-O2</option> option is recommended.</para>
3744
3521
3745
	  <note><para>The <option>-O2</option> option is the default
3746
	  with &os;&nbsp;5.1-RELEASE and later.</para></note>
3747
3748
	  <screen>&prompt.root; <userinput>newfs -U -O2 /dev/ad4s1c.bde</userinput></screen>
3522
	  <screen>&prompt.root; <userinput>newfs -U -O2 /dev/ad4s1c.bde</userinput></screen>
3749
3523
3750
	  <note>
3524
	  <note>
Lines 4100-4105 Link Here
4100
      </sect3>
3874
      </sect3>
4101
    </sect2>	
3875
    </sect2>	
4102
  </sect1>
3876
  </sect1>
3877
3878
3879
  <sect1 id="swap-encrypting">
3880
    <sect1info>
3881
      <authorgroup>
3882
	<author>
3883
	  <firstname>Christian</firstname>
3884
	  <surname>Br&uuml;ffer</surname>
3885
	  <contrib>Written by </contrib>
3886
	</author>
3887
      </authorgroup>
3888
    </sect1info>
3889
3890
    <title>Encrypting Swap Space</title>
3891
    <indexterm>
3892
      <primary>swap</primary>
3893
      <secondary>encrypting</secondary>
3894
    </indexterm>
3895
3896
    <para>Swap encryption in &os; is easy to configure and has been
3897
      available since &os; 5.3-RELEASE.  Depending on which version
3898
      of &os; is being used, different options are available
3899
      and configuration can vary slightly.  From &os; 6.0-RELEASE onwards,
3900
      the &man.gbde.8; or &man.geli.8; encryption systems can be used
3901
      for swap encryption.  With earlier versions, only &man.gbde.8; is
3902
      available.  Both systems use the <filename>encswap</filename>
3903
      <link linkend="configtuning-rcd">rc.d</link> script.</para>
3904
3905
    <para>The previous section, <link linkend="disks-encrypting">Encrypting
3906
      Disk Partitions</link>, includes a short discussion on the different
3907
      encryption systems.</para>
3908
3909
    <sect2>
3910
      <title>Why should Swap be Encrypted?</title>
3911
3912
      <para>Like the encryption of disk partitions, encryption of swap space
3913
	is done to protect sensitive information.  Imagine an application
3914
	that e.g. deals with passwords.  As long as these passwords stay in
3915
	physical memory, all is well.  However, if the operating system starts
3916
	swapping out memory pages to free space for other applications, the
3917
	passwords may be written to the disk platters unencrypted and easy to
3918
	retrieve for an adversary.  Encrypting swap space can be a solution for
3919
	this scenario.</para>
3920
    </sect2>
3921
3922
    <sect2>
3923
      <title>Preparation</title>
3924
3925
      <note>
3926
	<para>For the remainder of this section, <devicename>ad0s1b</devicename>
3927
	  will be the swap partition.</para>
3928
      </note>
3929
3930
      <para>Up to this point the swap has been unencrypted.  It is possible that
3931
	there are already passwords or other sensitive data on the disk platters
3932
	in cleartext.  To rectify this, the data on the swap partition should be
3933
	overwritten with random garbage:</para>
3934
3935
      <screen>&prompt.root; <userinput>dd if=/dev/random of=/dev/ad0s1b bs=1m</userinput></screen>
3936
    </sect2>
3937
3938
    <sect2>
3939
      <title>Swap Encryption with &man.gbde.8;</title>
3940
3941
      <para>If &os; 6.0-RELEASE or newer is being used, the
3942
	<literal>.bde</literal> suffix should be added to the device in the
3943
	respective <filename>/etc/fstab</filename> swap line:</para>
3944
3945
      <screen>
3946
# Device                Mountpoint      FStype  Options         Dump    Pass#
3947
/dev/ad0s1b.bde         none            swap    sw              0       0
3948
      </screen>
3949
3950
      <para>For systems prior to &os; 6.0-RELEASE, the following line
3951
	in <filename>/etc/rc.conf</filename> is also needed:</para>
3952
3953
      <programlisting>gbde_swap_enable="YES"</programlisting>
3954
    </sect2>
3955
3956
    <sect2>
3957
      <title>Swap Encryption with &man.geli.8;</title>
3958
3959
      <para>Alternatively, the procedure for using &man.geli.8; for swap
3960
	encryption is similar to that of using &man.gbde.8;.  The
3961
	<literal>.eli</literal> suffix should be added to the device in the
3962
	respective <filename>/etc/fstab</filename> swap line:</para>
3963
3964
      <screen>
3965
# Device                Mountpoint      FStype  Options         Dump    Pass#
3966
/dev/ad0s1b.eli         none            swap    sw              0       0
3967
      </screen>
3968
3969
      <para>&man.geli.8; uses the <acronym>AES</acronym> algorithm with
3970
	a key length of 256 bit by default.</para>
3971
3972
      <para>Optionally, these defaults can be altered using the
3973
	<literal>geli_swap_flags</literal> option in
3974
	<filename>/etc/rc.conf</filename>.  The following line tells the
3975
	<filename>encswap</filename> rc.d script to create &man.geli.8; swap
3976
	partitions using the Blowfish algorithm with a key length of 128 bit,
3977
	a sectorsize of 4 kilobytes and the <quote>detach on last close</quote>
3978
	option set:</para>
3979
3980
      <programlisting>geli_swap_flags="-a blowfish -l 128 -s 4096 -d"</programlisting>
3981
3982
      <para>Please refer to the description of the <command>onetime</command> command
3983
	in the &man.geli.8; manual page for a list of possible options.</para>
3984
    </sect2>
3985
3986
    <sect2>
3987
      <title>Verifying that it Works</title>
3988
3989
      <para>Once the system has been rebooted, proper operation of the
3990
	encrypted swap can be verified using the
3991
	<command>swapinfo</command> command.</para>
3992
3993
      <para>If &man.gbde.8; is being used:</para>
3994
3995
      <screen>&prompt.user; <userinput>swapinfo</userinput>
3996
Device          1K-blocks     Used    Avail Capacity
3997
/dev/ad0s1b.bde    542720        0   542720     0%
3998
      </screen>
3999
4000
      <para>If &man.geli.8; is being used:</para>
4001
4002
      <screen>&prompt.user; <userinput>swapinfo</userinput>
4003
Device          1K-blocks     Used    Avail Capacity
4004
/dev/ad0s1b.eli    542720        0   542720     0%
4005
      </screen>
4006
    </sect2>
4007
  </sect1>
4103
</chapter>
4008
</chapter>
4104
4009
4105
<!--
4010
<!--

Return to bug 99992