{"id":42,"date":"2019-04-19T21:50:08","date_gmt":"2019-04-19T21:50:08","guid":{"rendered":"https:\/\/online.osba.nl\/blog\/?p=42"},"modified":"2025-04-01T12:50:26","modified_gmt":"2025-04-01T10:50:26","slug":"not-enough-swap","status":"publish","type":"post","link":"https:\/\/blog.osba.nl\/en\/2019\/04\/19\/not-enough-swap\/","title":{"rendered":"Not enough swap"},"content":{"rendered":"\n<p>Installing lxml (for Synapse\/Matrix) gave problems on one of the Yunohosts ended in an error all the time.<\/p>\n\n\n\n<p>The error indicated not enough memory available at some point. The machines are fairly limited in RAM, so that explains. Extra swap space to the rescue!<\/p>\n\n\n\n<p>Armbian creates a swap partition and resizes the system partition (and the file system) to fit the uSD-card during first boot,  so there is no space available to increase swap space. <\/p>\n\n\n\n<p>Unfortunately, shrinking an ext4 file system is not as trivial as growing\/extending it. It helps that the uSD-card can easily be put in another system, avoiding the need to resize a (semi-) online root partition. <a href=\"http:\/\/www.microhowto.info\/howto\/reduce_the_size_of_an_ext2_ext3_or_ext4_filesystem.html\">One bit of information<\/a> made me rethink my shrink-root, grow-swap strategy: ostensibly a lot of writing might go on while resizing:<\/p>\n\n\n\n<p class=\"has-small-font-size\">The filesystems considered here tend to disperse data throughout the  underlying block device, so a large amount of copying may be needed even  if the filesystem has never been filled beyond the size it is being  reduced to. Do not start <code>resize2fs<\/code> unless you are confident you can allow it to finish. You can request a progress bar using the <code>-p<\/code> option.<\/p>\n\n\n\n<p>That is not what I expected or had taken in account. <\/p>\n\n\n\n<p>Since I do expect it to be a temporary measure, I decided to create a swap file instead of a swap partition. <a href=\"https:\/\/wiki.archlinux.org\/index.php\/swap\">Arch<\/a>, as usual, has a very helpful page on their wiki. There are some warnings against using swap files for other file system types especially with non-contigous swap files, but ext4 has no special mention. <\/p>\n\n\n\n<p>The steps for creating and using a swap file:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">fallocate -l 512M \/swapfile &amp;&amp; chmod 600 \/swapfile &amp;&amp; mkswap \/swapfile &amp;&amp; swapon \/swapfile<\/pre>\n\n\n\n<p>I used a 1GB file, and when lxml still wouldn&#8217;t compile, I added another gig of swap. <\/p>\n\n\n\n<p>&#8220;yunohost app install synapse&#8221; is running. If it ends in an error once more, I need to check whether the cause actually is still (out of) memory-related.<\/p>\n\n\n\n<p>To keep the swapfile configured across reboots, add a line to <code>\/etc\/fstab<\/code> like such: <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/swap           none            swap    sw      0       0<\/code><\/pre>\n\n\n\n<p><br><\/p>\n\n\n\n<p><\/p>\n<p class=\"wpf_wrapper\"><a class=\"print_link\" href=\"\" target=\"_blank\">Print this entry<\/a><\/p><!-- .wpf_wrapper -->","protected":false},"excerpt":{"rendered":"<p>Installing lxml (for Synapse\/Matrix) gave problems on one of the Yunohosts ended in an error all the time. The error indicated not enough memory available at some point. The machines are fairly limited in RAM, so that explains. Extra swap space to the rescue! Armbian creates a swap partition and resizes the system partition (and &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.osba.nl\/en\/2019\/04\/19\/not-enough-swap\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Not enough swap&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_locale":"en_US","_original_post":"42","activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":4,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"federated","footnotes":""},"categories":[6,11,4],"tags":[],"class_list":["post-42","post","type-post","status-publish","format-standard","hentry","category-armbian","category-matrix","category-yunohost","en-US"],"_links":{"self":[{"href":"https:\/\/blog.osba.nl\/wp-json\/wp\/v2\/posts\/42","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.osba.nl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.osba.nl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.osba.nl\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.osba.nl\/wp-json\/wp\/v2\/comments?post=42"}],"version-history":[{"count":3,"href":"https:\/\/blog.osba.nl\/wp-json\/wp\/v2\/posts\/42\/revisions"}],"predecessor-version":[{"id":863,"href":"https:\/\/blog.osba.nl\/wp-json\/wp\/v2\/posts\/42\/revisions\/863"}],"wp:attachment":[{"href":"https:\/\/blog.osba.nl\/wp-json\/wp\/v2\/media?parent=42"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.osba.nl\/wp-json\/wp\/v2\/categories?post=42"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.osba.nl\/wp-json\/wp\/v2\/tags?post=42"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}