Swap on core


#1

Let’s suppose I want to add some swap space to my Ubuntu Core device. Don’t tell me not to please :slight_smile:

I make a file as /writable/swapfile (is this location okay?)
I mkswap /writable/swapfile and after swapon /writable/swapfile I now have swap and all is good.

To make the change permanent I would normally ninja a line in /etc/fstab to ensure my swap file is added on boot. However the /etc/fstab on core has a big warning:-

# Auto-generated by /init
# DO NOT EDIT THIS FILE BY HAND - YOUR CHANGES WILL BE OVERWRITTEN
# (See writable-paths(5) for details)

Ah, okay. Well, it says I need to “See writable-paths(5) for details”, so lets do that.

popey@localhost:~$ man writable-paths.5
man: command not found

Sad face.

  1. How do I maintain /etc/fstab
  2. How do I read man pages without man?

#2

Here are my old notes:

Create swap file as follows:

sudo fallocate -l 2G /var/tmp/swapfile
sudo chmod 600 /var/tmp/swapfile
sudo mkswap /var/tmp/swapfile

Then after each boot:

sudo swapon /var/tmp/swapfile

ubuntu core doesn’t have a way to automatically mount a swap file; ideas:


#3

Ooh! Thanks.

Looks like comment #11 from @ogra suggests I can edit /etc/default/swapfile to get one easily? That file has “SIZE=0” on mine, perhaps I should just set it and reboot to see what happens :slight_smile:

Edit: tried that, did nothing.


#4

filr a bug please … i’ll fix it :slight_smile:


#5

@popey, so, I did this:

~$ cat /proc/swaps 
Filename				Type		Size	Used	Priority
~$ sudo vi /etc/default/swapfile 
~$ cat /etc/default/swapfile
FILE=/var/tmp/swapfile.swp
SIZE=1000
~$ sudo systemctl enable --now swapfile.service
Created symlink from /etc/systemd/system/sysinit.target.wants/swapfile.service to /etc/systemd/system/swapfile.service.
~$ cat /proc/swaps 
Filename                                Type            Size    Used    Priority
/var/tmp/swapfile.swp                   file            1023996 0       -1

#6

Winner, thanks @chipaca.


#7

I’ve created Enabling swap on core and linked to it from the docs.