cloud-init cannot create swap files on paths that it mounts
Bug #1869114 reported by
Johnson Shi
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
cloud-init |
Expired
|
Wishlist
|
Unassigned |
Bug Description
1. cloud-init's swap module runs before the mount module, which causes swapfile creation on runtime mounted disks to fail.
2. cloud-init's swap create does not ensure it has a path to the file (if specified with a directory that does not exist yet).
Bug exists in all clouds, but the bug was discovered through deploying an Azure VM, mounting the Azure resource disk, and then creating a swapfile within the mounted resource disk.
Relevant logs: https:/
Changed in cloud-init: | |
assignee: | nobody → Johnson Shi (johnsonshi) |
Changed in cloud-init: | |
assignee: | Johnson Shi (johnsonshi) → nobody |
To post a comment you must log in.
Hi Johnson, thanks for the bug report!
Swap file creation and mounting are both handled by the same module, cc_mounts. This has two phases: /etc/fstab generation and /etc/fstab application. In order for the use of swap files to be persisted between boots, they have to be included in /etc/fstab, so the swap file is created during the generation phase. This, of course, means that the other generated mounts haven't yet been applied, which leads to the behaviour you've observed here.
As other mounts (in general) presumably aren't dependent on the swap file's creation, it may be possible to change the order of these operations to behave as you would like without affecting other use cases, but we would probably need the expected new behaviour to be specified well to satisfy ourselves of this.
Thanks!
Dan