Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I was trying to install ruby on my remote server(this is a vm machine(debian) in a esxi server . ) I got this error:

The Command:

sudo apt-get install ruby1.8

Error :

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.

then I tried :

sudo dpkg --configure -a 

Output:

dpkg: unable to access dpkg status area: Read-only file system 

UPDATE:

output of mount

/dev/sda3 on / type ext4 (rw,errors=remount-ro)
tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
udev on /dev type tmpfs (rw,mode=0755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)
/dev/sda1 on /boot type ext4 (rw)
/dev/sdb1 on /home type ext4 (rw)

mount: warning: /etc/mtab is not writable (e.g. read-only filesystem).
       It's possible that information reported by mount(8) is not
       up to date. For actual information about system mount points
       check the /proc/mounts file.

UPDATE2:

cat /proc/mounts


rootfs / rootfs rw 0 0
none /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0
none /proc proc rw,nosuid,nodev,noexec,relatime 0 0
none /dev devtmpfs rw,relatime,size=1553128k,nr_inodes=216450,mode=755 0 0
none /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
/dev/disk/by-uuid/cf4fb4ae-6d12-407b-bf43-3b0daaaaaf74 / ext4 ro,relatime,errors=remount-ro,barrier=1,data=ordered 0 0
tmpfs /lib/init/rw tmpfs rw,nosuid,relatime,mode=755 0 0
tmpfs /dev/shm tmpfs rw,nosuid,nodev,relatime 0 0
/dev/sda1 /boot ext4 rw,relatime,barrier=1,data=ordered 0 0
/dev/sdb1 /home ext4 rw,relatime,barrier=1,data=ordered 0 0

UDPDATE 3

output of dmesg(some last part)

[1968636.237601] JBD2: Detected IO errors while flushing file data on sdb1-8
[1968772.229102] JBD2: Detected IO errors while flushing file data on sdb1-8
[1968789.799409] IPv6 addrconf: prefix with wrong length 56
[1968990.325125] IPv6 addrconf: prefix with wrong length 56
[1969190.801848] IPv6 addrconf: prefix with wrong length 56
[1969192.245363] JBD2: Detected IO errors while flushing file data on sdb1-8
[1969197.698223] IPv6 addrconf: prefix with wrong length 56
[1969223.105506] JBD2: Detected IO errors while flushing file data on sdb1-8
[1969349.119764] JBD2: Detected IO errors while flushing file data on sdb1-8
[1969398.205686] IPv6 addrconf: prefix with wrong length 56
[1969598.713179] IPv6 addrconf: prefix with wrong length 56
[1969607.241633] JBD2: Detected IO errors while flushing file data on sdb1-8
[1969799.220758] IPv6 addrconf: prefix with wrong length 56
[1969825.462909] JBD2: Detected IO errors while flushing file data on sdb1-8
[1969831.231049] JBD2: Detected IO errors while flushing file data on sdb1-8
[1969999.728348] IPv6 addrconf: prefix with wrong length 56
[1970200.247944] IPv6 addrconf: prefix with wrong length 56
[1970221.321558] JBD2: Detected IO errors while flushing file data on sdb1-8
[1970253.105491] JBD2: Detected IO errors while flushing file data on sdb1-8

/var/log/syslog output:

enter image description here

share|improve this question
    
The output of mount is not reliable, especially since your root fs appears to be read-only. Can you post the output of cat /proc/mounts as well? –  mrb Aug 29 '12 at 17:06
    
please check the update2 –  Subhransu Aug 29 '12 at 17:11
add comment

2 Answers

up vote 6 down vote accepted

Your root filesystem (/) is mounted read-only as the /dev/disk/... line in /proc/mounts shows. The reason for this could be that a disk error was detected on boot (errors=remount-ro option) or subsequent I/O error.

Check the kernel logs for any errors with the dmesg command and look in /var/log/syslog or /var/log/messages (but note that these files do probably not contain the last log entries). If there are any I/O errors, you may need to replace the disk. If not, boot to singe user mode and run fsck.ext4 UUID=cf4fb4ae-6d12-407b-bf43-3b0daaaaaf7 to try to fix the errors.

If fsck reports no errors and it is still read-only on reboot, you can run

sudo mount / -o remount,rw

to try to mount the disk read-write.

Looking at the log files in /var/log/ does not help much, as it is at the moment read-only.


Often, the reason why /var/lib/dpkg/lock cannot be locked is that an automatic system update runs in the background, but in your case it is specifically complaining about read-only filesystem.

share|improve this answer
    
I was going to +1 this but it's dangerous to just blindly remount rw unless you know why it's ro in the first place. It's better to just reboot into single user mode and run fsck. Only if it's clean (or fixed) should you boot back to rw state. If it's clean and still mounting ro, then perhaps try to force things. –  bahamat Aug 29 '12 at 21:21
    
@bahamat Thanks for your comment, I changed my answer accordingly. –  jofel Aug 29 '12 at 21:30
    
@jofel Please check the update3 - the output of dmesg , it seams like its io problem . what should be my next step ? –  Subhransu Aug 30 '12 at 2:48
    
@jofel should I do a tune2fs -c 0 -i 0d /dev/sda3 and reboot the system ? –  Subhransu Aug 30 '12 at 2:58
    
@Subhransu Depending how important the data on your root system partition is, I would try to make a backup first. I would then boot into single user mode (recovery mode) and then run fsck manually. The automatic fsck does often only report errors but does not fix them. So avoid unnecessary IO on a possible broken disk. The SMART-feature of the disk sometimes helps to detect if the disk is really broken. –  jofel Aug 30 '12 at 13:21
add comment

In one word, your disk is broken, replace a new one after backuping your data.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.