e2cb27a5f2590f0f109bbe96733be2bf2a3fa005
[ikiwiki.git] / docs / handbook / handbook-disks-virtual.mdwn
1 \r
2 \r
3 ## 12.11 Network, Memory, and File-Backed File Systems \r
4 \r
5 ***Reorganized and enhanced by Marc Fonvieille. ***\r
6 \r
7 Aside from the disks you physically insert into your computer: floppies, CDs, hard drives, and so forth; other forms of disks are understood by DragonFly - the ***virtual disks***.\r
8 \r
9 These include network file systems such as the [network-nfs.html Network File System], memory-based file systems and file-backed file systems.\r
10 \r
11 ### 12.11.1 File-Backed File System \r
12 \r
13 The utility [vnconfig(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#vnconfig&section8) configures and enables vnode pseudo-disk devices. A ***vnode*** is a representation of a file, and is the focus of file activity. This means that [vnconfig(8)](http://leaf.dragonflybsd.org/cgi/web-man?command=vnconfig&section=8) uses files to create and operate a file system. One possible use is the mounting of floppy or CD images kept in files.\r
14 \r
15 To use [vnconfig(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#vnconfig&section8), you need [vn(4)](http://leaf.dragonflybsd.org/cgi/web-man?command=vn&section=4) support in your kernel configuration file:\r
16 \r
17     \r
18     pseudo-device vn\r
19 \r
20 \r
21 To mount an existing file system image:\r
22 \r
23  **Example 12-4. Using vnconfig to Mount an Existing File System Image** \r
24 \r
25     \r
26     # vnconfig vn`***0***` `***diskimage***`\r
27     # mount /dev/vn`***0***`c `***/mnt***`\r
28 \r
29 \r
30 To create a new file system image with [vnconfig(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#vnconfig&section8):\r
31 \r
32  **Example 12-5. Creating a New File-Backed Disk with `vnconfig`** \r
33 \r
34     \r
35     # dd if#/dev/zero of`***newimage***` bs=1k count=`***5***`k\r
36     5120+0 records in\r
37     5120+0 records out\r
38     # vnconfig -s labels -c vn`***0***` `***newimage***`\r
39     # disklabel -r -w vn`***0***` auto\r
40     # newfs vn`***0***`c\r
41     Warning: 2048 sector(s) in last cylinder unallocated\r
42     /dev/vn0c:     10240 sectors in 3 cylinders of 1 tracks, 4096 sectors\r
43             5.0MB in 1 cyl groups (16 c/g, 32.00MB/g, 1280 i/g)\r
44     super-block backups (for fsck -b #) at:\r
45      32\r
46     # mount /dev/vn`***0***`c `***/mnt***`\r
47     # df `***/mnt***`\r
48     Filesystem  1K-blocks     Used    Avail Capacity  Mounted on\r
49     /dev/vn0c        4927        1     4532     0%    /mnt\r
50 \r
51 \r
52 ### 12.11.2 Memory-Based File System \r
53 \r
54 The [md(4)](http://leaf.dragonflybsd.org/cgi/web-man?command#md&section4) driver is a simple, efficient means to create memory file systems. [malloc(9)](http://leaf.dragonflybsd.org/cgi/web-man?command=malloc&section=9) is used to allocate the memory.\r
55 \r
56 Simply take a file system you have prepared with, for example, [vnconfig(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#vnconfig&section8), and:\r
57 \r
58  **Example 12-6. md Memory Disk** \r
59 \r
60     \r
61     # dd if#`***newimage***` of/dev/md`***0***`\r
62     5120+0 records in\r
63     5120+0 records out\r
64     # mount /dev/md`***0c***` `***/mnt***`\r
65     # df `***/mnt***`\r
66     Filesystem  1K-blocks     Used    Avail Capacity  Mounted on\r
67     /dev/md0c        4927        1     4532     0%    /mnt\r
68 \r
69 \r
70 For more details, please refer to [md(4)](http://leaf.dragonflybsd.org/cgi/web-man?command#md&section4) manual page.\r
71 \r
72 ### 12.11.3 Detaching a Memory Disk from the System \r
73 \r
74 When a memory-based or file-based file system is not used, you should release all resources to the system. The first thing to do is to unmount the file system, then use [mdconfig(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#mdconfig&section8) to detach the disk from the system and release the resources.\r
75 \r
76 For example to detach and free all resources used by `/dev/md4`:\r
77 \r
78     \r
79     # mdconfig -d -u `***4***`\r
80 \r
81 \r
82 It is possible to list information about configured [md(4)](http://leaf.dragonflybsd.org/cgi/web-man?command#md&section4) devices in using the command `mdconfig -l`.\r
83 \r
84 [vnconfig(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#vnconfig&section8) is used to detach the device. For example to detach and free all resources used by `/dev/vn4`:\r
85 \r
86     \r
87     # vnconfig -u vn`***4***`\r
88 \r
89 \r
90 \r
91 \r
92 CategoryHandbook\r
93 CategoryHandbook-storage\r