You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

147 lines
4.2KB

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