]>
Commit | Line | Data |
---|---|---|
1 | [[storage_directory]] | |
2 | Directory Backend | |
3 | ----------------- | |
4 | ifdef::wiki[] | |
5 | :pve-toplevel: | |
6 | :title: Storage: Directory | |
7 | endif::wiki[] | |
8 | ||
9 | Storage pool type: `dir` | |
10 | ||
11 | {pve} can use local directories or locally mounted shares for | |
12 | storage. A directory is a file level storage, so you can store any | |
13 | content type like virtual disk images, containers, templates, ISO images | |
14 | or backup files. | |
15 | ||
16 | NOTE: You can mount additional storages via standard linux `/etc/fstab`, | |
17 | and then define a directory storage for that mount point. This way you | |
18 | can use any file system supported by Linux. | |
19 | ||
20 | This backend assumes that the underlying directory is POSIX | |
21 | compatible, but nothing else. This implies that you cannot create | |
22 | snapshots at the storage level. But there exists a workaround for VM | |
23 | images using the `qcow2` file format, because that format supports | |
24 | snapshots internally. | |
25 | ||
26 | TIP: Some storage types do not support `O_DIRECT`, so you can't use | |
27 | cache mode `none` with such storages. Simply use cache mode | |
28 | `writeback` instead. | |
29 | ||
30 | We use a predefined directory layout to store different content types | |
31 | into different sub-directories. This layout is used by all file level | |
32 | storage backends. | |
33 | ||
34 | .Directory layout | |
35 | [width="100%",cols="d,m",options="header"] | |
36 | |=========================================================== | |
37 | |Content type |Subdir | |
38 | |VM images |`images/<VMID>/` | |
39 | |ISO images |`template/iso/` | |
40 | |Container templates |`template/cache/` | |
41 | |Backup files |`dump/` | |
42 | |Snippets |`snippets/` | |
43 | |=========================================================== | |
44 | ||
45 | ||
46 | Configuration | |
47 | ~~~~~~~~~~~~~ | |
48 | ||
49 | This backend supports all common storage properties, and adds an | |
50 | additional property called `path` to specify the directory. This | |
51 | needs to be an absolute file system path. | |
52 | ||
53 | .Configuration Example (`/etc/pve/storage.cfg`) | |
54 | ---- | |
55 | dir: backup | |
56 | path /mnt/backup | |
57 | content backup | |
58 | prune-backups keep-last=7 | |
59 | max-protected-backups 3 | |
60 | ---- | |
61 | ||
62 | The above configuration defines a storage pool called `backup`. That pool can be | |
63 | used to store up to 7 regular backups (`keep-last=7`) and 3 protected backups | |
64 | per VM. The real path for the backup files is `/mnt/backup/dump/...`. | |
65 | ||
66 | ||
67 | File naming conventions | |
68 | ~~~~~~~~~~~~~~~~~~~~~~~ | |
69 | ||
70 | This backend uses a well defined naming scheme for VM images: | |
71 | ||
72 | vm-<VMID>-<NAME>.<FORMAT> | |
73 | ||
74 | `<VMID>`:: | |
75 | ||
76 | This specifies the owner VM. | |
77 | ||
78 | `<NAME>`:: | |
79 | ||
80 | This can be an arbitrary name (`ascii`) without white space. The | |
81 | backend uses `disk-[N]` as default, where `[N]` is replaced by an | |
82 | integer to make the name unique. | |
83 | ||
84 | `<FORMAT>`:: | |
85 | ||
86 | Specifies the image format (`raw|qcow2|vmdk`). | |
87 | ||
88 | When you create a VM template, all VM images are renamed to indicate | |
89 | that they are now read-only, and can be used as a base image for clones: | |
90 | ||
91 | base-<VMID>-<NAME>.<FORMAT> | |
92 | ||
93 | NOTE: Such base images are used to generate cloned images. So it is | |
94 | important that those files are read-only, and never get modified. The | |
95 | backend changes the access mode to `0444`, and sets the immutable flag | |
96 | (`chattr +i`) if the storage supports that. | |
97 | ||
98 | ||
99 | Storage Features | |
100 | ~~~~~~~~~~~~~~~~ | |
101 | ||
102 | As mentioned above, most file systems do not support snapshots out | |
103 | of the box. To workaround that problem, this backend is able to use | |
104 | `qcow2` internal snapshot capabilities. | |
105 | ||
106 | Same applies to clones. The backend uses the `qcow2` base image | |
107 | feature to create clones. | |
108 | ||
109 | .Storage features for backend `dir` | |
110 | [width="100%",cols="m,m,3*d",options="header"] | |
111 | |============================================================================== | |
112 | |Content types |Image formats |Shared |Snapshots |Clones | |
113 | |images rootdir vztmpl iso backup snippets |raw qcow2 vmdk subvol |no |qcow2 |qcow2 | |
114 | |============================================================================== | |
115 | ||
116 | ||
117 | Examples | |
118 | ~~~~~~~~ | |
119 | ||
120 | Please use the following command to allocate a 4GB image on storage `local`: | |
121 | ||
122 | # pvesm alloc local 100 vm-100-disk10.raw 4G | |
123 | Formatting '/var/lib/vz/images/100/vm-100-disk10.raw', fmt=raw size=4294967296 | |
124 | successfully created 'local:100/vm-100-disk10.raw' | |
125 | ||
126 | NOTE: The image name must conform to above naming conventions. | |
127 | ||
128 | The real file system path is shown with: | |
129 | ||
130 | # pvesm path local:100/vm-100-disk10.raw | |
131 | /var/lib/vz/images/100/vm-100-disk10.raw | |
132 | ||
133 | And you can remove the image with: | |
134 | ||
135 | # pvesm free local:100/vm-100-disk10.raw | |
136 | ||
137 | ||
138 | ifdef::wiki[] | |
139 | ||
140 | See Also | |
141 | ~~~~~~~~ | |
142 | ||
143 | * link:/wiki/Storage[Storage] | |
144 | ||
145 | endif::wiki[] | |
146 | ||
147 |