5.18. Custom file system configuration specification


You can specify a custom filesystem configuration in your blueprints and therefore create images with a specific disk layout, instead of the default layout configuration.

By using the non-default layout configuration in your blueprints, you can benefit from:

  • Security benchmark compliance
  • Protection against out-of-disk errors
  • Improved performance
  • Consistency with existing setups
注意

The OSTree systems do not support filesystem customizations, because OSTree images have their own mount rule, such as read-only. The following image types are not supported:

  • image-installer

Additionally, the following image types do not support filesystem customizations, because these image types do not create partitioned operating system images:

  • tar
  • container

For release distributions before 9.4, the blueprint supports the following mountpoints and their sub-directories:

  • / is the root mount point
  • /var
  • /home
  • /opt
  • /srv
  • /usr
  • /app
  • /data
  • /tmp

You cannot specify arbitrary custom mount points on the following mount points and their sub-directories:

  • /bin
  • /dev
  • /etc
  • /lib
  • /lib64
  • /lost+found
  • /proc
  • /run
  • /sbin
  • /sys
  • /sysroot
  • /var/lock
  • /var/run

You can customize the filesystem in the blueprint for the /usr custom mount point, but its subdirectory is not allowed.

If you have more than one partition in the customized image, you can create images with a customized file system partition on LVM and resize those partitions at runtime. To do this, you can specify a customized filesystem configuration in your blueprint and therefore create images with the required disk layout. The default filesystem layout remains unchanged if you use plain images without file system customization, and cloud-init resizes the root partition.

The blueprint automatically converts the file system customization to an LVM partition.

You can use the custom file blueprint customization to create new files or to replace existing files. The parent directory of the file you specify must exist otherwise, the image build fails. Ensure that the parent directory exists by specifying it in the [[customizations.directories]] customization.

警告

If you combine the file customizations with other blueprint customizations, it might affect the functioning of the other customizations, or it might override the current file customizations.

5.18.1. Custom files specification in the blueprint

With the [[customizations.files]] blueprint customization you can create new text files, or modify existing files.

+ WARNING: This can override the existing content. * Set user and group ownership for the file you are creating. * Set the mode permission in the octal format.

You cannot create or replace the following files:

  • /etc/fstab
  • /etc/shadow
  • /etc/passwd
  • /etc/group

You can create customized files and directories in your image by using the [[customizations.files]] and the [[customizations.directories]] blueprint customizations. You can use these customizations only in the /etc directory.

警告

If you use the customizations.directories with a directory path that already exists in the image with mode, user, or group already set, the image build fails to prevent changing the ownership or permissions of the existing directory.

5.18.2. Custom directories specification in the blueprint

You can use the [[customizations.directories]] blueprint customization to create or modify directories.

With the customization, you can:

  • Create new directories.
  • Set user and group ownership for the directory you are creating.
  • Set the directory mode permission in the octal format.
  • Ensure that parent directories are created as needed.

With the [[customizations.files]] blueprint customization you can:

  • Create new text files.
  • Modifying existing files. WARNING: This can override the existing content.
  • Set user and group ownership for the file you are creating.
  • Set the mode permission in the octal format.
注意

You cannot create or replace the following files:

  • /etc/fstab
  • /etc/shadow
  • /etc/passwd
  • /etc/group

The following customizations are available:

  • Customize the filesystem configuration in your blueprint:

    [[customizations.filesystem]]
    mountpoint = "MOUNTPOINT"
    minsize = MINIMUM-PARTITION-SIZE

    The MINIMUM-PARTITION-SIZE value has no default size format. The blueprint customization supports the following values and units: kB to TB and KiB to TiB. For example, you can define the mount point size in bytes:

    [[customizations.filesystem]]
    mountpoint = "/var"
    minsize = 1073741824
  • Define the mount point size by using units. For example:

    [[customizations.filesystem]]
    mountpoint = "/opt"
    minsize = "20 GiB"
    [[customizations.filesystem]]
    mountpoint = "/var"
    minsize = "1 GiB"
  • Define the minimum partition by setting minsize. For example:

    [[customizations.filesystem]]
    mountpoint = "/var"
    minsize = 2147483648
  • Create customized directories under the /etc directory for your image by using [[customizations.directories]]:

    [[customizations.directories]]
    path = "/etc/directory_name"
    mode = "octal_access_permission"
    user = "user_string_or_integer"
    group = "group_string_or_integer"
    ensure_parents = boolean

    The blueprint entries are described as follows:

    • path Mandatory. Enter the path to the directory that you want to create. It must be an absolute path under the /etc directory.
    • mode Optional. Set the access permission on the directory, in the octal format. If you do not specify a permission, it defaults to 0755. The leading zero is optional.
    • user Optional. Set a user as the owner of the directory. If you do not specify a user, it defaults to root. You can specify the user as a string or as an integer.
    • group Optional. Set a group as the owner of the directory. If you do not specify a group, it defaults to root. You can specify the group as a string or as an integer.
    • ensure_parents Optional. Specify whether you want to create parent directories as needed. If you do not specify a value, it defaults to false.
  • Create a customized file under the /etc directory for your image by using [[customizations.directories]]:

    [[customizations.files]]
    path = "/etc/directory_name"
    mode = "octal_access_permission"
    user = "user_string_or_integer"
    group = "group_string_or_integer"
    data = "Hello world!"

    The blueprint entries are described as follows:

    • path Mandatory. Enter the path to the file that you want to create. It must be an absolute path under the /etc directory.
    • mode Optional. Set the access permission on the file in the octal format. If you do not specify a permission, it defaults to 0644. The leading zero is optional.
    • user Optional. Set a user as the owner of the file. If you do not specify a user, it defaults to root. You can specify the user as a string or as an integer.
    • group Optional. Set a group as the owner of the file. If you do not specify a group, it defaults to root. You can specify the group as a string or as an integer.
    • data Optional. Specify the content of a plain text file. If you do not specify any content, it creates an empty file.
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2026 Red Hat
返回顶部