From b66ddefad8fafe3702dae2775879236f9169e291 Mon Sep 17 00:00:00 2001 From: Dru Lavigne Date: Thu, 24 Apr 2014 18:24:48 +0000 Subject: [PATCH] Editorial review of Attaching and Detaching Existing Images. More commits to come to finish review of this chapter. Sponsored by: iXsystems --- .../books/handbook/disks/chapter.xml | 157 +++++++++--------- 1 file changed, 74 insertions(+), 83 deletions(-) diff --git a/en_US.ISO8859-1/books/handbook/disks/chapter.xml b/en_US.ISO8859-1/books/handbook/disks/chapter.xml index a3186fd5aa..8916b2d853 100644 --- a/en_US.ISO8859-1/books/handbook/disks/chapter.xml +++ b/en_US.ISO8859-1/books/handbook/disks/chapter.xml @@ -1989,44 +1989,67 @@ scsibus1: In addition to physical disks, &os; also supports - the creation and use of memory disks. + the creation and use of memory disks. One possible use for a + memory disk is to access the contents of an + ISO file system without the overhead of first + burning it to a CD or DVD, + then mounting the CD/DVD media. + + In &os;, the &man.md.4; driver is used to provide support + for memory disks. The GENERIC kernel + includes this driver. When using a custom kernel + configuration file, ensure it includes this line: - - disks - memory - + device md Attaching and Detaching Existing Images disks - file-backed + memory - &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: - - device md - - &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 CD - images. - - To mount an existing file system image: - - - Using <command>mdconfig</command> to Mount an Existing - File System Image + To mount an existing file system image, use + mdconfig to specify the name of the + ISO 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 ISO + will appear in the mount point. This example attaches + diskimage.iso to the memory device + /dev/md0 then mounts that memory device + on /mnt: &prompt.root; mdconfig -f diskimage.iso -u 0 &prompt.root; mount /dev/md0 /mnt - + If a unit number is not specified with + , mdconfig will + automatically allocate an unused memory device and output + the name of the allocated unit, such + as md4. Refer to &man.mdconfig.8; + for more details about this command and its options. + + 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 + mdconfig to detach the disk from the system and + release its resources. To continue this example: + + &prompt.root; umount /mnt +&prompt.root; mdconfig -d -u 0 + + To determine if any memory disks are still attached to the + system, type mdconfig -l. + + + + Creating a Memory Disk + + + disks + memory file system + To create a new file system image with &man.mdconfig.8;: @@ -2050,12 +2073,32 @@ Filesystem 1K-blocks Used Avail Capacity Mounted on /dev/md0a 4710 4 4330 0% /mnt - If unit number is not specified with - , &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 md4. Refer to &man.mdconfig.8; - for more details about. + 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> + + &prompt.root; mdconfig -a -t swap -s 5m -u 1 +&prompt.root; newfs -U md1 +/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; mount /dev/md1 /mnt +&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 @@ -2087,58 +2130,6 @@ Filesystem 1K-blocks Used Avail Capacity Mounted on disks detaching a memory disk - - 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. - - For example, to detach and free all resources used by - /dev/md4: - - &prompt.root; mdconfig -d -u 4 - - It is possible to list information about configured - &man.md.4; devices by running - mdconfig -l. - - - - Creating a Memory Disk - - - disks - memory file system - - - 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> - - &prompt.root; mdconfig -a -t swap -s 5m -u 1 -&prompt.root; newfs -U md1 -/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; mount /dev/md1 /mnt -&prompt.root; df /mnt -Filesystem 1K-blocks Used Avail Capacity Mounted on -/dev/md1 4718 4 4338 0% /mnt - - Creating a New Memory-Based Disk with <command>mdmfs</command>