Support swap

Bug #1560942 reported by Kyle Fazzari on 2016-03-23
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Snappy
High
Oliver Grawert
snapd
Undecided
Unassigned
ubuntu-core-config (Ubuntu)
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) on 2016-04-20
Changed in snappy:
status: New → Triaged
importance: Undecided → High
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.

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) on 2017-02-08
Changed in snapd:
status: New → Invalid
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?

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.

Kyle Fazzari (kyrofa) wrote :

Good point, thanks ogra. Sorry for the noise!

Oliver Grawert (ogra) wrote :

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

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

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.

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)

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.

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) on 2017-02-10
Changed in snappy:
status: Triaged → Fix Committed
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)
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers