虚拟机用着用着,某一天突然文件系统大部分都变成只读了,真让人头疼
-bash: cannot create temp file for here-document: Read-only file system
用 fsck 进行检查并修复、果然发现并修复了很多的问题。reboot 重启后一切问题都解决了。
root@hdp-01:~# fsck /
fsck from util-linux 2.31.1
e2fsck 1.44.1 (24-Mar-2018)
/dev/sda2 contains a file system with errors, check forced.
Pass 1: Checking inodes, blocks, and sizes
HTREE directory inode 1062887 has an invalid root node.
Clear HTree index<y>? yes
HTREE directory inode 1063356 has an invalid root node.
Clear HTree index<y>? yes
Deleted inode 1966091 has zero dtime. Fix<y>? yes
Inodes that were part of a corrupted orphan linked list found. Fix<y>? yes
Inode 1966092 was part of the orphaned inode list. FIXED.
Inode 1966093 was part of the orphaned inode list. FIXED.
Inode 1966094 was part of the orphaned inode list. FIXED.
Inode 1966095 was part of the orphaned inode list. FIXED.
Inode 1966161 was part of the orphaned inode list. FIXED.
Pass 2: Checking directory structure
Directory inode 1063356, block #0, offset 0: directory corrupted
Salvage<y>? yes
Missing '.' in directory inode 1063356.
Fix<y>? yes
Setting filetype for entry '.' in ??? (1063356) to 2.
Missing '..' in directory inode 1063356.
Fix<y>? yes
Setting filetype for entry '..' in ??? (1063356) to 2.
Directory inode 1062887, block #0, offset 0: directory corrupted
Salvage<y>? yes
Missing '.' in directory inode 1062887.
Fix<y>? yes
那么为什么变成只读模式呢?原来是前一天电脑突然意外关机了,而虚拟机中还正在运行着,导致了虚拟硬盘出现了文件紊乱