]> git.ipfire.org Git - thirdparty/util-linux.git/commit - configure.ac
mkswap: check for holes and unwanted extentd in file
authorKarel Zak <kzak@redhat.com>
Wed, 9 Sep 2020 09:00:40 +0000 (11:00 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 9 Sep 2020 09:10:51 +0000 (11:10 +0200)
commit195025c29e2ae7b1b203fb18d57509f675e924cd
treec6015038b1b055612cb681b4e22b06f2c426589f
parent933f095feb6c695e02c9989d091c76cc1b8d6d4c
mkswap: check for holes and unwanted extentd in file

Let's make mkswap(8) more user-friend and report possible swapon
issues already when user initialize a swap file. The extents check
produces warnings, no exit with error.

  # dd if=/dev/zero of=img count=100 bs=1MiB
  # chmod 0600 img

  # fallocate --dig-hole --offset 64520192 --length 1MiB img
  # fallocate --dig-hole --offset 84520960 --length 1MiB img

  # ./mkswap img
  mkswap: extents check failed:
    - hole detected at offset 64520192 (size 1048576 bytes)
    - hole detected at offset 84520960 (size 1048576 bytes)
  file img can be rejected by kernel on swap activation.

  Setting up swapspace version 1, size = 100 MiB (104853504 bytes)
  no label, UUID=92091112-26b5-47aa-a02a-592e52528319

It checks for holes in the file, and for unknown, inline, shared and
deallocated extents.

Addresses: https://github.com/karelzak/util-linux/issues/1120
Signed-off-by: Karel Zak <kzak@redhat.com>
configure.ac
disk-utils/mkswap.c