Linux 修复 fstab(只读/)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/383595/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-03 16:48:41  来源:igfitidea点击:

Repairing fstab (read only /)

linuxdebian

提问by

I had a typo in my fstab and it boots to a commandline but is readonly, I know what the error is but i can't change it because it's mounted as readonly. I want to mount the filesystem and make the changes. I know I can boot a live distro and edit it that way, but i was wondering if there was an easier way to do it.

我的 fstab 中有一个错字,它启动到命令行但是是只读的,我知道错误是什么,但我无法更改它,因为它以只读方式安装。我想挂载文件系统并进行更改。我知道我可以启动实时发行版并以这种方式进行编辑,但我想知道是否有更简单的方法来做到这一点。

It's debian lenny by the way.

顺便说一下,它是 debian lenny。

回答by MarkR

Yes, if you end up in single-user mode with a readonly root, try:

是的,如果您最终进入具有只读根的单用户模式,请尝试:

mount / -o remount,rw

Maybe a -n is necessary, maybe not. That should remount the root fs read/write (assuming there's nothing wrong with it).

也许 -n 是必要的,也许不是。这应该重新安装根 fs 读/写(假设它没有任何问题)。

回答by Johannes Schaub - litb

My kernel command line looks like this:

我的内核命令行如下所示:

$ cat /proc/cmdline
root=/dev/sda4 ro
$

Tell grub that it should omit passing "ro"to the kernel when booting (pressing esc, eon the entry you want edit will allow you to edit the arguments given to the kernel), and it will mount your root file system not read only anymore. Then you can change your /etc/fstaband restart.

告诉 grub 它应该"ro"在引导时省略传递给内核的操作(在您想要编辑的条目上按esce将允许您编辑提供给内核的参数),并且它将安装您的根文件系统,而不是只读。然后您可以更改您的/etc/fstab并重新启动。

回答by troyane

I know that question is outdated, but saw it, because nowadays got in the same trouble. I broke my fstabmanually (make a typo in parameter).

我知道这个问题已经过时了,但是看到了,因为现在遇到了同样的麻烦。我fstab手动打破了我的(在参数中打错字)。

That was very easy to correct fstabfrom readonly mode. We must mount /in read-write mode.

这很容易fstab从只读模式纠正。我们必须/以读写模式挂载。

If /etc/fstabis correct, you can simply type:

如果/etc/fstab正确,您可以简单地输入:

mount -n -o remount /

But if /etc/fstabis wrong (as it was in my case), you must give the device name and possibly the type, too: e.g.

但是如果/etc/fstab是错误的(就像我的情况一样),您还必须提供设备名称和类型:例如

mount -n -o remount -t extX /dev/hdaX /

Where extXis your filesystem type and /dev/hdaX-- is partition you use for your root mount point.

extX您的文件系统类型在哪里,以及/dev/hdaX您用于根安装点的分区。

To see all your available partitions just type ls /dev/[sh]d*.

要查看所有可用分区,只需键入ls /dev/[sh]d*.

回答by yanghaogn

#mount -n -o remount,rw / 

if /dev/sda1 is the real device, then do:

如果 /dev/sda1 是真实设备,则执行以下操作:

#mount -n -o remount,rw /dev/sda1 /

回答by Michael M

If you have something wrong with your /etc/fstab file. Please follow the following steps.

如果您的 /etc/fstab 文件有问题。请按照以下步骤操作。

  1. boot your ubuntu system or restart your computer
  2. since you can not start your system, you will encounter some errors like
  1. 启动您的 ubuntu 系统或重新启动您的计算机
  2. 由于您无法启动系统,您会遇到一些错误,例如

“a start job is running for dev-disk-by.... (you may need pressing F2 key to come the linux command terminal to see this)

“一个启动作业正在为 dev-disk-by 运行......(你可能需要按 F2 键来进入 linux 命令终端才能看到这个)

  1. use command vi /etc/fstab and edit your fstab file
  2. use # to commend out some problems and add something you want put in the fstab file.
  3. finish editing. hit shift+z and save the modification
  4. use command reboot to restart your system
  5. it works again
  1. 使用命令 vi /etc/fstab 并编辑您的 fstab 文件
  2. 使用 # 来推荐一些问题并添加您想要放入 fstab 文件的内容。
  3. 完成编辑。按 shift+z 并保存修改
  4. 使用命令 reboot 重新启动系统
  5. 它又起作用了

Please comment here, if you have questions

有问题请在此留言

回答by user3132483

@troyane saved my hassle by providing

@troyane 通过提供解决了我的麻烦

mount -n -o remount -t extX /dev/hdaX /

I was on Orangepi3 EMMC when I had a typo in UUID of root having ext4 filesystem.

当我在具有 ext4 文件系统的 root 的 UUID 中有一个拼写错误时,我正在使用 Orangepi3 EMMC。

The command remounted in read-write mode and I fixed my fstab

该命令以读写模式重新安装,我修复了我的 fstab

mount -n -o remount -t ext4 /dev/mmcblk2p1 /