Need Assistance?

In only two hours, with an average response time of 15 minutes, our expert will have your problem sorted out.

Server Trouble?

For a single, all-inclusive fee, we guarantee the continuous reliability, safety, and blazing speed of your servers.

Resolving Logrotate’s “Read-Only File System” Error

Efficient log file management is a critical aspect of system administration to ensure applications run smoothly without logs consuming disk space. Logrotate, a popular tool, automates the compression and rotation of log files. However, administrators may face challenges when logrotate encounters errors, such as the “read-only file system,” preventing it from renaming or rotating log files. In this guide, we focus on resolving Logrotate’s “Read-Only File System” error effectively.

The Issue

In a recent case, while performing log rotation on logs, the following error message appeared in the system logs:

error: error renaming /usr/local/php81/var/log/php-fpm.log.30.gz to /usr/local/php74/var/log/php-fpm.log.31.gz: Read-only file system

This error indicated that logrotate was unable to modify or rotate log files because the target filesystem was mounted as read-only. This could happen due to various reasons, such as system configuration issues, file system corruption, or system maintenance procedures that temporarily set file systems to read-only.

The Solution

To resolve this issue, we needed to ensure that logrotate had the appropriate write permissions to modify and rotate logs in the specified directories. The solution involved modifying the logrotate.service configuration file to explicitly grant read-write access to the directories where the logs were stored.

Edit the logrotate service file, Open the service file using the following command:

sudo vim /lib/systemd/system/logrotate.service

Add the line ReadWritePaths directive at the bottom of the service file to grant write access to the relevant log directories. For example:

ReadWritePaths=/usr/local/php81/var/log/

After saving the file, reload the systemd configuration to apply the changes:

sudo systemctl daemon-reload

Finally, restart the logrotate service:

sudo systemctl restart logrotate

To ensure there were no errors after restarting the service, check the status

sudo systemctl status logrotate

Conclusion

By adding the ReadWritePaths directive to the logrotate.service file, we successfully resolved the “Read-Only File System” error, allowing logrotate to continue managing and rotating log files. If you’re facing similar issues, this method can assist in resolving Logrotate’s “Read-Only File System” error and restoring proper log file management in your environment.

If you’re encountering difficulties in resolving Logrotate’s “Read-Only File System” error and need expert assistance, our team is here to help. Contact us for professional support to quickly resolve the issue and ensure seamless log management in your environment. Reach out today!

Liked!! Share the post.

Get Support right now!

Start server management with our 24x7 monitoring and active support team

Let us know your requirement.

Can't get what you are looking for?

Get Support Right Away!

Thank You

We have received your query and will get back to you soon.