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.
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-SIZEThe
MINIMUM-PARTITION-SIZEvalue 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 = 1073741824Define 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 = 2147483648Create customized directories under the
/etcdirectory 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 = booleanThe blueprint entries are described as follows:
-
pathMandatory. Enter the path to the directory that you want to create. It must be an absolute path under the/etcdirectory. -
modeOptional. Set the access permission on the directory, in the octal format. If you do not specify a permission, it defaults to0755. The leading zero is optional. -
userOptional. Set a user as the owner of the directory. If you do not specify a user, it defaults toroot. You can specify the user as a string or as an integer. -
groupOptional. Set a group as the owner of the directory. If you do not specify a group, it defaults toroot. You can specify the group as a string or as an integer. -
ensure_parentsOptional. Specify whether you want to create parent directories as needed. If you do not specify a value, it defaults tofalse.
-
Create a customized file under the
/etcdirectory 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:
-
pathMandatory. Enter the path to the file that you want to create. It must be an absolute path under the/etcdirectory. -
modeOptional. Set the access permission on the file in the octal format. If you do not specify a permission, it defaults to0644. The leading zero is optional. -
userOptional. Set a user as the owner of the file. If you do not specify a user, it defaults toroot. You can specify the user as a string or as an integer. -
groupOptional. Set a group as the owner of the file. If you do not specify a group, it defaults toroot. You can specify the group as a string or as an integer. -
dataOptional. Specify the content of a plain text file. If you do not specify any content, it creates an empty file.
-