UFS Add a Swap File on UFS

Hi everyone, every now and then I leave the crypt. I read the paragraph 14.7. Adding Swap Space in the FreeBSD Handbook, in particular the sub-paragraph 14.7.2. Creating a Swap File. I want to have more swap space but I guess is not easy to enlarge partition 3 and shrink partition 2 (see below) without a data loss. So perhaps, creating a swap file is the best choice for me now, without backup all disk and reinstall/reconfigure all the daemons, it's only a small home server but this operation eat me a lot of time.

My intent is to return back at the status of 11.x-RELEASE, at that time I never ran in troubles compiling ports. Starting from 12.x-RELEASE on, I get strange clang errors, here and there, not due to error in the source, but randomly, in different sources of the same port restarting the compilation (I guess an internal clang error, surely not a source error, I never investigated more). The first thing I thought about to solve this problem was to stop all services (named, apache24, mysql_server, cups, dovecot, svnserve, xrdp and xrdp_sesman) and this operation had calmed things down, but it didn't solve much.

I come to a conclusion: 'I need to fine tuning something in loader.conf and variables in sysctl'. I found something about that in this forum and tuned the system (more or less), but the problem still exist, not often like before, but exists. So it's about one month I experimented the make.conf variable MAKE_JOBS_NUMBER and set it to value 2 (4 in total), and the error no more come out.

Anyways, the last thing it come me in mind to have more breath, is to enlarge the swap space.

QUESTION 1: Can I create the swap file anywhere on the disk (except in /tmp, the content will be erased at reboot)? For example in /var directory, insted of /usr, like the example in the handbook (i.e. /var/swap0).

QUESTION 2: For your experience, a swap file can help to resolve what I guess (low resources and tuning).

thanks to you all for the answers.

Code:
ft-admin at master
~> df -achT
Filesystem   Type       Size    Used   Avail Capacity  Mounted on
/dev/ada0p2  ufs        285G     81G    181G    31%    /
devfs        devfs      1,0K    1,0K      0B   100%    /dev
tmpfs        tmpfs      1,1G     15M    1,1G     1%    /tmp
fdescfs      fdescfs    1,0K    1,0K      0B   100%    /dev/fd
procfs       procfs     4,0K    4,0K      0B   100%    /proc
total                   286G     81G    182G    31%

ft-admin at master
~> gpart show
=>       34  625142381  ada0  GPT  (298G)
         34          6        - free -  (3.0K)
         40       1024     1  freebsd-boot  (512K)
       1064  616561656     2  freebsd-ufs  (294G)
  616562720    8388608     3  freebsd-swap  (4.0G)
  624951328     191087        - free -  (93M)

ft-admin at master
~> neofetch
```                        `       ft-admin@master.void.lan
  ` `.....---.......--.```   -/    --------------------
  +o   .--`         /y:`      +.   OS: FreeBSD 13.2-RELEASE-p4 amd64
   yo`:.            :o      `+-    Uptime: 27 days, 6 hours, 22 mins
    y/               -/`   -o/     Packages: 1153 (pkg)
   .-                  ::/sy+:.    Shell: tcsh 6.22.04
   /                     `--  /    Terminal: /dev/pts/1
  `:                          :`   CPU: Intel Atom D525 (4) @ 1.800GHz [8.0°C]
  `:                          :`   GPU: Atom Processor D4xx/D5xx/N4xx/N5xx Integrated Graphics Controller
   /                          /    Memory: [---============] 989MiB / 4043MiB
   .-                        -.    CPU Usage: [---------------] 100%
    --                      -.     Disk (/): [----===========] 81G / 285G (31%)
     `:`                  `:`      Battery:
       .--             `--.        Local IP: 192.168.1.3
          .---.....----.           Users: ft-admin, root
                                   Locale: it_IT.UTF-8
 
It's better to look for another hardware where you can build your ports and host it as custom repository. This atom processor already have the max supported memory and building anything on it is just painful slow and waste of time.
For some ports like rust and llvm you will spend hours to build them and they can easy take like 16GB memory. So you will need around 20GB swap and it will be painful to see a failed port build after several hours of waiting if you run out of memory. It just not wort it.
 
Buy a bigger ssd -- they are quite inexpensive now -- and create a larger swap partition on it. May be put zfs on it as well. And copy over everything.
 
The content being erased at reboot isn't the problem, it's the fact you have /tmp on tmpfs(5). Which is a memory based filesystem. It kind of defeats the purpose if you put a swap file in there.

Ah, ok. Good to know.

It's better to look for another hardware where you can build your ports and host it as custom repository. This atom processor already have the max supported memory and building anything on it is just painful slow and waste of time.
For some ports like rust and llvm you will spend hours to build them and they can easy take like 16GB memory. So you will need around 20GB swap and it will be painful to see a failed port build after several hours of waiting if you run out of memory. It just not wort it.

Ahahahaahhah, yes, you are right. LLVM 13 and 15 just about 2 or 3 days with only 2 cores. Each one. But that machine is a mule, it's old and I use it as a server from 10-RELEASE (or 9-RELEASE, I don't remember), from the first installation I always upgraded it from version to version and FreeBSD is perfect for a server machine, it's a very good OS also for a desktop (DM). Few months ago I installed Xorg and XFCE and access it by RDP (from Windows. Yes, I know, I'm a beast) but most often from WinSCP and putty for maintenance.
I stopped working as firmware/software developer about 6 or 7 years ago, but I cannot leave without mess around.

Thank you all
 
Back
Top