Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/swap.img w/fallocate has holes #3211

Closed
ubuntu-server-builder opened this issue May 11, 2023 · 5 comments
Closed

/swap.img w/fallocate has holes #3211

ubuntu-server-builder opened this issue May 11, 2023 · 5 comments
Labels
launchpad Migrated from Launchpad

Comments

@ubuntu-server-builder
Copy link
Collaborator

This bug was originally filed in Launchpad as LP: #1781781

Launchpad details
affected_projects = ['curtin']
assignee = None
assignee_name = None
date_closed = 2020-02-20T21:14:57.989487+00:00
date_created = 2018-07-15T08:35:52.392722+00:00
date_fix_committed = 2020-01-23T19:01:28.631260+00:00
date_fix_released = 2020-02-20T21:14:57.989487+00:00
id = 1781781
importance = medium
is_complete = True
lp_url = https://bugs.launchpad.net/cloud-init/+bug/1781781
milestone = None
owner = smoser
owner_name = Scott Moser
private = False
status = fix_released
submitter = eb4x
submitter_name = Ebbex
tags = []
duplicates = []

Launchpad user Ebbex(eb4x) wrote on 2018-07-15T08:35:52.392722+00:00

The /swap.img file on an XFS root filesystem is not being used. The dmesg says it "has holes".

From the swapon manpage;

The swap file implementation in the kernel expects to be able to write to the file directly, without the assistance of the filesystem. This is a problem on preallocated files (e.g. fallocate(1)) on filesystems like XFS or ext4, and on copy-on-write filesystems like btrfs.

It is recommended to use dd(1) and /dev/zero to avoid holes on XFS and ext4.

I've tracked down this commit which seems to be a step in the right direction;

canonical/curtin@a909966

@ubuntu-server-builder ubuntu-server-builder added the launchpad Migrated from Launchpad label May 11, 2023
@ubuntu-server-builder
Copy link
Collaborator Author

Launchpad user Ebbex(eb4x) wrote on 2018-07-16T18:31:18.119623+00:00

So I've checked it out, and ext4 seems to work fine with fallocate. It could perhaps be considered a filesystem-bug as it seems that some xfs-developers are aware of the issue; https://www.spinics.net/lists/linux-mm/msg147100.html But it would be beneficial to have a work-around until that gets sorted.

@ubuntu-server-builder
Copy link
Collaborator Author

Launchpad user Ryan Harper(raharper) wrote on 2018-07-16T19:04:29.105846+00:00

Yes, from my reading, this is an xfs (btrfs) specific issue w.r.t how they don't handle converting a fallocated file into swap space.

I think we'll likely do the following:

  1. add a integration test which does swapfile enablment via fallocate for each fs and confirms that the target system can use it as swap; we expect this to fail when rootfs is either btrfs or xfs.

  2. update curtin swap creation code to check the target filesystem format and for btrfs or xfs filesystems, skip fallocate and use dd instead.

Alternatively, one can use a swap partition instead of a file on the filesystem which avoids this path; that may be preferred to avoid dd'ing gigabytes of data.

@ubuntu-server-builder
Copy link
Collaborator Author

Launchpad user Scott Moser(smoser) wrote on 2018-11-30T14:32:24.906619+00:00

The same basic issue is in cloud-init
and had a MP proposed at
https://code.launchpad.net/~adobrawy/cloud-init/+git/cloud-init/+merge/354680

@ubuntu-server-builder
Copy link
Collaborator Author

Launchpad user Chad Smith(chad.smith) wrote on 2020-01-23T19:01:24.087652+00:00

A fix landed inin cloud-init upstream for this issue @ 6603706

If this is still a problem, please re-open this bug task for cloud-init.

@ubuntu-server-builder
Copy link
Collaborator Author

Launchpad user Dan Watkins(oddbloke) wrote on 2020-02-20T21:15:00.457841+00:00

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

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
launchpad Migrated from Launchpad
Projects
None yet
Development

No branches or pull requests

1 participant