Home > 学习 | 工作 > linux文件系统只读模式解决方法

linux文件系统只读模式解决方法

接上篇《centos系统出现IO错误》,悲剧的事情发生了,我用fsck并没有解决该问题!!

开机过程中报了好多failure,包括mount failure、mysql start failure、samba failure…开机后,貌似一切正常,但是我知道这只是表面的,因为/目录已经是只读模式了!

下面看看分区挂载情况吧:

[root@jst-cn ~]# more /etc/mtab
proc /proc proc rw 0 0
[root@jst-cn ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
[root@jst-cn ~]# more /etc/fstab
LABEL=/                 /dev/sda2             ext3    defaults        1 1
LABEL=/other            /other                  ext3    defaults        1 2
LABEL=/home             /home                   ext3    defaults        1 2
LABEL=/tmp              /tmp                    ext3    defaults        1 2
LABEL=/test             /test                   ext3    defaults        1 2
LABEL=/www              /www                    ext3    defaults        1 2
LABEL=/usr              /usr                    ext3    defaults        1 2
LABEL=/tools            /tools                  ext3    defaults        1 2
LABEL=/var              /var                    ext3    defaults        1 2
LABEL=/data             /data                   ext3    defaults        1 2
LABEL=/backup           /backup                 ext3    defaults        1 2
LABEL=/opt              /opt                    ext3    defaults        1 2
LABEL=/boot             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
LABEL=SWAP-sda14        swap                    swap    defaults        0 0
[root@jst-cn ~]# more /proc/mounts
rootfs / rootfs rw 0 0
/dev/root / ext3 ro,data=ordered 0 0
/dev /dev tmpfs rw 0 0
/proc /proc proc rw 0 0
/sys /sys sysfs rw 0 0
/proc/bus/usb /proc/bus/usb usbfs rw 0 0
devpts /dev/pts devpts rw 0 0
/dev/sda15 /other ext3 rw,data=ordered 0 0
/dev/sda12 /home ext3 rw,data=ordered 0 0
/dev/sda11 /tmp ext3 rw,data=ordered 0 0
/dev/sda10 /test ext3 rw,data=ordered 0 0
/dev/sda9 /www ext3 rw,data=ordered 0 0
/dev/sda8 /usr ext3 rw,data=ordered 0 0
/dev/sda7 /tools ext3 rw,data=ordered 0 0
/dev/sda6 /var ext3 rw,data=ordered 0 0
/dev/sda5 /data ext3 rw,data=ordered 0 0
/dev/sda3 /backup ext3 rw,data=ordered 0 0
/dev/sda2 /opt ext3 rw,data=ordered 0 0
/dev/sda1 /boot ext3 rw,data=ordered 0 0
[root@jst-cn ~]# mount -o remount,rw /
mount: can’t find / in /etc/fstab or /etc/mtab
[root@jst-cn ~]# mount -o remount,rw /dev/root
mount: can’t find /dev/root in /etc/fstab or /etc/mtab
[root@jst-cn ~]# mount -o remount,rw /dev/sda2
mount: /dev/sda2 not mounted already, or bad option
[root@jst-cn ~]# mount -f
proc on /proc type proc (rw)
mount: warning /etc/mtab is not writable (e.g. read-only filesystem).
       It’s possible that information reported by mount( is not
       up to date. For actual information about system mount points
       check the /proc/mounts file.
[root@jst-cn ~]# mount -a
mount: /dev/sda13 already mounted or /dev/sda2 busy
mount: /dev/sda15 already mounted or /other busy
mount: /dev/sda12 already mounted or /home busy
mount: /dev/sda11 already mounted or /tmp busy
mount: /dev/sda10 already mounted or /test busy
mount: /dev/sda9 already mounted or /www busy
mount: /dev/sda8 already mounted or /usr busy
mount: /dev/sda7 already mounted or /tools busy
mount: /dev/sda6 already mounted or /var busy
mount: /dev/sda5 already mounted or /data busy
mount: /dev/sda3 already mounted or /backup busy
mount: /dev/sda2 already mounted or /opt busy
mount: /dev/sda1 already mounted or /boot busy
mount: devpts already mounted or /dev/pts busy
mount: sysfs already mounted or /sys busy
[root@jst-cn ~]# vim /var/log/messages
Jan  8 15:24:35 jst-cn smartd[3019]: smartd version 5.38 [i686-redhat-linux-gnu] Copyright (C) 2002-8 Bruce Allen
Jan  8 15:24:35 jst-cn smartd[3019]: Home page is
http://smartmontools.sourceforge.net/
Jan  8 15:24:35 jst-cn smartd[3019]: Opened configuration file /etc/smartd.conf
Jan  8 15:24:35 jst-cn smartd[3019]: Configuration file /etc/smartd.conf was parsed, found DEVICESCAN, scanning devices
Jan  8 15:24:35 jst-cn smartd[3019]: Problem creating device name scan list
Jan  8 15:24:35 jst-cn smartd[3019]: Device: /dev/sda, opened
Jan  8 15:24:35 jst-cn smartd[3019]: Device /dev/sda: using ‘-d sat’ for ATA disk behind SAT layer.
Jan  8 15:24:35 jst-cn smartd[3019]: Device: /dev/sda, opened
Jan  8 15:24:35 jst-cn smartd[3019]: Device: /dev/sda, not found in smartd database.
Jan  8 15:24:36 jst-cn smartd[3019]: Device: /dev/sda, is SMART capable. Adding to "monitor" list.
Jan  8 15:24:36 jst-cn smartd[3019]: Device: /dev/sdb, opened
Jan  8 15:24:36 jst-cn smartd[3019]: Device /dev/sdb: using ‘-d sat’ for ATA disk behind SAT layer.
Jan  8 15:24:36 jst-cn smartd[3019]: Device: /dev/sdb, opened
Jan  8 15:24:36 jst-cn smartd[3019]: Device: /dev/sdb, found in smartd database.
Jan  8 15:24:36 jst-cn smartd[3019]: Device: /dev/sdb, is SMART capable. Adding to "monitor" list.
Jan  8 15:24:36 jst-cn smartd[3019]: Device: /dev/sdc, opened
Jan  8 15:24:36 jst-cn smartd[3019]: Device: /dev/sdc, Bad IEC (SMART) mode page, err=2, skip device
Jan  8 15:24:36 jst-cn smartd[3019]: Monitoring 0 ATA and 2 SCSI devices
Jan  8 15:24:36 jst-cn avahi-daemon[2989]: Server startup complete. Host name is jst-cn.local. Local service cookie is 1542459542.
Jan  8 15:24:36 jst-cn smartd[3021]: smartd has fork()ed into background mode. New PID=3021.

很简单的看出来/etc/fstab分区挂载出问题了,/目录挂载到/opt所在的分区/dev/sda2上面了!然后结合more /proc/mountsfdisk -l可以看出来:/目录所在分区应该是/dev/sda13(因为此时的df -h命令已经无效了)!

所以目前的工作就修改/etc/fstab中错误的分区信息!下面是操作步骤:

1、重启系统,用安装光盘centos5.4引导进入linux rescue模式,就是在光盘启动进入安装界面时,输入linux rescue回车,一直点OK,直到进入shell模式!(这时,我遇见比较悲剧的事情——光驱坏了!只好到其他机子上拆一个过来。)

image

2、进入shell模式后,我们直接进入系统挂载的目录/mnt/sysimage/dev/,貌似linux recuse模式系统一般是挂载在这里的!

image

3、然后我们编辑/mnt/sysimage/dev/etc/fstab文件,将错误的/挂载修改回来:

错误的/挂载是:LABEL=/                 /dev/sda2             ext3    defaults        1 1

正确的/挂载是:LABEL=/                 /                       ext3    defaults        1 1

4、wq保存退出,reboot,拿出光盘,正常进入系统——没有报错了!搞定!!

后记:

这次linux分区变成只读模式,给我造成了很大的困扰,都已经备份数据准备重新安装系统了——因为是内网服务器,不可能给我很长的时间去找google然后解决问题,重装无疑是耗时最短的。

不过我还是坚持将所知道的方案,一个又一个的进行测试,尽量使问题能得到解决。因为如果只是简单的重装解决问题,那么下次遇到同样的问题,我还是不会解决!

幸好,这次问题得到顺利解决,并让我学到了linux rescue这个知识点,相信再次遇到相同/相关的问题,我会顺利去解决的!

原创文章,转载请注明: 转载自三叶草

本文链接地址:http://www.anjing.me/1167.html

特别声明:商业网站转载需经作者同意,否则视为侵权!

相关日志

POSTED ON 2011/01/10, , , , , ,

Comments:10

Leave my own
  1. #1 coldplains
    11/01/10 回复

    依然看不懂~~沙发而已~~~

  2. #3 su
    11/01/10 回复

    可以进来你博客啊  哇

    • #4 三叶草
      11/01/10 回复

      额,现在我都快悲剧的无语了…不过总算是可以进博客了。

  3. #5 oalleno
    11/01/10 回复

    不懂linux,不折腾自己了就

  4. #6 奶牛
    11/01/10 回复

    木有手动改过的奶牛灰过…

  5. #7 Leyeang
    11/01/10 回复

    打酱油~
    我头一次这样回复,实属无奈,呵呵
    还是讲讲青菜mm吧,群众喜闻乐见的

  6. #9 未扬清
    11/01/11 回复

    这个还是可以看明白的

  7. #10 立青
    11/01/11 回复

    现在还没接触这个东西,不愧是高人,赞!

Leave a Reply

TOP