美文网首页我用 Linux
文件系统被强制只读问题

文件系统被强制只读问题

作者: dyang__ | 来源:发表于2016-08-23 16:27 被阅读0次

开机报错


An error occurred while mounting /etc/fstab

Press S to skip mounting or M for manual recovery

S后无法进入系统,重启后继续出现上面的提示,再次按S后进入系统。

在命令行中使用tab自动补全时出现:


-bash: cannot create temp file for here-document: Read-only file system

尝试touch,mkdir等写操作都会提示文件系统只读。

看来文件系统现在是只读的。

使用sudo时出现:


sudo ls

sudo: unable to open /var/lib/sudo/dyang/tty1: No such file or directory

查看mount情况:


/dev/mapper/ubuntu--vg-root on / type ext4 (rw,noatime,nodiratime)

proc on /proc type proc (rw,noexec,nosuid,nodev)

sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)

none on /sys/fs/cgroup type tmpfs (rw)

none on /sys/fs/fuse/connections type fusectl (rw)

none on /sys/kernel/debug type debugfs (rw)

none on /sys/kernel/security type securityfs (rw)

udev on /dev type devtmpfs (rw,mode=0755)

devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)

tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755)

none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880)

none on /run/shm type tmpfs (rw,nosuid,nodev)

none on /run/user type tmpfs (rw,noexec,nosuid,nodev,size=104857600,mode=0755)

none on /sys/fs/pstore type pstore (rw)

/dev/sda1 on /boot type ext2 (rw)

systemd on /sys/fs/cgroup/systemd type cgroup (rw,noexec,nosuid,nodev,none,name=systemd)



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.

出现警告,看来确实是被mount成只读模式了。

网上说需要重新mount根目录

使用mount命令出现报错:


sudo mount -o remount,rw /

sudo: unable to open /var/lib/sudo/dyang/tty1: No such file or directory

[mntent]: line 8 in /etc/fstab is bad

查看/etc/fstab


# /etc/fstab: static file system information.

#

# Use 'blkid' to print the universally unique identifier for a

# device; this may be used with UUID= as a more robust way to name devices

# that works even if disks are added and removed. See fstab(5).

#

# <file system> <mount point>   <type>  <options>       <dump>  <pass>

/dev/mapper/ubuntu--vg-root /               ext4  noatime,nodiratime,  errors=remount-ro 0       1

# /boot was on /dev/sda1 during installation

UUID=2eb5fca1-c06d-4d28-b552-d0c7caa7d4e7 /boot           ext2    defaults        0       2

/dev/mapper/ubuntu--vg-swap_1 none            swap    sw              0       0

整个地方的配置文件有问题,第8行的errors和前面的逗号之间出现了多个空格,需要去掉。

再使用mount命令:


sudo mount -o remount,rw /

如果还是不行,修复硬盘解决:

方法1

如果整个硬盘已经是被只读方式挂载,那么可以使用fsck命令进行硬盘修复

Note: fsck最好对未挂载硬盘或者以只读方式挂载的硬盘进行修复,否则非常危险。

先进入/dev/disk/by-id下查看对应的硬盘,让后使用下面命令修复


sudo fsck -fc /dev/disk/by-id/dm-name-ubuntu--vg-root

方法2

重启系统,在grub界面进入advance (高级模式)->recovery mode(恢复模式)

选择root

输入密码进入后

先进入/dev/disk/by-id下查看对应的硬盘,让后使用下面命令修复


sudo fsck -fc /dev/disk/by-id/dm-name-ubuntu--vg-root

相关文章

  • 文件系统被强制只读问题

    开机报错 按S后无法进入系统,重启后继续出现上面的提示,再次按S后进入系统。 在命令行中使用tab自动补全时出现:...

  • 文件系统只读类问题

    转载华为服务支持中的文件系统只读类问题[https://support-it.huawei.com/docs/zh...

  • Linux系统排查3——I/O篇

    当磁盘无法写入的时候,一般有以下可能: 文件系统只读 磁盘已满 I节点使用完 一、 遇到只读的文件系统文件系统自动...

  • Android adb push ... Read-only f

    问题:adb push 时出现文件系统只读权限错误关键字:adb push, failed to copy ‘F...

  • 2018.11.17

    1.强制退出只读文件 :q!

  • go 的基本使用

    const 修饰,代表永远是只读的,不能被修改常量的定义 以及强制类型转换const filename = "ab...

  • openwrt点滴

    文件系统只读,导致配置无法保存 下面是正常的文件系统,rw表示可读可写. 下面是异常的文件系统, ro 表示可读,...

  • 8月1日 磁盘管理2

    如何进行格式化 企业环境: 文件系统只读异常问题 查看硬盘是否坏掉重新挂载参数: remount 企业中: 磁盘空...

  • linux 挂载数据盘

    linux 挂载数据盘 先来个例子 将 /dev/sdb1 用只读模式挂在 /mnt 目录, 文件系统挂载为只读模...

  • fsck 修复

    之前的笔记,回顾顺便分享给大家 曾遇到一个问题,文件属主删除文件删除不了,提示:只读文件系统 reboot 后发现...

网友评论

    本文标题:文件系统被强制只读问题

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