{"id":59,"date":"2024-08-31T13:30:21","date_gmt":"2024-08-31T13:30:21","guid":{"rendered":"https:\/\/nicewarm.coffee\/wordpress\/?p=59"},"modified":"2024-12-12T11:25:54","modified_gmt":"2024-12-12T11:25:54","slug":"sharing-zram-via-nfs","status":"publish","type":"post","link":"https:\/\/nicewarm.coffee\/wordpress\/?p=59","title":{"rendered":"sharing zram via NFS"},"content":{"rendered":"\n<p>Apparently, 16GB memory is not enough to compile Firefox using clang with LTO. Since my mini PC has plenty of memory, I decided to create a zram device and share it via NFS.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>## Fedora - NFS server, 192.168.1.2\n### create a zram device and format it with ext4 without journaling\n$ cat \/etc\/mke2fs.conf \n... output omitted ...\n&#91;fs_types]\n\text4 = {\n\t\tfeatures = has_journal,extent,huge_file,flex_bg,metadata_csum,metadata_csum_seed,64bit,dir_nlink,extra_isize,orphan_file\n\t}\n\text4withoutjournal = {\n        \tfeatures = extent,huge_file,flex_bg,metadata_csum,metadata_csum_seed,64bit,dir_nlink,extra_isize,orphan_file\n\t}\n... output omitted ...\n\n### setting zram size as 16Gig\n$ cat \/etc\/systemd\/zram-generator.conf  \n&#91;zram0]\nzram-size = min(ram, 16384)\ncompression-algorithm = zstd\nmount-point = \/mnt\/zram\n\nfs-type = ext4withoutjournal\noptions = rw,nosuid,nodev,discard,X-mount.mode=1777\n\n$ sudo ln -s \/usr\/sbin\/mke2fs \/usr\/sbin\/mkfs.ext4withoutjournal\n\n$ ls -alF \/usr\/sbin\/mkfs.ext4withoutjournal \nlrwxrwxrwx. 1 root root 6 Aug 31 21:33 \/usr\/sbin\/mkfs.ext4withoutjournal -&gt; mke2fs*\n\n### reboot will disable the default zram swap and \/dev\/zram0 will now be mounted under \/mnt\/zram\n\n### check zram is mounted\n$ mount | grep zram\n\/dev\/zram0 on \/mnt\/zram type ext4 (rw,nosuid,nodev,relatime,seclabel,discard)\n\n### no_root_squash is required for root to write on nfs\n$ cat \/etc\/exports\n\/mnt\/zram 192.168.1.0\/24(rw,sync,no_root_squash)\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>## Gentoo - NFS client, 192.168.1.100\n### emerge nfs-utils\n$ sudo emerge net-fs\/nfs-utils\n\n### create a mount point and mount the zram\n$ sudo mkdir \/mnt\/nfs\/zram\n$ sudo mount -t nfs 192.168.1.2:\/mnt\/zram \/mnt\/nfs\/zram\n\n### check zram is mounted\n$ sudo mount | grep zram\n\/dev\/zram2 on \/var\/tmp type ext4 (rw,relatime,discard)\n192.168.1.2:\/mnt\/zram on \/mnt\/nfs\/zram type nfs4 (rw,relatime,vers=4.2,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=192.168.1.100,local_lock=none,addr=192.168.1.2)\n\n### create a 8Gig swapfile\n$ sudo fallocate -l 8Gib \/mnt\/nfs\/zram\/swapfile\n$ sudo chmod 600 \/mnt\/nfs\/zram\/swapfile\n\n### check swapfile is created\n$ ls -alFh \/mnt\/nfs\/zram\/swapfile \n-rw------- 1 root root 8.0G Aug 31 23:48 \/mnt\/nfs\/zram\/swapfile\n\n$ sudo mkswap \/mnt\/nfs\/zram\/swapfile\nSetting up swapspace version 1, size = 8 GiB (8589930496 bytes)\nno label, UUID=f910bbdf-1ff2-4c20-9bdb-f5f92bd37156\n$ sudo swapon -p 100 \/mnt\/nfs\/zram\/swapfile\n\n### verify swap\n$ sudo swapon --show\nNAME                   TYPE      SIZE   USED PRIO\n\/dev\/nvme0n1p6         partition   4G 404.9M   -2\n\/mnt\/nfs\/zram\/swapfile file        8G     0B  100\n\n### you can also use \/mnt\/nfs\/zram as portage tmpfs by setting PORTAGE_TMPDIR to utilize the remaining space\nPORTAGE_TMPDIR=\"\/mnt\/nfs\/zram\"<\/code><\/pre>\n\n\n\n<p>References:<br><a href=\"https:\/\/wiki.gentoo.org\/wiki\/Zram\">https:\/\/wiki.gentoo.org\/wiki\/Zram<\/a><br><a href=\"https:\/\/www.redhat.com\/sysadmin\/configure-nfs-linux\n\">https:\/\/www.redhat.com\/sysadmin\/configure-nfs-linux<br><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Apparently, 16Gig memory is not enough to compile Firefox using clang + LTO. Since my mini PC has plenty of memory, I decided to create a zram device and share it on NFS.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-59","post","type-post","status-publish","format-standard","hentry","category-hello-world"],"_links":{"self":[{"href":"https:\/\/nicewarm.coffee\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/59","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nicewarm.coffee\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nicewarm.coffee\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nicewarm.coffee\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nicewarm.coffee\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=59"}],"version-history":[{"count":10,"href":"https:\/\/nicewarm.coffee\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/59\/revisions"}],"predecessor-version":[{"id":90,"href":"https:\/\/nicewarm.coffee\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/59\/revisions\/90"}],"wp:attachment":[{"href":"https:\/\/nicewarm.coffee\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=59"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nicewarm.coffee\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=59"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nicewarm.coffee\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=59"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}