Problems with disk and BTRFS

Hi,

So I have been working for some years now with my NCP setup. I’m running an instance with RockPro64, SD and a HDD with ncdata in a btrfs filesystem subvolume. However, some days ago, the HDD went to read-only filesystem. So I took a new HDD, format it on my PC with btrfs and created a ncdata subvolume. Then put all the ncdata from the old HDD to the new ncdata subvolume. Then I put the new HDD in the RockPro64 and it goes to maintenance mode. Taking out the /dev/sda1 (the HDD) line in the /etc/fstab, it boots well, but I can’t mount the BTRFS filesystem.

So I tried to format it with ncp-format-USB. This tool tried to format the root filesystem in the SD (/dev/mm…something) instead of my HDD, but the ncdatabase is there, so it didn’t do it. The message said it would not delete the database.

So, I want to warn you about the tool because it can incorrectly detect the device to format. And at the same time, I want to ask how I should format my drive to get it working.

EDIT: you can find my ncp-report below.
Thank you in advance.

<–! Paste this in GitHub report →

NextcloudPi diagnostics

NextcloudPi version  v1.52.0
NextcloudPi image    NextCloudPi_10-08-21
OS                   Armbian 21.11.0-trunk Buster \l . 4.4.213-rockchip64 (aarch64)
automount            yes
USB devices          none
datadir              /media/USBdrive/ncdata (doesn't exist)
rootfs usage         8,0G/29G
swapfile             /var/swap
dbdir                /var/lib/mysql
Nextcloud check      error
HTTPD service        up
PHP service          up
MariaDB service      up
Redis service        up
HPB service          down
Postfix service      up
Internet check       ok
Public IPv4          ***REMOVED SENSITIVE VALUE***
Public IPv6          ***REMOVED SENSITIVE VALUE***
Port 80              closed
Port 443             closed
IP                   ***REMOVED SENSITIVE VALUE***
Gateway              ***REMOVED SENSITIVE VALUE***
Interface            eth0
Certificates         ***REMOVED SENSITIVE VALUE***
NAT loopback         no
Uptime               2min

Nextcloud configuration

{"reqId":"Nz6vIQDNV9RLUnfE6Y4d","level":2,"time":"2023-06-01T10:32:48+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Temporary directory /media/USBdrive/ncdata/tmp is not present or writable","userAgent":"--","version":"21.0.4.1"}
Your data directory is invalid
Ensure there is a file called ".ocdata" in the root of the data directory.

Cannot create "data" directory
This can usually be fixed by giving the webserver write access to the root directory. See https://docs.nextcloud.com/server/21/go.php?to=admin-dir_permissions

An unhandled exception has been thrown:
Exception: Environment not properly prepared. in /var/www/nextcloud/lib/private/Console/Application.php:168
Stack trace:
#0 /var/www/nextcloud/console.php(99): OC\Console\Application->loadCommands()
#1 /var/www/nextcloud/occ(11): require_once('/var/www/nextcl...')
#2 {main}
HTTPd logs

[Thu Jun 01 10:36:53.294821 2023] [ssl:warn] [pid 1929:tid 547679436816] AH01909: localhost:4443:0 server certificate does NOT include an ID which matches the server name
[Thu Jun 01 10:36:53.295431 2023] [ssl:error] [pid 1929:tid 547679436816] AH02217: ssl_stapling_init_cert: can't retrieve issuer certificate! [subject: CN=rockpro64 / issuer: CN=rockpro64 / serial: 7DF15F248D7F5E434B83C8341E8757F9BE4E8AF1 / notbefore: Oct  8 21:03:40 2021 GMT / notafter: Oct  6 21:03:40 2031 GMT]
[Thu Jun 01 10:36:53.295511 2023] [ssl:error] [pid 1929:tid 547679436816] AH02604: Unable to configure certificate localhost:4443:0 for stapling
[Thu Jun 01 10:36:53.305715 2023] [mpm_event:notice] [pid 1929:tid 547679436816] AH00489: Apache/2.4.56 (Debian) OpenSSL/1.1.1n configured -- resuming normal operations
[Thu Jun 01 10:36:53.305870 2023] [core:notice] [pid 1929:tid 547679436816] AH00094: Command line: '/usr/sbin/apache2'
[Thu Jun 01 10:36:55.435448 2023] [mpm_event:notice] [pid 1929:tid 547679436816] AH00493: SIGUSR1 received.  Doing graceful restart
[Thu Jun 01 10:36:55.470128 2023] [ssl:warn] [pid 1929:tid 547679436816] AH01909: localhost:4443:0 server certificate does NOT include an ID which matches the server name
[Thu Jun 01 10:36:55.470510 2023] [ssl:error] [pid 1929:tid 547679436816] AH02217: ssl_stapling_init_cert: can't retrieve issuer certificate! [subject: CN=rockpro64 / issuer: CN=rockpro64 / serial: 7DF15F248D7F5E434B83C8341E8757F9BE4E8AF1 / notbefore: Oct  8 21:03:40 2021 GMT / notafter: Oct  6 21:03:40 2031 GMT]
[Thu Jun 01 10:36:55.470540 2023] [ssl:error] [pid 1929:tid 547679436816] AH02604: Unable to configure certificate localhost:4443:0 for stapling
[Thu Jun 01 10:36:55.474433 2023] [mpm_event:notice] [pid 1929:tid 547679436816] AH00489: Apache/2.4.56 (Debian) OpenSSL/1.1.1n configured -- resuming normal operations
[Thu Jun 01 10:36:55.474518 2023] [core:notice] [pid 1929:tid 547679436816] AH00094: Command line: '/usr/sbin/apache2'
[Thu Jun 01 11:45:07.585859 2023] [mpm_event:notice] [pid 1929:tid 547679436816] AH00492: caught SIGWINCH, shutting down gracefully
[Thu Jun 01 11:45:25.359904 2023] [ssl:warn] [pid 1664:tid 548355186704] AH01909: localhost:4443:0 server certificate does NOT include an ID which matches the server name
[Thu Jun 01 11:45:25.360692 2023] [ssl:error] [pid 1664:tid 548355186704] AH02217: ssl_stapling_init_cert: can't retrieve issuer certificate! [subject: CN=rockpro64 / issuer: CN=rockpro64 / serial: 7DF15F248D7F5E434B83C8341E8757F9BE4E8AF1 / notbefore: Oct  8 21:03:40 2021 GMT / notafter: Oct  6 21:03:40 2031 GMT]
[Thu Jun 01 11:45:25.360766 2023] [ssl:error] [pid 1664:tid 548355186704] AH02604: Unable to configure certificate localhost:4443:0 for stapling
[Thu Jun 01 11:45:25.444966 2023] [ssl:warn] [pid 1884:tid 548355186704] AH01909: localhost:4443:0 server certificate does NOT include an ID which matches the server name
[Thu Jun 01 11:45:25.445465 2023] [ssl:error] [pid 1884:tid 548355186704] AH02217: ssl_stapling_init_cert: can't retrieve issuer certificate! [subject: CN=rockpro64 / issuer: CN=rockpro64 / serial: 7DF15F248D7F5E434B83C8341E8757F9BE4E8AF1 / notbefore: Oct  8 21:03:40 2021 GMT / notafter: Oct  6 21:03:40 2031 GMT]
[Thu Jun 01 11:45:25.445557 2023] [ssl:error] [pid 1884:tid 548355186704] AH02604: Unable to configure certificate localhost:4443:0 for stapling
[Thu Jun 01 11:45:25.454841 2023] [mpm_event:notice] [pid 1884:tid 548355186704] AH00489: Apache/2.4.56 (Debian) OpenSSL/1.1.1n configured -- resuming normal operations
[Thu Jun 01 11:45:25.454993 2023] [core:notice] [pid 1884:tid 548355186704] AH00094: Command line: '/usr/sbin/apache2'

Database logs


Nextcloud logs

tail: no se puede abrir '/media/USBdrive/ncdata/nextcloud.log' para lectura: No existe el fichero o el directorio

Please provide the exact fstab entry that was in-place prior to the drive swap.

I.e.

Are/were there any other partitions on the old HDD?

Is sda1 what was mounted directly at /media/USBdrive/ncdata previously?

What else was/is in /media/USBdrive?

The old drive had only one btrfs partition. However, it had other subvolumes (folders that I had on my pc). I can’t filnd a command to show this, but on a partitioner program I could see this:

imagen

ncdata, ncdata.old, etc are btrfs subvolumes.

sda1 was mounted at /media/USBdrive. sda1 has a ncdata folder (actually a subvolume) and other folders.

About /etc/fstab, I was silly enough not to make a backup (I thought the process would be straigthforward), but I think that the content of the file was this:

UUID=***** / ext4 defaults,noatime,commit=600,errors=remount-ro 0 1
tmpfs /tmp tmpfs defaults,nosuid 0 0
# a swapfile is not a swap partition, no line here
#   use  dphys-swapfile swap[on|off]  for that
UUID=**** /media/USBdrive/ btrfs defaults 0 0
UUID=**** /media/USBdrive/ncdata btrfs subvol=/@/ncdata defaults 0 0

UPDATE: I took the hdd and put it on a case to connect it through USB. ncp-format-USB did the same thing: it tried to delete the SD card. So maybe there is something wrong with ncp-format-USB. Maybe you could add an option in ncp-format-USB to select the device to format.

In any case, I still have the problem of not being able to mount my drive. This is pretty weird, because I can mount it on my PC.

The error information I am getting is:

Running nc-format-USB
mmcblk0p1 179:1 0 28,5G 0 part /
stat: no se puede leer la información del sistema de ficheros para '/media/USBdrive/ncdata': No existe el fichero o el directorio
ERROR: Data directory is on USB drive (or can't be determined) and removal of data directory was not explicitly allowed. Please move the data directory to SD before formatting the USB drive. If you are certain that the data directory is not on this USB drive, check 'Allow data directory removal'. Exiting...
Done. Press any key...

Maybe it is just not doing it because it can’t finde the ncdata folder, but still I don’t understand why in the first line the root appears…

Okay so if you had to replace your HDD, you’re actually replacing the entirety of /media/USBdrive not just the ncdata subvolume. Your replacement drive would need to match the layout exactly like the old one.

That all said, if you formatted it correctly on the external PC (creating the main volume that will serve as /media/USBdrive then creating the subvolume that will serve as /media/USBdrive/ncdata) you should be fine.

At that point you should not need to format in NCP. Just nc-automount.

What I’m not sure about is: how well NCP will automatically understand the usage of the subvolume. Did you set that up manually originally outside of NCP (i.e. at the OS level)? Also, I think you’re overlooking that you also need to bring over your main volume from your old HDD too.

You’re actually getting two distinct errors from nc-format-USB:

stat: no se puede leer la información del sistema de ficheros para ā€˜/media/USBdrive/ncdata’: No existe el fichero o el directorio

The first one isn’t going to let you format /media/USBdrive/ncdata. I suspect this is because you’re trying to format a subvolume, but you haven’t added the main volume yet.

ERROR: Data directory is on USB drive (or can’t be determined) and removal of data directory was not explicitly allowed. Please move the data directory to SD before formatting the USB drive. If you are certain that the data directory is not on this USB drive, check ā€˜Allow data directory removal’. Exiting…

This one is refusing to let you format your existing ncdatadirectory (ncdata). NCP doesn’t want to let you accidentally overwrite your data.

I think the problem is the use case.

The script is meant for someone who has the ncdata on the SD and is using a HDD for the first time, then uses this script before moving it to the HDD. In my cases the ncdata was already in the old HDD, so the script fails for this use case.

I am not sure why I could not mount my drive, but after formatting again as btrfs (no subvolumes) it worked properly.

I think this can be closed now.

2 Likes