nextcloud/nextcloudpi

ncp-diag: Falsely reporting data in SD = yes, if root and data directories are BTRFS

Aberta

#1.509 aberto em 22 de jul. de 2022

 (0 comentário) (0 reação) (0 responsável)Shell (320 forks)auto 404
buggood first issue

Métricas do repositório

Stars
 (2.920 estrelas)
Métricas de merge de PR
 (Métricas PR pendentes)

Description

My Nextcloud is installed on a small x86-server with Debian using the curl-version of NCP. The root directory / is installed on a BTRFS partition.

I have used nc-datadir to move my data to a plugged in USB drive. Nevertheless, the system info in the NCP Panel, and, of course, ncp-diag still reports that my data are in the SD! Accordingly, system info complains that I should use nc-datadir to move your files to your plugged in USB drive.

Result from ncp-diag:

>>> You should use nc-datadir to move your files to your plugged in USB drive <<<

NextCloudPi version|v1.48.2
OS|Debian GNU/Linux 11. 5.10.0-16-amd64 (x86_64)
automount|yes
USB devices|sda sdb
>>> datadir|/media/USB*** <<<
>>> data in SD|yes <<<
data filesystem|btrfs
data disk usage|213G/932G
rootfs usage|19G/25G
swapfile|/dev/mmcblk1p3
dbdir|/media/USB***
Nextcloud check|ok
Nextcloud version|23.0.7.2
HTTPD service|up
PHP service|up
MariaDB service|up
Redis service|up
HPB service|up
Postfix service|up
internet check|ok
port check 80|open
port check 443|open
IP|192.168.***
gateway|192.168.***
interface|enp1s0
certificates|***
NAT loopback|no
uptime|1:11

I took a look at ncp-diag. In line 33 the location of the data directory is tested: echo "data in SD|$( [[ $( stat -fc%d / ) == $( stat -fc%d "$DATADIR" ) ]] && echo yes || echo no )"

If I understand it correctly, the stat command is used to compare the file system at the root directory / against the $DATADIR directory, where the Nextcloud data are stored. It compares the number of free inodes in each filesystem: If the numbers are identical data in SD = yes. Otherwise the result is no.

In my case, both directories, the root directory and the $DATADIR directory, reside on a BTRFS partition. BTRFS does not use inodes for its meta data. Accordingly, it will always report 0 as the number of free inodes!

Wouldn't it be better to test directly, if both directories are on the same device? This could be done via findmnt:

echo "data in SD|$( [[ $( findmnt -n -o SOURCE --target / ) == $( findmnt -n -o SOURCE --target "$DATADIR" ) ]] && echo yes || echo no )"

findmnt is part of the package util-linux, which, according to my knowledge, is automatically installed in Debian as well as in Raspbian/Raspberry PI OS.

Guia do colaborador