nefelim4ag / systemd-swap

Script for creating hybrid swap space from zram swaps, swap files and swap partitions.
GNU General Public License v3.0
550 stars 81 forks source link

Cannot Create SwapFC on non-root Drive #205

Closed stellarpower closed 2 years ago

stellarpower commented 2 years ago

Hi,

Trying to create a swap dir on a separate partition to the root FS - that's pretty full already in my setup. The partition is mounted using udisksctl by a non-root user, so is under /media. I'm running Ubuntu 20.04.


zswap_enabled=0

#zswap_compressor=zstd
#zswap_max_pool_percent=25
#zswap_zpool=z3fold

zram_enabled=0

#zram_size=$(( RAM_SIZE / 4 ))
#zram_count=${NCPU}
#zram_streams=${NCPU}
#zram_alg=zstd
#zram_prio=32767

swapfc_enabled=1

#swapfc_force_use_loop=0
#swapfc_frequency=1
#swapfc_chunk_size=256M
#swapfc_max_count=32
#swapfc_min_count=0
#swapfc_free_ram_perc=35
#swapfc_free_swap_perc=15
#swapfc_remove_free_swap_perc=55
#swapfc_priority=50

#swapfc_path=/swap-dir-testing/swapfc  # This is okay
swapfc_path=/media/ubuntu/spinning_disk/SwapChunks # This isnae

#swapfc_nocow=1
#swapfc_directio=1
#swapfc_force_preallocated=0
#swapd_auto_swapon=1
#swapd_prio=1024
root@machine ~# systemctl status systemd-swap
● systemd-swap.service - Manage swap spaces on zram, files and partitions.
     Loaded: loaded (/lib/systemd/system/systemd-swap.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2021-10-10 18:23:17 BST; 4s ago
   Main PID: 210702 (bash)
     Status: "Not enough space for allocating chunk"
      Tasks: 1 (limit: 38360)
     Memory: 3.2M
        CPU: 81ms
     CGroup: /system.slice/systemd-swap.service
             └─210702 bash /usr/bin/systemd-swap start

Oct 10 18:23:17 opsis systemd-swap[210702]: INFO: swapD: searching swap devices
Oct 10 18:23:17 opsis systemd-swap[210760]: mkdir: cannot create directory ‘/media/ubuntu/spinning_disk’: Permission denied
Oct 10 18:23:17 opsis systemd-swap[210763]: stat: cannot read file system information for '/media/ubuntu/spinning_disk/SwapChunks': Permission denied
Oct 10 18:23:17 opsis systemd-swap[210702]: INFO: swapFC: on-demand swap activation at >20858 MiB memory usage
Oct 10 18:23:18 opsis systemd-swap[210768]: stat: cannot read file system information for '/media/ubuntu/spinning_disk/SwapChunks': Permission denied
Oct 10 18:23:18 opsis systemd-swap[210702]: WARN: swapFC: ENOSPC
Oct 10 18:23:18 opsis systemd-swap[210702]: WARN: swapFC: polling rate doubled to 2s
Oct 10 18:23:20 opsis systemd-swap[210780]: stat: cannot read file system information for '/media/ubuntu/spinning_disk/SwapChunks': Permission denied
Oct 10 18:23:20 opsis systemd-swap[210702]: WARN: swapFC: ENOSPC
Oct 10 18:23:20 opsis systemd-swap[210702]: WARN: swapFC: polling rate doubled to 4s

I imagine there could be a few root causes here - whether using an external partition is allowed; if I've not mounted it suitably; if it's a permission thing with systemd - I'll leave the issue generic for now, and if you are able to advise on what is more specifically going wrong, then am happy to make it more specific and add any more information if required - quite probably is a fault with my end, but am opening anyway in case. If only certain devices (usually) work, might be helpful to add to the docs.

Thanks!

oold commented 2 years ago

You're using the old bash script version of systemd-swap. I'm not sure if this works in the Python version, but you can try that one if you're still interested. I can see that it's trying to create the parent directory, but that fails already. Since there is no error reported for the actual directory, I'm going to assume that it's a btrfs volume because the output of btrfs subvolume create "$swapfc_path" is redirected to /dev/null. Otherwise, we'd probably see another mkdir error. Honestly, no idea what's actually happening there. I'll close this issue. Feel free to open another issue if it also happens with the current version.

stellarpower commented 2 years ago

A okay, I think I installed through the package manager, it's on 4.3.3. I'll try cloning and building the deb and see. Thanks :)