美文网首页
硬盘read-only问题的解决

硬盘read-only问题的解决

作者: 布莱特杨 | 来源:发表于2021-06-29 21:35 被阅读0次

0 导语

最近遇到了一件非常头痛的事情,
……(此处问题描述容后再补充),
查阅了好几篇技术文档,尽管这些技术文档具有一定参考价值,但是没有一篇能够彻底解决问题,因此在彻底解决这个问题之后,我对我亲身经历的解决方法做了个总结。

1 硬盘解挂

$mount | grep /data
/dev/mapper/data on /data type ext4 (ro,relatime,stripe=512,data=ordered)
$lsof /data #查看是否有任务运行
COMMAND   PID     USER   FD   TYPE DEVICE SIZE/OFF      NODE NAME
bash    70244 yangming  cwd    DIR  253,3     4096 222953473 /data/project
lsof    70327 yangming  cwd    DIR  253,3     4096 222953473 /data/project
lsof    70328 yangming  cwd    DIR  253,3     4096 222953473 /data/project
$sudo fuser -k /data #用root权限杀掉这些占用磁盘的任务
$sudo umount /data #解挂

2 硬盘挂载尝试

2.1 两次失败的挂载

$sudo mount -o remount,rw /dev/mapper/data -t ext4 /data
mount: /data not mounted or bad option

       In some cases useful info is found in syslog - try
       dmesg | tail or so.
$sudo mount -o rw /dev/mapper/data -t ext4 /data
mount: wrong fs type, bad option, bad superblock on /dev/mapper/data,
       missing codepage or helper program, or other error

       In some cases useful info is found in syslog - try
       dmesg | tail or so.

2.2 查看文件系统分区表

$more /etc/fstab
#
# /etc/fstab
# Created by anaconda on Tue Nov 24 11:30:13 2015
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root /                       xfs     defaults        0 0
UUID=d089c41c-fc81-4073-8b84-3080e12b5048 /boot                   xfs     defaults        0 0
/dev/mapper/centos-home /home                   xfs     defaults        0 0
/dev/mapper/centos-swap swap                    swap    defaults        0 0
/dev/mapper/data        /data                   ext4    defaults        0 0

3 修复文件系统

注意: 在开始修复之前,要知道不可以用 fsck 检查已挂载的磁盘,这很可能会对磁盘造成永久性的伤害。因此在开始使用 fsck 之前,需要解挂载硬盘。

