Fixed my problem.

While looking through /var/log/syslog, I noticed this line around the
same time swap mount failed.

BTRFS warning (device sda3): swapfile must not be copy-on-write

Then a few lines later...

systemd[1]: swap.img.swap: Failed with result 'exit-code'.
systemd[1]: Failed to activate swap /swap.img.
systemd[1]: Dependency failed for Swap.
systemd[1]: swap.target: Job swap.target/start failed with result 'dependency'.

Yes my root is on btrfs and I did not see this error before. So I
deleted /swap.img and started over.

$ sudo rm -rf /swap.img
$ sudo touch /swap.img
$ sudo chattr +C /swap.img
$ sudo fallocate -l 2G /swap.img
$ sudo chmod 600 /swap.img
$ sudo mkswap /swap.img
$ sudo swapon /swap.img

No error and "swapon --show" gives this:

NAME      TYPE SIZE USED PRIO
/swap.img file   2G   0B   -2

Just what I was expecting. So problem solved for me, maybe a check can
be put in to see if it's on btrfs and apply the 'chattr +C' option.

-- 
You received this bug notification because you are a member of Kernel
Packages, which is subscribed to linux in Ubuntu.
https://bugs.launchpad.net/bugs/1788321

Title:
  swapon failed: invalid argument

Status in linux package in Ubuntu:
  Confirmed
Status in util-linux package in Ubuntu:
  Invalid

Bug description:
  Environment:
   - Ubuntu 18.04.1 LTS
   - Linux 4.15.0-32-generic i686

  Description:
  When I try to mount my swap partition or my swap file, I get "swapon failed: 
invalid argument" .

  Steps to reproduce:
  1) sudo bash
  2) dd if=/dev/zero of=/swapfile bs=1024 count=524288
  3) mkswap /swapfile
  4) chown root:root /swapfile
  5) chmod 0600 /swapfile
  6) swapon /swapfile
  Last execution returns "swapon failed: invalid argument" .

  I'm almost sure it's a bug because I have no problems using Linux
  4.15.0-29-generic instead of Linux 4.15.0-32-generic. Also, no
  problems using Ubuntu 18.04.1 LTS Live CD.

  Regards.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1788321/+subscriptions

-- 
Mailing list: https://launchpad.net/~kernel-packages
Post to     : kernel-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~kernel-packages
More help   : https://help.launchpad.net/ListHelp

Reply via email to