Date: Thu, 24 Apr 2014 19:51:56 +0000 (UTC) From: Dru Lavigne <dru@FreeBSD.org> To: doc-committers@freebsd.org, svn-doc-all@freebsd.org, svn-doc-head@freebsd.org Subject: svn commit: r44648 - head/en_US.ISO8859-1/books/handbook/disks Message-ID: <201404241951.s3OJpuC1007623@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dru Date: Thu Apr 24 19:51:56 2014 New Revision: 44648 URL: http://svnweb.freebsd.org/changeset/doc/44648 Log: Finish editorial review of Memory Disks chapter. Sponsored by: iXsystems Modified: head/en_US.ISO8859-1/books/handbook/disks/chapter.xml Modified: head/en_US.ISO8859-1/books/handbook/disks/chapter.xml ============================================================================== --- head/en_US.ISO8859-1/books/handbook/disks/chapter.xml Thu Apr 24 18:24:48 2014 (r44647) +++ head/en_US.ISO8859-1/books/handbook/disks/chapter.xml Thu Apr 24 19:51:56 2014 (r44648) @@ -2030,6 +2030,11 @@ scsibus1: as <filename>md4</filename>. Refer to &man.mdconfig.8; for more details about this command and its options.</para> + <indexterm> + <primary>disks</primary> + <secondary>detaching a memory disk</secondary> + </indexterm> + <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 @@ -2044,48 +2049,26 @@ scsibus1: </sect2> <sect2 xml:id="disks-md-freebsd5"> - <title>Creating a Memory Disk</title> + <title>Creating a File- or Memory-Backed 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> - - <example> - <title>Creating a New File-Backed Disk with - <command>mdconfig</command></title> - - <screen>&prompt.root; <userinput>dd if=/dev/zero of=<replaceable>newimage</replaceable> bs=1k count=<replaceable>5</replaceable>k</userinput> -5120+0 records in -5120+0 records out -&prompt.root; <userinput>mdconfig -a -t vnode -f <replaceable>newimage</replaceable> -u <replaceable>0</replaceable></userinput> -&prompt.root; <userinput>bsdlabel -w md<replaceable>0</replaceable> auto</userinput> -&prompt.root; <userinput>newfs md<replaceable>0</replaceable>a</userinput> -/dev/md0a: 5.0MB (10224 sectors) block size 16384, fragment size 2048 - using 4 cylinder groups of 1.25MB, 80 blks, 192 inodes. -super-block backups (for fsck -b #) at: - 160, 2720, 5280, 7840 -&prompt.root; <userinput>mount /dev/md<replaceable>0</replaceable>a <replaceable>/mnt</replaceable></userinput> -&prompt.root; <userinput>df <replaceable>/mnt</replaceable></userinput> -Filesystem 1K-blocks Used Avail Capacity Mounted on -/dev/md0a 4710 4 4330 0% /mnt</screen> - </example> - - <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> + <para>&os; also supports memory disks where the storage to use + is allocated from either a hard disk or an area of memory. + The first method is commonly referred to as a file-backed file + system and the second method as a memory-backed file system. + Both types can be created using + <command>mdconfig</command>.</para> + + <para>To create a new memory-backed file system, specify a type + of <literal>swap</literal> and the size of the memory disk to + create. Then, format the memory disk with a file system and + mount as usual. This example creates a 5M memory disk on unit + <literal>1</literal>. That memory disk is then formatted with + the <acronym>UFS</acronym> file system before it is + mounted:</para> <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> @@ -2098,47 +2081,55 @@ super-block backups (for fsck -b #) at: &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 - comes with &man.mdmfs.8; which automatically configures a - &man.md.4; disk using &man.mdconfig.8;, puts a UFS file system - on it using &man.newfs.8;, and mounts it using &man.mount.8;. - For example, to create and mount the same file system image as - above, type the following:</para> - - <example> - <title>Configure and Mount a File-Backed Disk with - <command>mdmfs</command></title> + <para> + To create a new file-backed memory disk, first allocate an + area of disk to use. This example creates an empty 5K file + named <filename>newimage</filename>:</para> <screen>&prompt.root; <userinput>dd if=/dev/zero of=<replaceable>newimage</replaceable> bs=1k count=<replaceable>5</replaceable>k</userinput> 5120+0 records in -5120+0 records out -&prompt.root; <userinput>mdmfs -F <replaceable>newimage</replaceable> -s <replaceable>5</replaceable>m md<replaceable>0</replaceable> <replaceable>/mnt</replaceable></userinput> -&prompt.root; <userinput>df <replaceable>/mnt</replaceable></userinput> -Filesystem 1K-blocks Used Avail Capacity Mounted on -/dev/md0 4718 4 4338 0% /mnt</screen> - </example> - - <para>When <option>md</option> is used without a unit number, - &man.mdmfs.8; uses the &man.md.4; auto-unit feature to - automatically select an unused device. For more details - about &man.mdmfs.8;, refer to its manual page.</para> - - <indexterm> - <primary>disks</primary> - <secondary>detaching a memory disk</secondary> - </indexterm> - <example> - <title>Creating a New Memory-Based Disk with - <command>mdmfs</command></title> +5120+0 records out</screen> - <screen>&prompt.root; <userinput>mdmfs -s <replaceable>5</replaceable>m md<replaceable>2</replaceable> <replaceable>/mnt</replaceable></userinput> + <para>Next, attach that file to a memory disk, label the memory + disk and format it with the <acronym>UFS</acronym> file + system, mount the memory disk, and verify the size of the + file-backed disk:</para> + + <screen>&prompt.root; <userinput>mdconfig -f <replaceable>newimage</replaceable> -u <replaceable>0</replaceable></userinput> +&prompt.root; <userinput>bsdlabel -w md<replaceable>0</replaceable> auto</userinput> +&prompt.root; <userinput>newfs md<replaceable>0</replaceable>a</userinput> +/dev/md0a: 5.0MB (10224 sectors) block size 16384, fragment size 2048 + using 4 cylinder groups of 1.25MB, 80 blks, 192 inodes. +super-block backups (for fsck -b #) at: + 160, 2720, 5280, 7840 +&prompt.root; <userinput>mount /dev/md<replaceable>0</replaceable>a <replaceable>/mnt</replaceable></userinput> &prompt.root; <userinput>df <replaceable>/mnt</replaceable></userinput> Filesystem 1K-blocks Used Avail Capacity Mounted on -/dev/md2 4846 2 4458 0% /mnt</screen> - </example> +/dev/md0a 4710 4 4330 0% /mnt</screen> + + <para>It takes several commands to create a file- or memory-backed file + system using <command>mdconfig</command>. &os; also + comes with <command>mdmfs</command> which automatically configures a + memory disk, formats it with the <acronym>UFS</acronym> file system, + and mounts it. For example, after creating + <replaceable>newimage</replaceable> with + <command>dd</command>, this one command is equivalent to + running the <command>bsdlabel</command>, + <command>newfs</command>, and <command>mount</command> + commands shown above:</para> + + <screen>&prompt.root; <userinput>mdmfs -F <replaceable>newimage</replaceable> -s <replaceable>5</replaceable>m md<replaceable>0</replaceable> <replaceable>/mnt</replaceable></userinput></screen> + + <para>To instead create a new memory-based memory disk with + <command>mdmfs</command>, use this one command:</para> + + <screen>&prompt.root; <userinput>mdmfs -s <replaceable>5</replaceable>m md<replaceable>1</replaceable> <replaceable>/mnt</replaceable></userinput></screen> + + <para>If the unit number is not specified, + <command>mdmfs</command> will + automatically select an unused memory device. For more details + about <command>mdmfs</command>, refer to &man.mdmfs.8;.</para> </sect2> </sect1>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201404241951.s3OJpuC1007623>