Curtin fails to deploy image when using an ext2 base filesystem due to swap.img

Bug #1918990 reported by Lee Trager
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MAAS
Fix Released
Medium
Unassigned
Ubuntu on IBM z Systems
Fix Released
Undecided
Unassigned
curtin
Fix Released
Undecided
Unassigned

Bug Description

I configured an IBM Z DPM Partition to use ext2 for / with no other filesystem. The deployment fails when Curtin is unable to create swap.img. While ext2 isn't widely used anymore we have had MAAS users that prefer to use a non-journaling filesystem.

Running command ['sh', '-c', 'rm -f "$1" && umask 0066 && truncate -s 0 "$1" && { chattr +C "$1" || true; } && fallocate -l "${2}M" "$1" && mkswap "$1" || { r=$?; rm -f "$1"; exit $r; }', 'setup_swap', '/tmp/tmpry474p97/target//swap.img', '4096'] with allowed return codes [0] (capture=False)
chattr: Operation not supported while setting flags on /tmp/tmpry474p97/target//swap.img
fallocate: fallocate failed: Operation not supported
creating swap file '/swap.img' of 4096MB took 0.006 seconds
failed creating swap file '/swap.img' of 4096MB

Tags: s390x maas
Revision history for this message
Lee Trager (ltrager) wrote :
Frank Heimes (fheimes)
tags: added: maas s390x
Revision history for this message
Lee Trager (ltrager) wrote :

I think this is a bug in Curtin. I just tried to deploy a CentOS 8 AMD64 image with an ext2 filesystem and I get the same error. One thing I just realized, MAAS doesn't request that a swap file is created in curtin.cfg. When deploying Ubuntu or CentOS with an ext4 base filesystem swap is not created. It seems Curtin automatically tries to enable Swap in some cases when ext2 is used as the base filesystem.

summary: - IBM Z DPM Partition fails to deploy with ext2 filesystem due to
+ Curtin fails to deploy image when using an ext2 base filesystem due to
swap.img
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

I don't know whether this is a bug in curtin or whatever is generating the config. Curtin tries to add a swapfile by default but it's easy to disable. Subiquity currently disables the swapfile if a swap partition is mounted or if / is on btrfs (subiquity doesn't let you format as ext2). Where should the logic of which filesystems support swapfiles live?

Revision history for this message
Lee Trager (ltrager) wrote :

The attached tar files contain the Curtin configuration MAAS is sending. It defines storage but doesn't mention swap at all. MAAS does support configuring swap partitions but that must be done manually by the user.

What's interesting is that if you deploy Ubuntu 20.04 on AMD64 with ext2 swap isn't created. Nor is swap created when you use an ext4 filesystem. Because Curtin is already deciding when to add a swap file I think the logic should live in Curtin. Curtin docs[1] do define a "force" field to "Force the creation of swapfile even if curtin detects it may not work." So it seems there is some logic in Curtin already.

[1] https://curtin.readthedocs.io/en/latest/topics/config.html?highlight=multipath#swap

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Ah, you're right. I guess this line here https://git.launchpad.net/curtin/tree/curtin/swap.py#n106 needs an update?

Revision history for this message
Lee Trager (ltrager) wrote :

The easiest solution is probably to disallow swap files on ext2, like what is done for ZFS.

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Hmm actually I think the fix is to allocate space for swapfiles with dd on ext2 (and maybe ext3 as well?)

Revision history for this message
Server Team CI bot (server-team-bot) wrote :

This bug is fixed with commit c204635e to curtin on branch master.
To view that commit see the following URL:
https://git.launchpad.net/curtin/commit/?id=c204635e

Changed in curtin:
status: New → Fix Committed
Frank Heimes (fheimes)
Changed in ubuntu-z-systems:
status: New → In Progress
Alberto Donato (ack)
Changed in maas:
status: New → Triaged
importance: Undecided → Medium
Revision history for this message
Dan Bungert (dbungert) wrote : Fixed in curtin version 21.3.

This bug is believed to be fixed in curtin in version 21.3. If this is still a problem for you, please make a comment and set the state back to New

Thank you.

Changed in curtin:
status: Fix Committed → Fix Released
Frank Heimes (fheimes)
Changed in ubuntu-z-systems:
status: In Progress → Fix Committed
Changed in maas:
milestone: none → 3.0.x
status: Triaged → Fix Released
Frank Heimes (fheimes)
Changed in ubuntu-z-systems:
status: Fix Committed → Fix Released
Changed in maas:
milestone: 3.0.x → none
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.