This is admittedly some user error going on, but I’m hoping I can recover from it smoothly.
Right now my MariaDB service fails to run
root@DietPi:~# systemctl status mariadb
● mariadb.service - MariaDB 10.1.44 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Fri 2020-02-21 11:22:02 MST; 10min ag
o
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Process: 14447 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_P
OSITION (code=exited, status=1/FAILURE)
Process: 14355 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=
`/usr/bin/galera_recovery`; [ $? -eq 0 ] && systemctl set-environment _WSREP_START_POSITIO
N=$VAR || exit 1 (code=exited, status=0/SUCCESS)
Process: 14351 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (
code=exited, status=0/SUCCESS)
Process: 14348 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (c
ode=exited, status=0/SUCCESS)
Main PID: 14447 (code=exited, status=1/FAILURE)
Feb 21 11:21:32 DietPi systemd[1]: Starting MariaDB 10.1.44 database server...
Feb 21 11:21:33 DietPi mysqld[14447]: 2020-02-21 11:21:33 1995419440 [Note] /usr/sbin/mysqld
(mysqld 10.1.44-MariaDB-0+deb9u1) starting as process 14447 ...
Feb 21 11:22:02 DietPi systemd[1]: mariadb.service: Main process exited, code=exited
, status=1/FAILURE
Feb 21 11:22:02 DietPi systemd[1]: Failed to start MariaDB 10.1.44 database server.
Feb 21 11:22:02 DietPi systemd[1]: mariadb.service: Unit entered failed state.
Feb 21 11:22:02 DietPi systemd[1]: mariadb.service: Failed with result 'exit-code'.
I noticed there were some errors related to being able to write to the /var/lib/mysql directory
Feb 21 11:14:22 DietPi systemd[1]: Starting MariaDB 10.1.44 database server...
Feb 21 11:14:23 DietPi mysqld[13800]: 2020-02-21 11:14:23 1996009264 [Note] /usr/sbin/mysqld (mysqld 10.1.44-MariaDB-0+deb9u1) starting as process 13800 ...
Feb 21 11:14:23 DietPi mysqld[13800]: 2020-02-21 11:14:23 1996009264 [Warning] Can't create test file /var/lib/mysql/DietPi.lower-test
Feb 21 11:14:23 DietPi mysqld[13800]: [97B blob data]
Feb 21 11:14:23 DietPi mysqld[13800]: 2020-02-21 11:14:23 1996009264 [ERROR] Aborting
Feb 21 11:14:23 DietPi systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
Feb 21 11:14:23 DietPi systemd[1]: Failed to start MariaDB 10.1.44 database server.
When I look in that directory I can see that /var/lib/mysql is symlinked to /mnt/dietpi_userdata/mysql
root@DietPi:/var/lib# ls -l
total 84
drwxr-xr-x 2 root root 4096 Feb 20 20:04 alsa
drwxr-xr-x 5 root root 4096 Feb 14 15:53 apt
drwxr-xr-x 2 root root 4096 Mar 4 2019 dhcp
drwxr-xr-x 2 root root 4096 Sep 10 2018 dhcpcd5
drw-rw---- 8 dietpi dietpi 4096 Mar 10 2019 dietpi
drwxr-xr-x 7 root root 4096 Feb 14 16:00 dpkg
drwxr-xr-x 2 root root 4096 Jul 24 2019 fail2ban
drwxr-xr-x 2 root root 4096 Sep 27 2018 git
drwxr-xr-x 2 root root 4096 Mar 12 2018 misc
lrwxrwxrwx 1 root root 26 Mar 10 2019 mysql -> /mnt/dietpi_userdata/mysql
lrwxrwxrwx 1 root root 26 Jan 21 13:06 mysql.bak -> /mnt/dietpi_userdata/mysql
drwxr-xr-x 2 root root 4096 Nov 13 2018 ntp
drwxr-xr-x 2 root root 4096 Mar 4 2019 pam
drwxr-xr-x 4 root root 4096 Mar 10 2019 php
drwxr-xr-x 3 plex plex 4096 May 22 2019 plexmediaserver
drwxr-xr-x 2 root root 4096 Jul 24 2019 python
drwxr-x--- 2 redis redis 4096 Feb 21 11:14 redis
drwxr-xr-x 2 root root 4096 Mar 4 2019 resolvconf
drwxr-xr-x 3 root root 4096 Mar 10 2019 samba
drwx--x--x 4 root root 4096 Nov 13 2018 sudo
drwxr-xr-x 7 root root 4096 Oct 24 12:27 systemd
drwxr-xr-x 3 root root 4096 Oct 24 12:24 ucf
drwxr-xr-x 2 root root 4096 Oct 24 12:16 usbutils
However the /mnt/dietpi_userdata/mysql directory is empty.
root@DietPi:/mnt/dietpi_userdata# ls -l
total 0
This isn’t really surprising to me since all of my userdata is stored on an external USB drive. However something about the setup of where userdata is stored got messed up recently on my setup. When I review the drives available in dietpi drive manager it shows my rootfs (sd card) as the location of my userdata, and if I try to change this to my USB drive, it appears to work, but when I run drive manager again, the setting is not preserved.
Is there a way I can force dietpi to use my external drive as my userdata location?
I also tried manually defining the mysql data location in /etc/mysql/mariadb.conf.d/50-server.cnf but that just lead to mariadb still failing, just without any helpful errors I could see.
Some other info about my drives and mount points that could be helpful:
root@DietPi:/boot# ls -lah /mnt
total 40K
drwxr-xr-x 10 root root 4.0K Feb 15 15:39 .
drwxr-xr-x 22 root root 4.0K Mar 16 2019 ..
drwxr-xr-x 3 root root 4.0K May 13 2019 0827b932-2eb4-46ba-aab0-e7525d6af812
drwxr-xr-x 4 root root 4.0K Feb 20 19:44 85fb25d2-7a10-4e41-bbc1-57477df55a4b
drwxr-xr-x 2 root root 4.0K Feb 15 15:39 dietpi_userdata
drwxr-xr-x 2 root root 4.0K Mar 4 2019 ftp_client
drwxr-xr-x 2 root root 4.0K Mar 4 2019 nfs_client
drwxr-xr-x 2 root root 4.0K Mar 10 2019 pogo1
drwxr-xr-x 2 root root 4.0K Mar 10 2019 samba
drwxr-xr-x 2 root root 4.0K Mar 19 2019 SSD128GB
root@DietPi:/boot# cat /etc/fstab
# Please use "dietpi-drive_manager" to setup mounts
#----------------------------------------------------------------
# NETWORK
#----------------------------------------------------------------
//192.168.0.8/PogoPlug-2 /pogo1 cifs username=guest,password=,iocharset=utf8,uid=dietpi,gid=dietpi,file_mode=0770,dir_mode=0770,vers=3.0,_netdev,nofail,x-systemd.automount 0 0
#----------------------------------------------------------------
# TMPFS
#----------------------------------------------------------------
tmpfs /tmp tmpfs size=512M,noatime,lazytime,nodev,nosuid,mode=1777
tmpfs /DietPi tmpfs defaults,size=10m,noatime,nodev,nosuid,mode=1777 0 0
tmpfs /var/log tmpfs defaults,size=50m,noatime,nodev,nosuid,mode=1777 0 0
#----------------------------------------------------------------
# MISC: ecryptfs, vboxsf (VirtualBox shared folder), bind mounts
#----------------------------------------------------------------
#----------------------------------------------------------------
# SWAPFILE
#----------------------------------------------------------------
/var/swap none swap sw 0 0
#----------------------------------------------------------------
# PHYSICAL DRIVES
#----------------------------------------------------------------
PARTUUID=b8ef7a27-02 / ext4 noatime,lazytime,rw 0 1
PARTUUID=b8ef7a27-01 /boot vfat noatime,lazytime,rw 0 2
UUID=85fb25d2-7a10-4e41-bbc1-57477df55a4b /mnt/85fb25d2-7a10-4e41-bbc1-57477df55a4b ext4 noatime,lazytime,rw,nofail,noauto,x-systemd.automount
Should I manually transfer my userdata folder from the USB drive to the SD card and then use dietpi drive manger to reformat the USB and reassign the userdata from SD back to the USB?