]> git.proxmox.com Git - pve-docs.git/blame_incremental - pve-storage-dir.adoc
network: override device names: suggest running update-initramfs
[pve-docs.git] / pve-storage-dir.adoc
... / ...
CommitLineData
1[[storage_directory]]
2Directory Backend
3-----------------
4ifdef::wiki[]
5:pve-toplevel:
6:title: Storage: Directory
7endif::wiki[]
8
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
16NOTE: You can mount additional storages via standard linux `/etc/fstab`,
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
22snapshots at the storage level. But there exists a workaround for VM
23images using the `qcow2` file format, because that format supports
24snapshots internally.
25
26TIP: Some storage types do not support `O_DIRECT`, so you can't use
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
31into different sub-directories. This layout is used by all file level
32storage 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
46Configuration
47~~~~~~~~~~~~~
48
49This backend supports all common storage properties, and adds two
50additional properties. The `path` property is used to specify the
51directory. This needs to be an absolute file system path.
52
53The optional `content-dirs` property allows for the default layout
54to be changed. It consists of a comma-separated list of identifiers
55in the following format:
56
57 vtype=path
58
59Where `vtype` is one of the allowed content types for the storage, and
60`path` is a path relative to the mountpoint of the storage.
61
62.Configuration Example (`/etc/pve/storage.cfg`)
63----
64dir: backup
65 path /mnt/backup
66 content backup
67 prune-backups keep-last=7
68 max-protected-backups 3
69 content-dirs backup=custom/backup/dir
70----
71
72The above configuration defines a storage pool called `backup`. That pool can be
73used to store up to 7 regular backups (`keep-last=7`) and 3 protected backups
74per VM. The real path for the backup files is `/mnt/backup/custom/backup/dir/...`.
75
76File naming conventions
77~~~~~~~~~~~~~~~~~~~~~~~
78
79This backend uses a well defined naming scheme for VM images:
80
81 vm-<VMID>-<NAME>.<FORMAT>
82
83`<VMID>`::
84
85This specifies the owner VM.
86
87`<NAME>`::
88
89This can be an arbitrary name (`ascii`) without white space. The
90backend uses `disk-[N]` as default, where `[N]` is replaced by an
91integer to make the name unique.
92
93`<FORMAT>`::
94
95Specifies the image format (`raw|qcow2|vmdk`).
96
97When you create a VM template, all VM images are renamed to indicate
98that they are now read-only, and can be used as a base image for clones:
99
100 base-<VMID>-<NAME>.<FORMAT>
101
102NOTE: Such base images are used to generate cloned images. So it is
103important that those files are read-only, and never get modified. The
104backend changes the access mode to `0444`, and sets the immutable flag
105(`chattr +i`) if the storage supports that.
106
107
108Storage Features
109~~~~~~~~~~~~~~~~
110
111As mentioned above, most file systems do not support snapshots out
112of the box. To workaround that problem, this backend is able to use
113`qcow2` internal snapshot capabilities.
114
115Same applies to clones. The backend uses the `qcow2` base image
116feature to create clones.
117
118.Storage features for backend `dir`
119[width="100%",cols="m,m,3*d",options="header"]
120|==============================================================================
121|Content types |Image formats |Shared |Snapshots |Clones
122|images rootdir vztmpl iso backup snippets |raw qcow2 vmdk subvol |no |qcow2 |qcow2
123|==============================================================================
124
125
126Examples
127~~~~~~~~
128
129Please use the following command to allocate a 4GB image on storage `local`:
130
131 # pvesm alloc local 100 vm-100-disk10.raw 4G
132 Formatting '/var/lib/vz/images/100/vm-100-disk10.raw', fmt=raw size=4294967296
133 successfully created 'local:100/vm-100-disk10.raw'
134
135NOTE: The image name must conform to above naming conventions.
136
137The real file system path is shown with:
138
139 # pvesm path local:100/vm-100-disk10.raw
140 /var/lib/vz/images/100/vm-100-disk10.raw
141
142And you can remove the image with:
143
144 # pvesm free local:100/vm-100-disk10.raw
145
146
147ifdef::wiki[]
148
149See Also
150~~~~~~~~
151
152* link:/wiki/Storage[Storage]
153
154endif::wiki[]
155
156