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.
## Fedora - NFS server, 192.168.1.2
### create a zram device and format it with ext4 without journaling
$ cat /etc/mke2fs.conf
... output omitted ...
[fs_types]
ext4 = {
features = has_journal,extent,huge_file,flex_bg,metadata_csum,metadata_csum_seed,64bit,dir_nlink,extra_isize,orphan_file
}
ext4withoutjournal = {
features = extent,huge_file,flex_bg,metadata_csum,metadata_csum_seed,64bit,dir_nlink,extra_isize,orphan_file
}
... output omitted ...
### setting zram size as 16Gig
$ cat /etc/systemd/zram-generator.conf
[zram0]
zram-size = min(ram, 16384)
compression-algorithm = zstd
mount-point = /mnt/zram
fs-type = ext4withoutjournal
options = rw,nosuid,nodev,discard,X-mount.mode=1777
$ sudo ln -s /usr/sbin/mke2fs /usr/sbin/mkfs.ext4withoutjournal
$ ls -alF /usr/sbin/mkfs.ext4withoutjournal
lrwxrwxrwx. 1 root root 6 Aug 31 21:33 /usr/sbin/mkfs.ext4withoutjournal -> mke2fs*
### reboot will disable the default zram swap and /dev/zram0 will now be mounted under /mnt/zram
### check zram is mounted
$ mount | grep zram
/dev/zram0 on /mnt/zram type ext4 (rw,nosuid,nodev,relatime,seclabel,discard)
### no_root_squash is required for root to write on nfs
$ cat /etc/exports
/mnt/zram 192.168.1.0/24(rw,sync,no_root_squash)
## Gentoo - NFS client, 192.168.1.100
### emerge nfs-utils
$ sudo emerge net-fs/nfs-utils
### create a mount point and mount the zram
$ sudo mkdir /mnt/nfs/zram
$ sudo mount -t nfs 192.168.1.2:/mnt/zram /mnt/nfs/zram
### check zram is mounted
$ sudo mount | grep zram
/dev/zram2 on /var/tmp type ext4 (rw,relatime,discard)
192.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)
### create a 8Gig swapfile
$ sudo fallocate -l 8Gib /mnt/nfs/zram/swapfile
$ sudo chmod 600 /mnt/nfs/zram/swapfile
### check swapfile is created
$ ls -alFh /mnt/nfs/zram/swapfile
-rw------- 1 root root 8.0G Aug 31 23:48 /mnt/nfs/zram/swapfile
$ sudo mkswap /mnt/nfs/zram/swapfile
Setting up swapspace version 1, size = 8 GiB (8589930496 bytes)
no label, UUID=f910bbdf-1ff2-4c20-9bdb-f5f92bd37156
$ sudo swapon -p 100 /mnt/nfs/zram/swapfile
### verify swap
$ sudo swapon --show
NAME TYPE SIZE USED PRIO
/dev/nvme0n1p6 partition 4G 404.9M -2
/mnt/nfs/zram/swapfile file 8G 0B 100
### you can also use /mnt/nfs/zram as portage tmpfs by setting PORTAGE_TMPDIR to utilize the remaining space
PORTAGE_TMPDIR="/mnt/nfs/zram"
References:
https://wiki.gentoo.org/wiki/Zram
https://www.redhat.com/sysadmin/configure-nfs-linux