From owner-svn-doc-all@FreeBSD.ORG Thu Apr 24 19:51:56 2014 Return-Path: Delivered-To: svn-doc-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id DDC9B47C; Thu, 24 Apr 2014 19:51:56 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BE5A616F0; Thu, 24 Apr 2014 19:51:56 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s3OJpu0W007624; Thu, 24 Apr 2014 19:51:56 GMT (envelope-from dru@svn.freebsd.org) Received: (from dru@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s3OJpuC1007623; Thu, 24 Apr 2014 19:51:56 GMT (envelope-from dru@svn.freebsd.org) Message-Id: <201404241951.s3OJpuC1007623@svn.freebsd.org> From: Dru Lavigne Date: Thu, 24 Apr 2014 19:51:56 +0000 (UTC) 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 X-SVN-Group: doc-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-doc-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire doc trees \(except for " user" , " projects" , and " translations" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Apr 2014 19:51:56 -0000 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 md4. Refer to &man.mdconfig.8; for more details about this command and its options. + + disks + detaching a memory disk + + 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: - Creating a Memory Disk + Creating a File- or Memory-Backed Memory Disk disks memory file system - To create a new file system image with - &man.mdconfig.8;: - - - Creating a New File-Backed Disk with - <command>mdconfig</command> - - &prompt.root; dd if=/dev/zero of=newimage bs=1k count=5k -5120+0 records in -5120+0 records out -&prompt.root; mdconfig -a -t vnode -f newimage -u 0 -&prompt.root; bsdlabel -w md0 auto -&prompt.root; newfs md0a -/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; mount /dev/md0a /mnt -&prompt.root; df /mnt -Filesystem 1K-blocks Used Avail Capacity Mounted on -/dev/md0a 4710 4 4330 0% /mnt - - - For a memory-based file system, swap - backing 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. - - - Creating a New Memory-Based Disk with - <command>mdconfig</command> + &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 + mdconfig. + + To create a new memory-backed file system, specify a type + of swap 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 + 1. That memory disk is then formatted with + the UFS file system before it is + mounted: &prompt.root; mdconfig -a -t swap -s 5m -u 1 &prompt.root; newfs -U md1 @@ -2098,47 +2081,55 @@ super-block backups (for fsck -b #) at: &prompt.root; df /mnt Filesystem 1K-blocks Used Avail Capacity Mounted on /dev/md1 4718 4 4338 0% /mnt - - 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: - - - Configure and Mount a File-Backed Disk with - <command>mdmfs</command> + + To create a new file-backed memory disk, first allocate an + area of disk to use. This example creates an empty 5K file + named newimage: &prompt.root; dd if=/dev/zero of=newimage bs=1k count=5k 5120+0 records in -5120+0 records out -&prompt.root; mdmfs -F newimage -s 5m md0 /mnt -&prompt.root; df /mnt -Filesystem 1K-blocks Used Avail Capacity Mounted on -/dev/md0 4718 4 4338 0% /mnt - - - When 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. - - - disks - detaching a memory disk - - - Creating a New Memory-Based Disk with - <command>mdmfs</command> +5120+0 records out - &prompt.root; mdmfs -s 5m md2 /mnt + Next, attach that file to a memory disk, label the memory + disk and format it with the UFS file + system, mount the memory disk, and verify the size of the + file-backed disk: + + &prompt.root; mdconfig -f newimage -u 0 +&prompt.root; bsdlabel -w md0 auto +&prompt.root; newfs md0a +/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; mount /dev/md0a /mnt &prompt.root; df /mnt Filesystem 1K-blocks Used Avail Capacity Mounted on -/dev/md2 4846 2 4458 0% /mnt - +/dev/md0a 4710 4 4330 0% /mnt + + It takes several commands to create a file- or memory-backed file + system using mdconfig. &os; also + comes with mdmfs which automatically configures a + memory disk, formats it with the UFS file system, + and mounts it. For example, after creating + newimage with + dd, this one command is equivalent to + running the bsdlabel, + newfs, and mount + commands shown above: + + &prompt.root; mdmfs -F newimage -s 5m md0 /mnt + + To instead create a new memory-based memory disk with + mdmfs, use this one command: + + &prompt.root; mdmfs -s 5m md1 /mnt + + If the unit number is not specified, + mdmfs will + automatically select an unused memory device. For more details + about mdmfs, refer to &man.mdmfs.8;.