How to setup ephemeral disks? #1618
-
I’d like the ability to partition, format and mount ephemeral disks attached to the host. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Starting with Bottlerocket v1.1.2, it will be possible to use bootstrap containers to partition, format and mount the devices on the host. Users will be able to can create an "always-executed" bootstrap container that partitions, formats and mounts the devices, using the tools they are familiar with. Here is an example on how to do so. Given a bootstrap container called setup-ephemeral-disks with the following configuration: [settings.bootstrap-containers.setup-ephemeral-disks]
source = "<SOURCE>"
mode = "always"
essential = false Where FROM alpine
RUN apk add e2fsprogs bash parted
ADD setup-ephemeral-disks ./
RUN chmod +x ./setup-ephemeral-disks
ENTRYPOINT ["sh", "setup-ephemeral-disks"] And setup-ephemeral-disks as: #!/usr/bin/env bash
set -ex
# The name of the disk we want to manage
DISK=/.bottlerocket/rootfs/dev/nvme2n1
# Sentry file to check if the disk was already partitioned and formatted
PARTITIONS_CREATED=/.bottlerocket/bootstrap-containers/current/created
# Mounts from this mount point will propagate accross mount namespaces
BASE_MOUNT_POINT=/.bottlerocket/rootfs/mnt
# If the disk hasn't been partitioned, create the partitions and format them
if [ ! -f $PARTITIONS_CREATED ]; then
parted -s $DISK mklabel gpt 1>/dev/null
parted -s $DISK mkpart primary ext4 0% 50% 1>/dev/null
parted -s $DISK mkpart primary ext4 50% 100% 1>/dev/null
mkfs.ext4 -F ${DISK}p1
mkfs.ext4 -F ${DISK}p2
# Create sentry file once the disk is partitioned and formatted
touch $PARTITIONS_CREATED
fi
# We make sure the target mount points exist
mkdir -p $BASE_MOUNT_POINT/part1
mkdir -p $BASE_MOUNT_POINT/part2
# Always mount the partitions
mount ${DISK}p1 $BASE_MOUNT_POINT/part1
mount ${DISK}p2 $BASE_MOUNT_POINT/part2 With the provided configurations the bootstrap container will be executed at every boot, and the boot won’t fail if the bootstrap container fails. You can setup the bootstrap container as essential, if you don’t want to proceed with the boot process when the bootstrap container fails. From the admin container, you should see the new partitions mounted under /.bottlerocket/rootfs/mnt, and from the host under /mnt. The script provided is just an example and should only be used as a reference. Keep in mind that some devices (like EBS volumes) could get a different name on every start, make sure your setup script accounts for that. |
Beta Was this translation helpful? Give feedback.
-
Hi @arnaldo2792 , Iam trying make a raid on instance store volumes, i am doing it via bootstrap container as mentioned above. to get the nvme list , iam using nvme list command, the error on execution is Failed to open /dev/nvme0 . nvme-cli is present inside the container . Any idea ? |
Beta Was this translation helpful? Give feedback.
Starting with Bottlerocket v1.1.2, it will be possible to use bootstrap containers to partition, format and mount the devices on the host. Users will be able to can create an "always-executed" bootstrap container that partitions, formats and mounts the devices, using the tools they are familiar with. Here is an example on how to do so.
Given a bootstrap container called setup-ephemeral-disks with the following configuration:
Where
<SOURCE>
is the URL of an image with the following definition: