歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Linux文件系統變為只讀的修復

Linux文件系統變為只讀的修復

日期:2017/2/28 16:23:43   编辑:Linux教程

Linux系統重啟或無故變為只讀造成網站無法正常訪問的簡單臨時的做法:

一、

1、mount:
  用於查看哪個模塊輸入只讀,一般顯示為:

  /dev/hda1 on / type ext3 (rw)
  none on /proc type proc (rw)
  usbdevfs on /proc/bus/usb type usbdevfs (rw)
  none on /dev/pts type devpts (rw,gid=5,mode=620)
  /dev/hda5 on /home type ext3 (rw)
  none on /dev/shm type tmpfs (rw)
  /dev/hda2 on /usr/local type ext3 (rw)
  /dev/nb1 on /EarthView/RAW type ext3 (ro)(變為只讀了)


  2、如果發現有ro,就重新mount,或者umount以後再remount

  3、umount /dev/nb1
  如果發現有提示“device is busy”,找到是什麼進程使得他busy

  fuser -m /mnt/data 將會顯示使用這個模塊的pid
  fuser -mk /mnt/data 將會直接kill那個pid

  然後重新mount即可。

  4、還有一種方法是直接remount,命令為

  mount -o rw,remount /mnt/data


二、具體深入的做法,情況不同可以自行選擇:

服務器/var/log/messages報錯 :

end_request: I/O error, dev sda, sector 122194293 Buffer I/O error on device sda1, logical block 446493 lost page write due to I/O error on sda1

下面是整個處理全過程

[[email protected] ~]# fdisk -lu #第一步 :找出本地扇片所在的分區。
Disk /dev/sda: 73.4 GB, 73407868928 bytes
255 heads, 63 sectors/track, 8924 cylinders, total 143374744 sectors
Units = sectors of 1 * 512 = 512 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 63 4096574 2048256 83 Linux
/dev/sda2 4096575 75778604 35841015 83 Linux
/dev/sda3 75778605 129034079 26627737+ 83 Linux
/dev/sda4 129034080 143364059 7164990 5 Extended
/dev/sda5 129034143 139267484 5116671 83 Linux
/dev/sda6 139267548 143364059 2048256 82 Linux swap


[[email protected] ~]# tune2fs -l /dev/sda3 |grep "Block size" #找到block大小。
Block size: 4096

(122194293-75778605)*512/4096 =528691 利用公式算出邏輯塊地址

b = (int)((L-S)*512/B)

[[email protected] ~]# debugfs
debugfs 1.35 (28-Feb-2004)
debugfs: open /deb/sda3
/deb/sda3: No such file or directory while opening filesystem
debugfs: open /dev/sda3
debugfs: icheck 582391
Block Inode number
582391 277584
debugfs: ncheck 277584
Inode Pathname
277584 /users/inn.net.cn/data/upload/download/innshow004.rar
debugfs: quit
[[email protected] ~]#dd if=/dev/zero of=/dev/sda1 bs=4096 count=1 seek=582391 #找到這個快的文件之後,需要做好備份,我們強制把它設置為0字節。
[[email protected] ~]# sync

Copyright © Linux教程網 All Rights Reserved