Skip to content

Amazon Linux 2023 - cloud-init mounts

0

I'm attempting to create a file system and mount it using cloud-init on Amazon Linux 2023. I've used this technique before with a Ubuntu image but it's not working for Amazon Linux 2023.

cloudconfig snippet:

fs_setup:
  - label: data01
    filesystem: ext4
    device: /dev/nvme1n1
    partition: auto

mounts:
 - [ LABEL=data01, /app, "auto", "defaults,nofail", "0", "0" ]

error in cloud-init.log

2023-04-13 12:44:57,216 - cc_mounts.py[DEBUG]: mounts configuration is [['LABEL=data01', '/app', 'auto', 'defaults,nofail', '0', '0']]
2023-04-13 12:44:57,216 - util.py[DEBUG]: Reading from /etc/fstab (quiet=False)
2023-04-13 12:44:57,216 - util.py[DEBUG]: Read 217 bytes from /etc/fstab
2023-04-13 12:44:57,216 - cc_mounts.py[DEBUG]: Attempting to determine the real name of LABEL=data01
2023-04-13 12:44:57,216 - cc_mounts.py[DEBUG]: changed LABEL=data01 => None
2023-04-13 12:44:57,216 - cc_mounts.py[DEBUG]: Ignoring nonexistent named mount LABEL=data01

If I manually add the fstab line after boot, /app mounts as expected with mount -a

LABEL=data01    /app   auto    defaults,nofail     0       0

asked 3 years ago1.4K views

1 Answer
1

Hello,

Amazon Linux 2023 uses the following cloud-init version by default:

$ rpm-q cloud-init
cloud-init-22.2.2-1.amzn2023.1.7.noarch

Looking over the version's documentation, https://cloudinit.readthedocs.io/en/22.2.2/topics/modules.html#mounts it states:

When specifying the fs_spec, if the device name starts with one of xvd, sd, hd, or vd, the leading /dev may be omitted.

Any mounts that do not appear to either an attached block device or network resource will be skipped with a log like “Ignoring nonexistent mount …”.

This indicates that cloud-init is most likely not going to see/use labels. I was able to test and confirm this by running multiple variations of the configuration snippet you provided, each variation resulted in the same "Ignoring nonexistent mount …" error. When using the device name/path as mentioned within the guide though:

fs_setup:
  - label: data01
    filesystem: ext4
    device: /dev/nvme1n1
    partition: auto

mounts:
 - [ /dev/nvme1n1, /app, "auto", "defaults,nofail", "0", "0" ]

This mounted with no issues. If you would still like to mount a freshly formatted volume (within cloud-init) using the label, you will need to use a different method to mount the volume, such as running a follow up command within the runcmd module (as seen below):

#cloud-config 
fs_setup:
  - label: data01
    filesystem: ext4
    device: /dev/nvme1n1
    partition: auto

runcmd:
 - [ mount, -L, data01, /app ]

Should you require further assistance regarding your specific situation/use-case, please feel free to create an AWS Support case to get in touch with an engineer to assist you further.

https://docs.aws.amazon.com/awssupport/latest/user/case-management.html

AWS
SUPPORT ENGINEER

answered 3 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.