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

swapon and fallocated files #633

Closed
marcosfrm opened this Issue May 4, 2018 · 5 comments

Comments

Projects
None yet
2 participants
@marcosfrm
Copy link
Contributor

commented May 4, 2018

swapon man page discourages fallocate. But this works in EXT4 (kernel 4.16):

# fallocate -l 1G /swap
# chmod 0600 /swap 
# mkswap /swap 
Setting up swapspace version 1, size = 1024 MiB (1073737728 bytes)
no label, UUID=41268fc9-da3d-4540-a82e-35ed86f4fd5e
# swapon /swap
# swapon
NAME  TYPE  SIZE USED PRIO
/swap file 1024M   0B   -2

Appears that the file with holes limitation is solved.

And in XFS too? (not merged yet)

https://www.spinics.net/lists/linux-xfs/msg17823.html

@marcosfrm

This comment has been minimized.

Copy link
Contributor Author

commented Jul 10, 2018

fallocate alocates stuff without holes. Ubuntu is using it by default on EXT4:

https://salsa.debian.org/installer-team/partman-swapfile/blob/1/finish.d/create_swapfile#L38

This will be supported on XFS starting with 4.18:

https://lkml.org/lkml/2018/6/5/888

@marcosfrm marcosfrm changed the title swapon and files with holes swapon and fallocated files Jul 10, 2018

karelzak added a commit that referenced this issue Jan 21, 2019

swapon: (man) cleanup note about holes
Addresses: #633
Signed-off-by: Karel Zak <kzak@redhat.com>
@karelzak

This comment has been minimized.

Copy link
Owner

commented Jan 21, 2019

It seems the XFS change is still not merged into Linus' tree.

Anyway, I have improved the note in the man pages.

@karelzak karelzak closed this Jan 21, 2019

@karelzak

This comment has been minimized.

Copy link
Owner

commented Jan 21, 2019

Ah, already merged as

commit 67482129cdabf7cede1301d2415ef4f0156d35cd
Author: Darrick J. Wong darrick.wong@oracle.com
Date: Thu May 10 08:38:15 2018 -0700

iomap: add a swapfile activation function
@marcosfrm

This comment has been minimized.

Copy link
Contributor Author

commented Jan 21, 2019

Please also edit sys-utils/swapon.8 to be inline with 77983e4. Cant we put the kernel version there (4.18 for XFS)?

BTW, Linux 5.0 will bring swap file support to Btrfs:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ed46ff3d423780fa5173b38a844bf0fdb210a2a7

(do not know if fallocate will work)

karelzak added a commit that referenced this issue Jan 22, 2019

swapon: rewrite section about swapfiles
* don't duplicate info on two places -- let's keep only small note
  in mkswap(8) man page, suggest to read swapon(8) man page

* add info about kernel versions for XFS and Btrfs swapfiles support

* use subsection in the NOTES

Addresses: #633
Signed-off-by: Karel Zak <kzak@redhat.com>
@karelzak

This comment has been minimized.

Copy link
Owner

commented Jan 22, 2019

Good points, fixed:

  • added info about the kernel versions
  • keep only link to swapon in mkswap man page
  • cleanup all the stuff
  • more details about btrfs requirements

karelzak added a commit that referenced this issue Jan 22, 2019

swapon: be more explicit about BTRFS
It seems nocow and nodatasum attributes are required.
See btrfs_swap_activate() in  https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ed46ff3d423780fa5173b38a844bf0fdb210a2a7

Addresses: #633
Signed-off-by: Karel Zak <kzak@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.