Editorial review of Attaching and Detaching Existing Images.
More commits to come to finish review of this chapter. Sponsored by: iXsystems
This commit is contained in:
parent
2bb2a3da35
commit
b66ddefad8
Notes:
svn2git
2020-12-08 03:00:23 +00:00
svn path=/head/; revision=44647
1 changed files with 74 additions and 83 deletions
|
@ -1989,44 +1989,67 @@ scsibus1:
|
|||
</info>
|
||||
|
||||
<para>In addition to physical disks, &os; also supports
|
||||
the creation and use of memory disks.</para>
|
||||
the creation and use of memory disks. One possible use for a
|
||||
memory disk is to access the contents of an
|
||||
<acronym>ISO</acronym> file system without the overhead of first
|
||||
burning it to a <acronym>CD</acronym> or <acronym>DVD</acronym>,
|
||||
then mounting the <acronym>CD/DVD</acronym> media.</para>
|
||||
|
||||
<para>In &os;, the &man.md.4; driver is used to provide support
|
||||
for memory disks. The <filename>GENERIC</filename> kernel
|
||||
includes this driver. When using a custom kernel
|
||||
configuration file, ensure it includes this line:</para>
|
||||
|
||||
<indexterm>
|
||||
<primary>disks</primary>
|
||||
<secondary>memory</secondary>
|
||||
</indexterm>
|
||||
<programlisting>device md</programlisting>
|
||||
|
||||
<sect2 xml:id="disks-mdconfig">
|
||||
<title>Attaching and Detaching Existing Images</title>
|
||||
|
||||
<indexterm>
|
||||
<primary>disks</primary>
|
||||
<secondary>file-backed</secondary>
|
||||
<secondary>memory</secondary>
|
||||
</indexterm>
|
||||
|
||||
<para>&man.mdconfig.8; is used to configure and enable memory
|
||||
disks, &man.md.4;, under &os;. To use &man.mdconfig.8;,
|
||||
&man.md.4; must be first loaded. When using a custom kernel
|
||||
configuration file, ensure it includes this line:</para>
|
||||
|
||||
<programlisting>device md</programlisting>
|
||||
|
||||
<para>&man.mdconfig.8; supports several types of memory backed
|
||||
virtual disks: memory disks allocated with &man.malloc.9; and
|
||||
memory disks using a file or swap space as backing. One
|
||||
possible use is the mounting of <acronym>CD</acronym>
|
||||
images.</para>
|
||||
|
||||
<para>To mount an existing file system image:</para>
|
||||
|
||||
<example>
|
||||
<title>Using <command>mdconfig</command> to Mount an Existing
|
||||
File System Image</title>
|
||||
<para>To mount an existing file system image, use
|
||||
<command>mdconfig</command> to specify the name of the
|
||||
<acronym>ISO</acronym> file and a free unit number. Then,
|
||||
refer to that unit number to mount it on an existing mount
|
||||
point. Once mounted, the files in the <acronym>ISO</acronym>
|
||||
will appear in the mount point. This example attaches
|
||||
<replaceable>diskimage.iso</replaceable> to the memory device
|
||||
<filename>/dev/md0</filename> then mounts that memory device
|
||||
on <filename>/mnt</filename>:</para>
|
||||
|
||||
<screen>&prompt.root; <userinput>mdconfig -f <replaceable>diskimage.iso</replaceable> -u <replaceable>0</replaceable></userinput>
|
||||
&prompt.root; <userinput>mount /dev/md<replaceable>0</replaceable> <replaceable>/mnt</replaceable></userinput></screen>
|
||||
</example>
|
||||
|
||||
<para>If a unit number is not specified with
|
||||
<option>-u</option>, <command>mdconfig</command> will
|
||||
automatically allocate an unused memory device and output
|
||||
the name of the allocated unit, such
|
||||
as <filename>md4</filename>. Refer to &man.mdconfig.8;
|
||||
for more details about this command and its options.</para>
|
||||
|
||||
<para>When a memory disk is no
|
||||
longer in use, its resources should be released back to
|
||||
the system. First, unmount the file system, then use
|
||||
<command>mdconfig</command> to detach the disk from the system and
|
||||
release its resources. To continue this example:</para>
|
||||
|
||||
<screen>&prompt.root; <userinput>umount /mnt</userinput>
|
||||
&prompt.root; <userinput>mdconfig -d -u <replaceable>0</replaceable></userinput></screen>
|
||||
|
||||
<para>To determine if any memory disks are still attached to the
|
||||
system, type <command>mdconfig -l</command>.</para>
|
||||
</sect2>
|
||||
|
||||
<sect2 xml:id="disks-md-freebsd5">
|
||||
<title>Creating a Memory Disk</title>
|
||||
|
||||
<indexterm>
|
||||
<primary>disks</primary>
|
||||
<secondary>memory file system</secondary>
|
||||
</indexterm>
|
||||
<para>To create a new file system image with
|
||||
&man.mdconfig.8;:</para>
|
||||
|
||||
|
@ -2050,12 +2073,32 @@ Filesystem 1K-blocks Used Avail Capacity Mounted on
|
|||
/dev/md0a 4710 4 4330 0% /mnt</screen>
|
||||
</example>
|
||||
|
||||
<para>If unit number is not specified with
|
||||
<option>-u</option>, &man.mdconfig.8; uses the
|
||||
&man.md.4; automatic allocation to select an unused device.
|
||||
The name of the allocated unit will be output to stdout, such
|
||||
as <filename>md4</filename>. Refer to &man.mdconfig.8;
|
||||
for more details about.</para>
|
||||
<para>For a memory-based file system, <quote>swap
|
||||
backing</quote> should normally be used. This does not mean
|
||||
that the memory disk will be swapped out to disk by default,
|
||||
but rather that the memory disk will be allocated from a
|
||||
memory pool which can be swapped out to disk if needed. It is
|
||||
also possible to create memory-based disks which are
|
||||
&man.malloc.9; backed, but using large malloc backed memory
|
||||
disks can result in a system panic if the kernel runs out of
|
||||
memory.</para>
|
||||
|
||||
<example>
|
||||
<title>Creating a New Memory-Based Disk with
|
||||
<command>mdconfig</command></title>
|
||||
|
||||
<screen>&prompt.root; <userinput>mdconfig -a -t swap -s <replaceable>5</replaceable>m -u <replaceable>1</replaceable></userinput>
|
||||
&prompt.root; <userinput>newfs -U md<replaceable>1</replaceable></userinput>
|
||||
/dev/md1: 5.0MB (10240 sectors) block size 16384, fragment size 2048
|
||||
using 4 cylinder groups of 1.27MB, 81 blks, 192 inodes.
|
||||
with soft updates
|
||||
super-block backups (for fsck -b #) at:
|
||||
160, 2752, 5344, 7936
|
||||
&prompt.root; <userinput>mount /dev/md<replaceable>1</replaceable> <replaceable>/mnt</replaceable></userinput>
|
||||
&prompt.root; <userinput>df <replaceable>/mnt</replaceable></userinput>
|
||||
Filesystem 1K-blocks Used Avail Capacity Mounted on
|
||||
/dev/md1 4718 4 4338 0% /mnt</screen>
|
||||
</example>
|
||||
|
||||
<para>While &man.mdconfig.8; is useful, it takes several
|
||||
command lines to create a file-backed file system. &os; also
|
||||
|
@ -2087,58 +2130,6 @@ Filesystem 1K-blocks Used Avail Capacity Mounted on
|
|||
<primary>disks</primary>
|
||||
<secondary>detaching a memory disk</secondary>
|
||||
</indexterm>
|
||||
|
||||
<para>When a memory-based or file-based file system is no
|
||||
longer in use, its resources should be released back to
|
||||
the system. First, unmount the file system, then use
|
||||
&man.mdconfig.8; to detach the disk from the system and
|
||||
release the resources.</para>
|
||||
|
||||
<para>For example, to detach and free all resources used by
|
||||
<filename>/dev/md4</filename>:</para>
|
||||
|
||||
<screen>&prompt.root; <userinput>mdconfig -d -u <replaceable>4</replaceable></userinput></screen>
|
||||
|
||||
<para>It is possible to list information about configured
|
||||
&man.md.4; devices by running
|
||||
<command>mdconfig -l</command>.</para>
|
||||
</sect2>
|
||||
|
||||
<sect2 xml:id="disks-md-freebsd5">
|
||||
<title>Creating a Memory Disk</title>
|
||||
|
||||
<indexterm>
|
||||
<primary>disks</primary>
|
||||
<secondary>memory file system</secondary>
|
||||
</indexterm>
|
||||
|
||||
<para>For a memory-based file system, <quote>swap
|
||||
backing</quote> should normally be used. This does not mean
|
||||
that the memory disk will be swapped out to disk by default,
|
||||
but rather that the memory disk will be allocated from a
|
||||
memory pool which can be swapped out to disk if needed. It is
|
||||
also possible to create memory-based disks which are
|
||||
&man.malloc.9; backed, but using large malloc backed memory
|
||||
disks can result in a system panic if the kernel runs out of
|
||||
memory.</para>
|
||||
|
||||
<example>
|
||||
<title>Creating a New Memory-Based Disk with
|
||||
<command>mdconfig</command></title>
|
||||
|
||||
<screen>&prompt.root; <userinput>mdconfig -a -t swap -s <replaceable>5</replaceable>m -u <replaceable>1</replaceable></userinput>
|
||||
&prompt.root; <userinput>newfs -U md<replaceable>1</replaceable></userinput>
|
||||
/dev/md1: 5.0MB (10240 sectors) block size 16384, fragment size 2048
|
||||
using 4 cylinder groups of 1.27MB, 81 blks, 192 inodes.
|
||||
with soft updates
|
||||
super-block backups (for fsck -b #) at:
|
||||
160, 2752, 5344, 7936
|
||||
&prompt.root; <userinput>mount /dev/md<replaceable>1</replaceable> <replaceable>/mnt</replaceable></userinput>
|
||||
&prompt.root; <userinput>df <replaceable>/mnt</replaceable></userinput>
|
||||
Filesystem 1K-blocks Used Avail Capacity Mounted on
|
||||
/dev/md1 4718 4 4338 0% /mnt</screen>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<title>Creating a New Memory-Based Disk with
|
||||
<command>mdmfs</command></title>
|
||||
|
|
Loading…
Reference in a new issue