Fix fallocate issue on cloud-init 19.4 for Fedora 33 cloud images

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello all,

I am writing to this list because I found out F33 cloud image cloud init support for creating swap files looks to be broken probably because of a known Linux 5.7+ kernel issue [1].

The problem is cloud-init is trying to create a new swap file by using fallocate command that is not working well (kernel is complaining the file has holes when executing swapon command just later). The easy workaround for this issue is to use dd command instead of fallocate command in cloud-init.

Because I don't know the whole procedure required for submitting a patch I am writing to you in the hope you can help me in having the F33 cloud image fixed.
Please find attached to this e-mail the simple fix for cloud init 19.4 I just wrote. The patch should apply the procedure documented in Fedora docs [2]

Thank you in advance.
Federico

[1] https://marcelhauri.ch/blog/swapon-swapfile-has-holes/ 
[2] https://docs.fedoraproject.org/en-US/Fedora/14/html/Storage_Administration_Guide/s2-swap-creating-file.html

diff --git a/cloudinit/config/cc_mounts.py b/cloudinit/config/cc_mounts.py
index c741c746..7b996295 100644
--- a/cloudinit/config/cc_mounts.py
+++ b/cloudinit/config/cc_mounts.py
@@ -252,8 +252,7 @@ def setup_swapfile(fname, size=None, maxsize=None):
         util.log_time(LOG.debug, msg, func=util.subp,
                       args=[['sh', '-c',
                              ('rm -f "$1" && umask 0066 && '
-                              '{ fallocate -l "${2}M" "$1" || '
-                              'dd if=/dev/zero "of=$1" bs=1M "count=$2"; } && '
+                              'dd if=/dev/zero "of=$1" bs=1M "count=$2" && '
                               'mkswap "$1" || { r=$?; rm -f "$1"; exit $r; }'),
                              'setup_swap', fname, mbsize]])
 
_______________________________________________
cloud mailing list -- cloud@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to cloud-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/cloud@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure

[Index of Archives]     [Fedora General Discussion]     [Older Fedora Users Archive]     [Fedora Advisory Board]     [Fedora Security]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Mentors]     [Fedora Package Announce]     [Fedora Package Review]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Coolkey]     [Yum Users]     [Big List of Linux Books]     [Yosemite News]     [Linux Apps]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]

  Powered by Linux