1

I have the following in my /etc/fstab, and /dev/sdb1 is correctly formatted as a swap space. swapon -a works without problems.

/dev/sdb1 none swap sw 0 0

However, every time I reboot the system, swapping is off. /var/log/syslog contains the following:

Sep  5 09:17:59 puffin systemd[1]: Activating swap /dev/sdb1...
Sep  5 09:17:59 puffin swapon[757]: /sbin/swapon: invalid option -- 'o'
Sep  5 09:17:59 puffin swapon[757]: Usage:
Sep  5 09:17:59 puffin swapon[757]:  swapon -a [-e] [-v] [-f]             enable all swaps from /etc/fstab
Sep  5 09:17:59 puffin swapon[757]:  swapon [-p priority] [-v] [-f] <special>  enable given swap
Sep  5 09:17:59 puffin swapon[757]:  swapon -s                            display swap usage summary
Sep  5 09:17:59 puffin swapon[757]:  swapon -h                            display help
Sep  5 09:17:59 puffin swapon[757]:  swapon -V                            display version
Sep  5 09:17:59 puffin swapon[757]: The <special> parameter:
Sep  5 09:17:59 puffin swapon[757]:  {-L label | LABEL=label}             LABEL of device to be used
Sep  5 09:17:59 puffin swapon[757]:  {-U uuid  | UUID=uuid}               UUID of device to be used
Sep  5 09:17:59 puffin swapon[757]:  <device>                             name of device to be used
Sep  5 09:17:59 puffin swapon[757]:  <file>                               name of file to be used
Sep  5 09:17:59 puffin systemd[1]: dev-sdb1.swap: Swap process exited, code=exited status=1

It seems that systemd is calling swapon with the -o option, which swapon does not recognize. I noticed that there exist some other versions of swapon that do support an -o option, for example here: http://man7.org/linux/man-pages/man8/swapon.8.html. However, the version of swapon that comes with Ubuntu 17.04 does not have an -o option.

Question: how can I fix this? In particular, where is systemd configured to use the swapon -o command? I cannot find the corresponding unit file; there are no files under /etc/systemd ending in .swap or containing the word swap.

Additional information: the command systemctl start dev-sdb1.swap also does not work. It fails, and journalctl -xe shows an error similar to the above.

Most answers to similar questions are for people who forgot to format their swap partitions. Note that this is a different problem. Thanks!

  • 1
    It may be unrelated, as the syslog output is interesting, but 17.04 comes with a swapfile instead of a swap partition by default if you install it fresh rather than upgrading from it. What's the output of swapon --show? – Zanna Sep 5 '17 at 13:36
  • I installed 17.04 by upgrading from an earlier version, so no swap file for me. The output of swapon --show is swapon: unrecognized option '--show'. The output of swapon -s is Filename Type Size Used Priority /dev/sdb1 partition 16777212 0 -1. – Peter Selinger Sep 5 '17 at 17:05
  • ok, clear... but another strange thing... your version of swapon doesn't recognise --show either... what about swapon --version? – Zanna Sep 5 '17 at 17:16
  • You probably have two problems. 1) sdb is probably a USB drive, correct? It may not be ready/mounted at the time it tries to open the swap partition, and 2) you should try using the UUID (UUID=)of the swap partition (sudo blkid) instead of /dev/sdb1. I'm not sure, but I think there is a parameter that you can place in fstab that will make it wait for the drive... but I don't know what it is... homework for you... – heynnema Sep 5 '17 at 18:20
  • ps: swapon -V should show version 2.29 for 17.04 – heynnema Sep 5 '17 at 18:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.