Fatal error: $CFG->dataroot is not configured properly, directory does not exist or is not accessible! Exiting.

Fatal error: $CFG->dataroot is not configured properly, directory does not exist or is not accessible! Exiting.

by Fro Lien -
Number of replies: 17

Dear all

This is the first time i asked about Moodle here. Please forgive me if my writing skills bad.


My issue 

  •  Fatal error: $CFG->dataroot is not configured properly, directory does not exist or is not accessible! Exiting.

Structure of our Moodle System

Our organization use Moodle as a E learning platform for children's. We built Moodle server on VMware ESXi 6.0 and we created a new virtual machine on ESXi for Moodle. In the VM, we installed Ubuntu Server 16.4 LTS. Then we install Moodle 2.0 on this server. But we store moodledata folder on another partition (dev/sdb1). moodledata patch was /var/lib/mysql/moodledata




Parmission of moodledata folder



Moodle folder place is /var/www/html/moodle



Today I start upgrade old Moodle version 2.0 to Moodle v3.6.3

After I upgrade Ubuntu Server v16.4 LTS to 18.4 LTS, I cannot access to our Moodle site. Error message is (Fatal error: $CFG->dataroot is not configured properly, directory does not exist or is not accessible! Exiting.)

I have no idea what is wrong. 


Please may I know any instructions to solve this issue. 

Thanks you.

(Edited by Helen Foster to remove screenshot - original submission Saturday, 30 March 2019, 1:32 PM)

Average of ratings: -
In reply to Fro Lien

Re: Fatal error: $CFG->dataroot is not configured properly, directory does not exist or is not accessible! Exiting.

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Hi

/var/lib/mysql/moodledata is an odd place for moodledata. Whatever, if you run 'sudo -u www-data -l www-data touch /var/lib/mysql/moodledata/junk' does it create that file?

P.S. You provide too much information, things like your site name and a password.
In reply to Visvanath Ratnaweera

Re: Fatal error: $CFG->dataroot is not configured properly, directory does not exist or is not accessible! Exiting.

by Fro Lien -

Hi Visvanath Ratnaweera

Thank you so much for your reply. I ran your commend in terminal. But I got an error message. back. Please have a look in screenshot.


In reply to Fro Lien

Re: Fatal error: $CFG->dataroot is not configured properly, directory does not exist or is not accessible! Exiting.

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Uups, I meant 'sudo -u www-data -g www-data touch /var/lib/mysql/moodledata/junk' (user www-data, group www-data).

I am still checking /var/lib/mysql for moodledata, since you said it worked before the upgrade. Otherwise listen to Ken.

In reply to Visvanath Ratnaweera

Re: Fatal error: $CFG->dataroot is not configured properly, directory does not exist or is not accessible! Exiting.

by Ken Task -
Picture of Particularly helpful Moodlers

This is the 3rd VM Ubuntu system under either VMWare or Azure where mysql was initially setup in a partition made manually for mysql. And that partition is the largest of all partitions on the system. 

Somewhere out in la-la-land there is a posting or advice or a script on installing Moodle in a Ubuntu VM that way and it's totally in-correct and potentially very problematic ... now, and in the future.

Bet if OP used the mysql client on that server and issued 'show databases;' command, one called 'moodledata' might show in the list and we know that's NOT a database.

OP might be in a situation .... if moodledata can't be moved now due to size ... another data device has to be created in VMware/Azure - 1TB sounds good.   That data device won't automagically be recognized by Ubuntu.   Device must be set up in the file system of Ubuntu, formatted, then mounted before OP can move moodledata to a place where is there is plenty of room.  And a Moodle march will require lots of room to have the 'stage' backups during the 'march'.

But, that still leaves a lot of waisted disk space as the database for a typical Moodle would never require that much space.  One should never use /var/lib/mysql for anything else ... not even site/course backups in directories at that location.  MySQL sees folders there as databases, doesn't it?

'spirit of sharing', Ken



In reply to Ken Task

Re: Fatal error: $CFG->dataroot is not configured properly, directory does not exist or is not accessible! Exiting.

by Fro Lien -

Hi Ken Task

Should I create new partition in VMware? Actually I am beginner for this process. I am ready to follow your instructions. Please let me know if there any option.

In reply to Visvanath Ratnaweera

Re: Fatal error: $CFG->dataroot is not configured properly, directory does not exist or is not accessible! Exiting.

by Fro Lien -
In reply to Fro Lien

Re: Fatal error: $CFG->dataroot is not configured properly, directory does not exist or is not accessible! Exiting.

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Hi

This confirms what Moodle complained: "Fatal error: $CFG->dataroot is not configured properly, directory does not exist or is not accessible!" Your web server can not write in the directory /var/lib/mysql/moodledata.

Do you have a basic understanding of the Unix/Linux command interface or just mechanically repeat what we say?
In reply to Visvanath Ratnaweera

Re: Fatal error: $CFG->dataroot is not configured properly, directory does not exist or is not accessible! Exiting.

by Fro Lien -

Hi Visvanath Ratnaweera

I know Unix/LInux command interface very well. I used Ubuntu Server over three years. So I know half of Ubuntu Server command. Yes you can give me any command and I am ready to follow.

One thing I forgot say that I upgrade Ubuntu Server to 18.4 LTS.

In reply to Fro Lien

Re: Fatal error: $CFG->dataroot is not configured properly, directory does not exist or is not accessible! Exiting.

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Hi

OK, that is a relief! Then I don't have to tell you that as the superuser you can destroy your system with one command! ;-(

