Support swap

Bug #1560942 reported by Kyle Fazzari
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Snappy
Fix Released
High
Unassigned
snapd
Invalid
Undecided
Unassigned
ubuntu-core-config (Ubuntu)
Fix Released
Medium
Unassigned

Bug Description

Enabling swap in Snappy is currently not possible. This is something that should be controlled by the gadget snap working with the OS snap, perhaps implemented as a swapfile on the writable partition.

For implementers: consider fallocate for swapfile creation-- it's much faster than dd.

Michael Vogt (mvo)
Changed in snappy:
status: New → Triaged
importance: Undecided → High
Revision history for this message
Dan Kegel (obdank) wrote :

The obvious manual workaround for the moment:
do something like this once:
  sudo fallocate -l 4G /var/tmp/swapfile
then do something this after each boot:
  sudo swapon /var/tmp/swapfile
'free' then shows the desired amount of swap.

Revision history for this message
Oliver Grawert (ogra) wrote :

adding ubuntu-core-config (though it might perhaps better suit in initramfs-tools-ubuntu-core).

in any case creating a swapfile and managing swapon/off is an image feature, unlikely to be handled by snapd.

Changed in ubuntu-core-config (Ubuntu):
status: New → Triaged
importance: Undecided → Medium
Oliver Grawert (ogra)
Changed in snapd:
status: New → Invalid
Revision history for this message
Kyle Fazzari (kyrofa) wrote :

Note that this was assigned to snapd as the mailing list discussion led me to believe this would be implemented via the gadget snap, which is something snapd would need to support no?

Revision history for this message
Oliver Grawert (ogra) wrote :

i guess it will either become a kernel cmdline option (that you set in the gadget indeed) to trigger a creation script in the initrd (if you need swap you perhaps want it really early because your system is low on ram ... i.e. before you clutter memory with userspace processes)

...or actually via a core snap configuration option that would be handled from a config hook ...

in the latter case snapd would need swapon and fallocate support in the core-support interface.
but i think userspace is to late for this and in the first case above, snapd wouldnt be involved at all.

Revision history for this message
Kyle Fazzari (kyrofa) wrote :

Good point, thanks ogra. Sorry for the noise!

Revision history for this message
Oliver Grawert (ogra) wrote :

heh, no problem, i appreciate your cleanup work ...

Revision history for this message
Mark Shuttleworth (sabdfl) wrote : Re: [Bug 1560942] Re: Support swap

Just to say, I think it makes sense that default swap behaviour should
be a core config element.

Revision history for this message
Oliver Grawert (ogra) wrote :

@mark:

so how about
"snap set core system.swap=512"

config:
  core:
    system:
      swap: 512 # size in MB|auto

where "auto" would select a certain percentage of free diskspace (somewhere between 5 and 10%)
if it is unset (the default to not scare SD card users away) there wont be swap.

Revision history for this message
Oliver Grawert (ogra) wrote :

@jdstrand:

any suggestion for a file location here ? (we need to add swap file creation support to the core-support interface, so fallocate and swapon execution should be supported plus a writable path for a swapfile)

Revision history for this message
Oliver Grawert (ogra) wrote :

actually, scratch that, i'll add a systemd service so the interface only needs write access to a config file and can use the existing implementation to en/disable services we already have in place.

Revision history for this message
Oliver Grawert (ogra) wrote :

ubuntu-core-config (0.6.40+ppa41) xenial; urgency=medium

  * add /etc/default/swapfile, /etc/systemd/system/swapfile.service and
    /usr/bin/mkswapfile to be managed by the core configure hook.

 -- Oliver Grawert <email address hidden> Fri, 10 Feb 2017 14:02:20 +0100

Changed in ubuntu-core-config (Ubuntu):
status: Triaged → Fix Committed
Michael Vogt (mvo)
Changed in snappy:
status: Triaged → Fix Committed
Revision history for this message
Oliver Grawert (ogra) wrote :

setting the snappy task back to in-progress.

i kept it open for the work on the configure hook which is not done yet.
the ubuntu-core-config change and core_support interface work are just infrastructure.
the actual final implementation still needs to happen in the hook script.

Changed in snappy:
status: Fix Committed → In Progress
assignee: nobody → Oliver Grawert (ogra)
Revision history for this message
Dan Kegel (dank) wrote :
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

@ogra is this still in progress? If you are not actively working on this could you kindly please update the state of the bug.

Revision history for this message
Oliver Grawert (ogra) wrote :

it is working via manual intervention after login like:

https://forum.snapcraft.io/t/enabling-swap-on-ubuntu-core/5440

i.e. i implemented the OS side of it ...

but we still do not have any "snap set system.swap=" option to steer it or set via a gadget configuration option in the yaml, this would be a snapd configuration task.

Changed in snappy:
assignee: Oliver Grawert (ogra) → nobody
Changed in ubuntu-core-config (Ubuntu):
status: Fix Committed → Fix Released
John Lenton (chipaca)
Changed in snappy:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.