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