LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Read-only filesystem error (https://www.linuxquestions.org/questions/linux-newbie-8/read-only-filesystem-error-4175444098/)

Geoff_L 01-04-2013 01:57 AM

Read-only filesystem error
 
[SOLVED - please see my post at the end of the thread for the solution]

I'm trying to set up a compact, command-line only, debian-based virtual machine (VirtualBox OSE) and have plumped for Linux Voyage. After installation, I tried to install Apache and PHP but got the following errors:

W: Not using locking for read only lock file /var/lib/dpkg/lock
E: Unable to write to /var/cache/apt/
E: The package lists or status file could not be parsed or opened.

Doing ls -l /var/lib/dpkg/lock returns
-rw-r----- 1 root root 0 May 18 2012 /var/lib/dpkg/lock

Trying chmod +w /var/lib/dpkg/lock results in:
chmod: changing permissions of '/var/lib/dpkg/lock': Read-only file system

So I checked /etc/fstab and found for the root mount point:
/dev/hda1 / ext2 defaults,noatime,rw 0 0
I thought that the rw option would mean the partition was mounted read-write?! (I'm probably missing something, which is why I've posted this in the Newbie forum)

Trying touch /test.txt results in:
touch: cannot touch '/test.txt': Read-only file system
which confirms that '/' is mounted read-only.

Doing:
mount / -o remount,rw
touch /test.txt
creates the test file with no errors.

All pointers in the right direction gratefully received.

syg00 01-04-2013 03:14 AM

The mount option will initially mount it rw - but errors may change that. Been so long since I saw an actual ext2 filesystem, let's see what this gives
Code:

tune2fs -l /dev/hda1 | grep -i error

Geoff_L 01-04-2013 03:35 AM

Many thanks for jumping in.

Quote:

Originally Posted by syg00 (Post 4862677)
The mount option will initially mount it rw - but errors may change that. Been so long since I saw an actual ext2 filesystem, let's see what this gives
Code:

tune2fs -l /dev/hda1 | grep -i error

Errors behavior: Continue

Hope that's what you wanted.

syg00 01-04-2013 03:45 AM

Not really - I was half expecting (hoping seems inappropriate) for "remount-ro". How about
Code:

tune2fs -l /dev/hda1 | grep -i state
This will be particularly of interest once the filesystem goes read-only.

Geoff_L 01-04-2013 03:53 AM

Quote:

Originally Posted by syg00 (Post 4862688)
Not really - I was half expecting (hoping seems inappropriate) for "remount-ro". How about
Code:

tune2fs -l /dev/hda1 | grep -i state
This will be particularly of interest once the filesystem goes read-only.

Filesystem state: not clean

I'm now wondering whether it might be a good idea to reboot from the live CD and run fsck on /dev/hda1?

syg00 01-04-2013 04:10 AM

Stop wondering. Do it.
That will fix the filesystem (for now ?) - if there is an underlying problem with the (virtualised) hardware, this will recur. That's a whole 'nuther can of worms.

Geoff_L 01-04-2013 04:31 AM

Many thanks for the continued help.

I ran fsck on /dev/hda1 and, although fsck found no errors and tune2fs still shows Filesystem state: not clean, the filesystem now mounts read/write. Again, thanks.

jpollard 01-04-2013 07:56 AM

Depends on when you run tune2fs... If it is your root disk it will always show "not clean" as it is mounted read/write.

When the system first boots, the init process (the initrd) will mount the root filesystem read only.

If the system detects a problem (ext2 is subject to this), then it will not mount it read/write until you have repaired whatever it thinks is bad. Usually a "fsck -y" will do the trick, sometimes releasing a scratch file that was incompletely deleted or other common things. If fsck can't fix it (files lost, or directories...), then it is up to the administrator to decide what to do interactively. Once finished, another run of fsck should be done to confirm it - then a reboot.

Having root mounted read only during this prevents the system from trying to update the (corrupted) disk image during reboot that fsck may have just repaired.

Geoff_L 01-04-2013 12:20 PM

Thanks for the explanation -- much appreciated.

As this VM is a new install, I don't have much invested in it and so can start afresh. I'll investigate whether I can use ext3 or ext4 with Linux Voyage or look for an alternative very lightweight current distro on which to build a basic LAMP server.

Geoff_L 01-06-2013 11:39 PM

The solution identified above turned out to be a fluke and wasn't reproducible when I tried to create a second instance of the same distro (Voyage 0.8). The issue turns out to be because the distro is primarily designed to be used in embedded applications, typically with a CF card rather than a hard drive or SSD and so the system is configured to change the primary drive to read-only once initialisation is complete. To change this so that the drive remains read/write:

1. Log in as root
2. do remountrw
3. edit /etc/init.d/voyage-util by commenting out or removing the line "/usr/local/sbin/remountro" at about line 90. It might also help to comment out the echo command a line or two above this so that you don't see a "remounting / read-only" message just before the login prompt.

I hope this helps others.

metrocitydoctor 08-02-2013 02:46 AM

thanks
 
just try to fix the same problem with the solution mentioned above. thanks and it is ok to install now. :)


All times are GMT -5. The time now is 02:50 AM.