No, you mentioned the system upgrade - it must have been a dist-upgrade. In that process the user www-data:www-data has lost the write privileges to the moodledata directory. As Ken explained you have put it in an unusual place, which is biting you now. Consider shifting it to a safer place. No, you don't have to install Moodle from scratch, or do you want to lose the 109 GB uploaded files? Follow Ken's instructions.
In reply to Fro Lien

Re: Fatal error: $CFG->dataroot is not configured properly, directory does not exist or is not accessible! Exiting.

by Ken Task -
Picture of Particularly helpful Moodlers

/var/lib/mysql should be reserved for database server files ONLY.
They all have ownerships/permissions for the mysql user: mysql

moodledata needs to be moved to /var/www/
and it's ownherships/permissions should be for the web server user - www-data.

** but ** only if one has enough space available on
/dev/sda1/ ... where /var/www/ resides.

to check:
cd /var/lib/mysql
du -h ./moodledata

That last command will scroll a lot.  At the end it should
give you total space used by all of moodledata

If that shows it can 'fit' in /var/www/
Then from /var/lib/mysql
mv moodledata /var/www/
Edit config.php file in /var/www/html/
and change the path to moodledata

Ownership for all moodledata would be www-data:www-data for Ubuntu.

** Also note: one cannot upgrade from 2.0 directly to highest 3.6.x.
One **must** upgrade in stages ...
https://docs.moodle.org/36/en/Upgrading is where you want to go.
But from 2.0 one has to upgrade the site from 2.0 -> 2.7 first.
Then check the site.   Working?
Backup ... code and DB.
Then upgrade to he next step 2.7 -> 2.9.highest.
Check site.  Working?Backup ... code and DB.

2.9.highest to 3.0.highest
check ok backup
3.0.highest to 3.1.highest.
Check site.  Backup code and DB.

Finally 3.1.highest to 3.6.x

At each stage, check server environment ... update component ... and see what moodle says about version of PHP and version of MySQL.

'spirit of sharing', Ken


In reply to Ken Task

Re: Fatal error: $CFG->dataroot is not configured properly, directory does not exist or is not accessible! Exiting.

by Fro Lien -

Hi Ken Task

I used du -h ./moodledata to check the size of moodledata. 



In reply to Ken Task

Re: Fatal error: $CFG->dataroot is not configured properly, directory does not exist or is not accessible! Exiting.

by Fro Lien -

I got an idea Ken. Should I reinstall Moodle from beginning. 


01. What what size should I assign for moodledata?

02. Should I create new partition or should I store moodle under /var/www/html?


Then I will restore all courses from old moodledata folder. 

In reply to Fro Lien

Re: Fatal error: $CFG->dataroot is not configured properly, directory does not exist or is not accessible! Exiting.

by Ken Task -
Picture of Particularly helpful Moodlers

Think you need to step back a bit and re-asses goal/plan/etc.

First, you are planning to 'march' a version 2.0 of moodle which is presently on the server with partitioning error.

Is that correct?

You upgraded the OS in place prior to checking what the plan was to be for 'marching'  the moodle upwards.  Is that correct?

To help a little: php -v, mysql -V ... IF your upgrade to the OS took PHP to a higher version that is beyond what Moodle 2.0 can run under, whatever you do drive wise to fix, is for naught.   Plus you can't access moodledata right now nor move it.

Install a new Moodle on same machine doesn't fix the mysql/partition issue.   Plus you loose what you had.

You can only restore courses from moodle backups ... mbz files ... they may not exist in moodledata.   In moodle files like backups are not stored with humanly recognizable names ... look at moodledata/filedir/   There are your files for Moodle.   You won't find any files in there named 'backup...whatever....mbz'.

Since it's in a VM the only option you have at present ... that would be, I think, the least amount of effort, is to extended the device upon which / resides - enough to be able to move moodledata and check to see if moodle was reporting the first error it found ... might be many/many if you upgraded in place and the PHP is too high now to run Moodle version 2.

'spirit of sharing', Ken


In reply to Ken Task

Re: Fatal error: $CFG->dataroot is not configured properly, directory does not exist or is not accessible! Exiting.

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Ken

Yes, "step back a bit and re-asses"! OP mistakenly tried to upgrade Moodle 2.0 (PHP 5.2-4) to 3.6 (PHP 7) in one step by dist-upgrading the Ubuntu Linux 16.4 (PHP 5.4?) to 18.4 (PHP 7.0) and now stuck - even without the "dataroot not writable" problem. Start at the beginning, in another Ubuntu 16.4 VM, is the simplest solution, provided that he has a site backup.
In reply to Ken Task

Re: Fatal error: $CFG->dataroot is not configured properly, directory does not exist or is not accessible! Exiting.

by Fro Lien -

Hi Ken

/dev/sda1/ only have 50GB where /var/www/

Should I extend for sda1?

In reply to Fro Lien

Re: Fatal error: $CFG->dataroot is not configured properly, directory does not exist or is not accessible! Exiting.

by Ken Task -
Picture of Particularly helpful Moodlers

My 2 cents ... think I'd set up a storage device of 1TB size and attach it to the Ubuntu VM hosting the moodle.   That you could do in VMWare *** but the Linux operating system won't automagically recognize that device (storage).

Check Ubuntu docs/official pages for how to use fdisk to find out device name, how to format, how to mount.

When you get that setup, then *move* moodledata to the newly added mount point.

Change config.php of Moodle code to the path of the moved moodledata.

You'll still have all that waisted space in /var/lib/mysql ... am thinking path of least resistance here.

You need to get that running first before thinking about/planning the upgrade march.

'spirit of sharing', Ken