// Module included in the following assemblies:
// * edge_computing/image-based-upgrade/cnf-preparing-for-image-based-upgrade.adoc

ifeval::["{context}" == "ibi-preparing-image-based-install"]
:ibi:
endif::[]

ifeval::["{context}" == "shared-container-partition"]
:ibu:
endif::[]

:_mod-docs-content-type: PROCEDURE
[id="cnf-image-based-upgrade-shared-container-partition_{context}"]
= Configuring a shared container partition between ostree stateroots

[role="_abstract"]
ifdef::ibu[]
[role="_abstract"]
Apply a `MachineConfig` to both the seed and the target clusters during installation time to create a separate partition and share the `/var/lib/containers` partition between the two `ostree` stateroots that will be used during the upgrade process.
endif::[]

[IMPORTANT]
====
You must complete this procedure at installation time.
====

ifdef::ibi[]
[role="_abstract"]
Apply a `MachineConfig` to the seed cluster to create a separate partition and share the `/var/lib/containers` partition between the two `ostree` stateroots that will be used during the preinstall process.
endif::[]

.Procedure

* Apply a `MachineConfig` to create a separate partition:
+
[source,yaml]
----
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
metadata:
  labels:
    machineconfiguration.openshift.io/role: master
  name: 98-var-lib-containers-partitioned
spec:
  config:
    ignition:
      version: 3.2.0
    storage:
      disks:
        - device: /dev/disk/by-path/<root_disk>
          partitions:
            - label: var-lib-containers
              startMiB: <start_of_partition>
              sizeMiB: <partition_size>
      filesystems:
        - device: /dev/disk/by-partlabel/var-lib-containers
          format: xfs
          mountOptions:
            - defaults
            - prjquota
          path: /var/lib/containers
          wipeFilesystem: true
    systemd:
      units:
        - contents: |-
            # Generated by Butane
            [Unit]
            Before=local-fs.target
            Requires=systemd-fsck@dev-disk-by\x2dpartlabel-var\x2dlib\x2dcontainers.service
            After=systemd-fsck@dev-disk-by\x2dpartlabel-var\x2dlib\x2dcontainers.service

            [Mount]
            Where=/var/lib/containers
            What=/dev/disk/by-partlabel/var-lib-containers
            Type=xfs
            Options=defaults,prjquota

            [Install]
            RequiredBy=local-fs.target
          enabled: true
          name: var-lib-containers.mount
----
+
where:
+
`<root_disk>`:: Specifies the root disk, for example `pci-0000:01:00.0-scsi-0:2:0:0`.
`<start_of_partition>`:: Specifies the start of the partition in MiB. If the value is too small, the installation will fail.
`<partition_size>`:: Specifies a minimum size for the partition of 500 GB (512000 MiB) to ensure adequate disk space for precached images. If the value is too small, the deployments after installation will fail.

ifeval::["{context}" == "ibi-preparing-image-based-install"]
:!ibi:
endif::[]

ifeval::["{context}" == "shared-container-partition"]
:!ibu:
endif::[]
