0

I have an application responsible for the URL Routing of my other projects I developed while under Windows environment.

Now that I have a Linux environment, set in a Virtual Machine, and I can't regenerate the routes of my applications because the SQLite file I use to store the informations apparently cannot be written by the routines in my PHP applications.

I'm receiving a PDOException with the following message:

SQLSTATE[HY000]: General error: 8 attempt to write a readonly database

I've read this stack saying the parent folder of the SQLite file must be writable too. Well... I'm new in the Linux world and I'm solving several small problems one at a time and although I understand this... restrictive policy Linux has/have, I don't know how to fix this.

The Windows partition where the files are being stored, accordingly to the tutorials I've read in order to allow them to be accessed within the guest (Linux), show me I'm the owner:

Folder Permissions

And I've read PHP scripts run with a different user or group. What should I do?

Sigh... I'm getting angry with this Linux environment...

Community
  • 1
  • 1
Bruno Augusto
  • 1,530
  • 2
  • 15
  • 44
  • Can you write (create) files in the Windows partition via the console? – Alejandro Arbiza Oct 11 '14 at 19:24
  • Yes, and I think I can because the Terminal says **bruno@pc**. I tried with 3rd-party applications like Sqliteman and it can't write the file too, saying the file is locked. – Bruno Augusto Oct 11 '14 at 19:31
  • My guess is that this is a permissions issue in the mounted partition. Which Linux are you using? – Alejandro Arbiza Oct 11 '14 at 20:03
  • Linux Mint 17. Accordingly to the tutorial I should add this line to **/etc/fstab**: `//192.168.0.13/WindosPartitionName /mnt/share/FolderName cifs username=bruno,password=mypassword,rw,uid=1000,gid=1000 0 0`. Another source said if I change both 1000 to 0 (zero) instead of me the owner would be root. – Bruno Augusto Oct 11 '14 at 20:08
  • Have you tried adding the parameters `file_mode` and `dir_mode` as shown here: http://community.linuxmint.com/tutorial/view/77 ? – Alejandro Arbiza Oct 11 '14 at 20:23
  • Well, I've added the extra params and at least the original error is not appearing anymore. However, now `I'm receiving `SQLSTATE[HY000]: General error: 5 database is locked`. And maybe because of this error I noticed the routine is taking too long to complete, even to show the error. And this is usually very fast. – Bruno Augusto Oct 11 '14 at 20:39
  • Would that be this error now then? http://stackoverflow.com/questions/8559623/sqlite-busy-the-database-file-is-locked-database-is-locked-in-wicket – Alejandro Arbiza Oct 11 '14 at 23:54
  • This *might* be the case because if try to add the routing entry manually in the database using Sqliteman, when I try to commit this new entry, it also reports that the database is locked but it tells me that there is another operation going on. But I have no clue on what to do and, again, this is happening only in the Linux environment. – Bruno Augusto Oct 12 '14 at 00:48
  • I'm sorry Bruno, I'm blank here. I still think that the problem is related to permissions... when you run Sqliteman: do you do it via sudo? – Alejandro Arbiza Oct 12 '14 at 13:10

1 Answers1

-1

After reading a comment in Ubuntu discussion board, I've got a partial answer for my problem. Apparently the file permissions on NFS mounted folders, which I think it's the Windows NTFS (filesystem), are poorly designed.

After this answer, I decided to move the SQLite file to somewhere else, outside the mounted folder. I received a new error saying the database file could not be open but this time I was already aware of the PDO SQLite limitation described here,that states the parent folder must also be writable.

Permissions fixed and everything worked. :)

After that, I noticed another comment ahead saying that this bug was fixed in Samba 3.2.5, which is weird because after running the smbstatus command I received as version as 4.1.6-Ubuntu.

Anyway... The point is that this comment also states that if you mount the partition using the nobrl option during CIFS mount, advisory locks do not propagate across the network.

I don't know what this means, I only know that after edit my /etc/fstab (see below) to include this option and restarting the Virtual Machine, everything worked.

//WindowsIP/SharedPartitionName /path/to/linux/folder cifs username=myusername,password=mypassword,rw,nobrl,uid=1000,gid=1000,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777    0   0

Thank you @AlejandroArbiza for the patience and I hope this helps someone in the future.

Community
  • 1
  • 1
Bruno Augusto
  • 1,530
  • 2
  • 15
  • 44