$sudo fsck -t ext4 /dev/mapper/data
fsck from util-linux 2.23.2
e2fsck 1.42.9 (28-Dec-2013)
/dev/mapper/data: recovering journal
/dev/mapper/data contains a file system with errors, check forced.
Pass 1: Checking inodes, blocks, and sizes
Deleted inode 230363028 has zero dtime.  Fix<y>? yes
Inode 242302182, i_blocks is 177680, should be 162536.  Fix<y>? yes
Inodes that were part of a corrupted orphan linked list found.  Fix<y>? yes
Inode 281875450 was part of the orphaned inode list.  FIXED.
Pass 2: Checking directory structure
Invalid inode number for '.' in directory inode 223021074.
Fix<y>? yes
Entry 'mysql.sock' in /software/biosoft/mysql/mysql-5.6.33 (265553036) has deleted/unused inode 265563382.  Clear<y>? yes
Pass 3: Checking directory connectivity
Unconnected directory inode 223021074 (/project/???)
Connect to /lost+found<y>? yes
Pass 4: Checking reference counts
Inode 222953473 ref count is 34, should be 35.  Fix<y>? yes
Unattached inode 222963827
Connect to /lost+found<y>? yes
Inode 222963827 ref count is 2, should be 1.  Fix<y>? yes
Unattached inode 222963923
Connect to /lost+found<y>? yes
Inode 222963923 ref count is 2, should be 1.  Fix<y>? yes
Unattached inode 222963924
Connect to /lost+found<y>? yes
Inode 222963924 ref count is 2, should be 1.  Fix<y>? yes
Unattached inode 222963925
Connect to /lost+found<y>? yes
Inode 222963925 ref count is 2, should be 1.  Fix<y>? yes
Unattached inode 222963926
Connect to /lost+found<y>? yes
Inode 222963926 ref count is 2, should be 1.  Fix<y>? yes
Unattached inode 222963927
Connect to /lost+found<y>? yes
Inode 222963927 ref count is 2, should be 1.  Fix<y>? yes
Unattached inode 222963928
Connect to /lost+found<y>? yes
Inode 222963928 ref count is 2, should be 1.  Fix<y>? yes
Inode 222963954 ref count is 1, should be 2.  Fix<y>? yes
Inode 222964059 ref count is 1, should be 2.  Fix<y>? yes
Inode 222964061 ref count is 1, should be 2.  Fix<y>? yes
Inode 223021039 ref count is 3, should be 2.  Fix<y>? yes
Inode 223021074 ref count is 3, should be 2.  Fix<y>? yes
Unattached inode 223021075
Connect to /lost+found<y>? yes
Inode 223021075 ref count is 2, should be 1.  Fix<y>? yes
Unattached inode 223021076
Connect to /lost+found<y>? yes
Inode 223021076 ref count is 2, should be 1.  Fix<y>? yes
Unattached inode 223021077
Connect to /lost+found<y>? yes
Inode 223021077 ref count is 2, should be 1.  Fix<y>? yes
Unattached inode 223021078
Connect to /lost+found<y>? yes
Inode 223021078 ref count is 2, should be 1.  Fix<y>? yes
yyPass 5: Checking group summary information
Block bitmap differences:  -(14200832--14206211) -(49594368--49807359) -(49840128--50106957) +(426344448--426348436) +(426348544--426356735) +(426371072--426377215) +(429064192--429070200) +(429070336--429080177) +(429094912--429096959) +(938508288--938999807) +(939032576--939524095) +(939556864--940048383) +(940081152--940572671) +(940605440--941096959) +(941129728--941621247) +(941654016--942145535) +(942178304--942669823) +(942702592--943194111) +(943226880--943718399) +(943751168--944242687) +(944275456--944766975) +(944799744--945291263) +(945324032--945815551) +(945848320--946339839) +(946372608--946864127) +(946896896--947388415) +(947421184--947912703) +(947945472--948436991) +(948469760--948961279) +(948994048--949485567) +(949518336--950009855) +(950042624--950534143) +(950566912--951058431) +(951091200--951582719) +(951615488--952107007) +(952139776--952631295) +(952664064--953155583) +(953188352--953679871) +(953712640--954204159) +(954236928--954728447) +(954761216--955252735) +(955285504--955777023) +(955809792--956301311) +(956334080--956825599) +(956858368--957349887) +(957382656--957874175) +(957906944--958398463) +(958431232--958922751) +(958955520--959447039) +(959479808--959971327) +(960004096--960495615) +(960528384--961019903) +(961052672--961544191) +(961576960--962068479) +(962101248--962592767) +(962625536--963117055) +(963149824--963641343) +(963674112--964165631) +(964198400--964689919) +(964722688--965214207) +(965246976--965738495) +(965771264--966262783) +(966295552--966787071) +(966819840--967311359) +(967344128--967835647) +(967868416--968359935) +(968392704--968884223) +(968916992--969408511) +(969441280--969932799) +(969965568--970457087) +(970489856--970981375) +(971014144--971505663) +(971538432--972029951) +(972062720--972554239) +(972587008--973078527) +(973111296--973602815) +(973635584--974127103) +(974159872--974651391) +(974684160--974695167) +(974696448--974845183) +(974845952--974846975) +(974848000--974852863) +(974854144--974863871) +(974864384--974866175) +(974866432--974868735) +(974870528--974871551) +(974872576--974875391) +(974876672--974879487) +(974880768--974882559) +(974882816--974884607) +(974884864--974887679) +(974888960--974889983) +(974891008--974901759) +(974903296--974905855) +(974907392--974911999) +(974913536--974914815) +(974915584--974919935) +(974921728--974923263) +(974923776--974926847) +(974927872--974929151) +(974929920--974932479) +(974934016--974936575) +(974938112--974939135) +(974940160--974941439) +(974942208--974946559) +(974948352--974950911) +(974952448--974955263) +(974956544--974960127) +(974960640--974962431) +(974962688--974965759) +(974966784--974970111) +(974970880--974974719) +(974974976--974978559) +(974979072--974987519) +(974989312--974990847) +(974991360--974993151) +(974993408--974995967) +(974997504--975000319) +(975001600--975002879) +(975003648--975005183) +(975005696--975006719) +(975007744--975009023) +(975009792--975012607) +(975013888--975016703) +(975017984--975021311) +(975022080--975025663) +(975026176--975027199) +(975028224--975029247) +(975030272--975033087) +(975034368--975035903) +(975036416--975037695) +(975038464--975040255) +(975040512--975042303) +(975042560--975045119) +(975046656--975049215) +(975050752--975052543) +(975052800--975057919) +(975058944--975062015) +(975063040--975063807) +(975065088--975065855) +(975067136--975068159) +(975069184--975070719) +(975071232--975073791) +(975075328--975077631) +(975079424--975082239) +(975083520--975085055) +(975085568--975087103) +(975087616--975090431) +(975091712--975092735) +(975093760--975098111) +(975099904--975100927) +(975101952--975103231) +(975104000--975107583) +(975108096--975111935) +(975112192--975114751) +(975116288--975119103) +(975120384--975122687) +(975124480--975127039) +(975128576--975132159) +(975132672--975135743) +(975136768--975139583) +(975140864--975142143) +(975142912--975144447) +(975144960--975146751) +(975147008--975148799) +(975149056--975150591) +(975151104--975152127) +(975153152--975161599) +(975163392--975167231) +(975167488--975169023) +(975169536--975171327) +(975171584--975173119) +(975173632--975175679) +(975208448--975208703) +(975210496--975211007) +(975212544--975212799) +(975214592--975215359) +(975216640--975217151) +(975218688--975220223) +(975220736--975222015) +(975222784--975225855) +(975226880--975229183) +(975230976--975235327) +(975237120--975238143) +(975239168--975241983) +(975243264--975245567) +(975247360--975252991) +(975253504--975255295) +(975255552--975256575) +(975257600--975259135) +(975259648--975263487) +(975263744--975269631) +(975269888--975271679) +(975271936--975275775) +(975276032--975277823) +(975278080--975279871) +(975280128--975281663) +(975282176--975285503) +(975286272--975289855) +(975290368--975291903) +(975292416--975294207) +(975294464--975297023) +(975298560--975301375) +(975302656--975304959) +(975306752--975309311) +(975310848--975312383) +(975312896--975314687) +(975314944--975320063) +(975321088--975330815) +(975331328--975337215) +(975337472--975340287) +(975341568--975344127) +(975345664--975348479) +(975349760--975352831) +(975353856--975357695) +(975357952--975360511) +(975362048--975363071) +(975364096--975367167) +(975368192--975370751) +(975372288--975374591) +(975376384--975378687) +(975380480--975382271) +(975382528--975385343) +(975386624--975389183) +(975390720--975392511) +(975392768--975394303) +(975394816--975398143) +(975398912--975402495) +(975403008--975405311) +(975407104--975409407) +(975411200--975412735) +(975413248--975416063) +(975417344--975419135) -1842974648
Fix<y>? yes
Free blocks count wrong for group #433 (1064, counted=6444).
Fix<y>? yes
Free blocks count wrong for group #1513 (16384, counted=32768).
Fix<y>? yes
Free blocks count wrong for group #1514 (0, counted=32768).
Fix<y>? yes
Free blocks count wrong for group #1515 (0, counted=32768).
Fix<y>? yes
Free blocks count wrong for group #1516 (0, counted=32768).
Fix<y>? yes
Free blocks count wrong for group #1517 (0, counted=32768).
Fix<y>? yes
Free blocks count wrong for group #1518 (0, counted=32768).
Fix<y>? yes
Free blocks count wrong for group #1519 (0, counted=32768).
Fix<y>? yes
Free blocks count wrong for group #1521 (0, counted=32768).
Fix<y>? yes
Free blocks count wrong for group #1522 (0, counted=32768).
Fix<y>? yes
Free blocks count wrong for group #1523 (0, counted=32768).
Fix<y>? yes
Free blocks count wrong for group #1524 (0, counted=32768).
Fix<y>? yes
Free blocks count wrong for group #1525 (0, counted=32768).
Fix<y>? yes
Free blocks count wrong for group #1526 (0, counted=32768).
Fix<y>? yes
Free blocks count wrong for group #1527 (0, counted=32768).
Fix<y>? yes
Free blocks count wrong for group #1528 (0, counted=32768).
Fix<y>? yes
Free blocks count wrong for group #1529 (28082, counted=32768).
Fix<y>? yes
Free blocks count wrong for group #56243 (15723, counted=15724).
Fix<y>? yes
Free blocks count wrong for group #72896 (26747, counted=28640).
Fix<y>? yes
Free blocks count wrong (1036196707, counted=1036772123).
Fix<y>? yes
yyyyInode bitmap differences:  -230363028y -281875450
Fix<y>? yes
yyFree inodes count wrong for group #56240 (707, counted=708).
Fix<y>? yes
Free inodes count wrong for group #68817 (3692, counted=3693).
Fix<y>? yes
Free inodes count wrong (332591299, counted=332591301).
Fix<y>? yes

/dev/mapper/data: ***** FILE SYSTEM WAS MODIFIED *****
/dev/mapper/data: 2953019/335544320 files (1.0% non-contiguous), 1647582437/2684354560 blocks

4 重新挂载

文件系统修复后,输入以下命令将其重新挂载。

$sudo mount -o rw /dev/mapper/data -t ext4 /data
$cd /data/project #进入磁盘目录
$touch test #创建新测试文件
$ll test #查看测试文件
-rw-r--r-- 1 yangm test 0 Jun 28 21:32 test
$rm -f 1 #删除测试文件

挂载后硬盘可创建文件,说明成功解决问题!

布莱特杨
2021-06-28 22:10

相关文章

网友评论

      本文标题:硬盘read-only问题的解决

      本文链接:https://www.haomeiwen.com/subject/aqpqultx.html