一次启动进入只读状态?

发布于 2024-12-13 12:37:26 字数 229 浏览 5 评论 0原文

我正在尝试启动到只读模式来测试某些软件。我不想在启动后重新安装驱动器,因为这不符合测试启动时检查文件系统的软件的要求。

有没有办法在不编辑 grub.conf 的情况下做到这一点?最好在中断启动时通过 grub UI 添加一些内容?

如果我编辑 grub.conf 以只读方式启动,我该如何将其编辑回来?


我知道内核将 root 挂载为 RO,但稍后在启动过程中将其重新挂载为 RW。

I'm trying to boot into read only mode to test some software. I don't want to remount a drive after booting as that would not meet the requirements to test the software which checks the file system at boot.

Is there a way to do this without editing grub.conf? Preferably adding something via the grub UI when interrupting boot?

If I do edit the grub.conf to boot in read only, how am I supposed to edit it back?


I understand that the kernel mounts root as RO but it's remounted as RW later in the boot process.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦初启 2024-12-20 12:37:26

当 grub 运行时,您通常可以在 grub 加载内核并继续引导之前编辑内核命令行。也许您的发行版在启动时隐藏了grub界面 - 按住左侧shift 可能会调出它并让您编辑内核命令行。

Linux 内核 Documentation/kernel-parameters.txt 记录了用于以只读方式挂载根文件系统的 ro 内核命令参数。如果您添加 init=/bin/sh,那么您将负责挂载您想要的任何文件系统。您可能需要先挂载 /proc,然后 mount(8) 将显示任何已挂载的文件系统:mount -t proc none /proc

只要确保为 mount(8) 提供 -o ro-o rw 选项即可根据需要挂载每个文件系统。

但我必须认为有更好的软件测试方法。您真正想做什么?

When grub is running, you typically have some ability to edit the kernel command line before grub loads the kernel and continues booting. Perhaps your distribution has hidden the grub interface at boot -- holding down the left shift may bring it up and let you edit the kernel command line.

The Linux kernel Documentation/kernel-parameters.txt documents the ro kernel command parameter to mount your root filesystem read-only. If you add-in init=/bin/sh, then you'll be in charge of mounting whatever filesystems you want. You may need to mount /proc before mount(8) will show any mounted filesystems: mount -t proc none /proc.

Just be sure to give the -o ro or -o rw option to mount(8) as your mount each filesystem as you desire.

But I have to think there are better ways of testing software. What are you really trying to do?

×纯※雪 2024-12-20 12:37:26

这也可以通过添加

GRUB_DEFAULT=saved

到 grub.cfg 来完成。然后您可以为引导加载程序创建 2 个不同的 GRUB 条目(例如“RedHat”和“RedHat RO”)。在终端中设置像这样的默认条目

grub-set-default "RedHat"

仅在终端中的下一次重新引导问题时运行其他 grub 条目

grub-reboot "RedHat RO"

这有效本质上,通过在 grub 配置(grubenv)中添加一个标志并在重新启动后将其删除,所以基本上您的 /boot/ 分区必须是可写的,如果需要的话,您也可以重新挂载可写的引导分区。 /目录 另一种选择是将引导分区

放在 USB 记忆棒上,并在每次需要时从那里引导“RedHat RO”,

否则:正如 sarnold 已经说过的:您在 GRUB 命令行中所做的更改或GRUB 编辑只是暂时的。

This could also be done by adding

GRUB_DEFAULT=saved

to your grub.cfg . Then you can create 2 different GRUB entries to the bootloader (eg. "RedHat" and "RedHat RO". The set the default entry like this in your terminal

grub-set-default "RedHat"

To run the other grub entry only for the next reboot issue in your terminal

grub-reboot "RedHat RO"

This works essentially, by adding a flag in the grub configuration (grubenv) and removing it after reboot. So basically your /boot/ partition has to be writeable. You can also remount the boot partition writeable if necessary. In any case you need the /boot/ directory on a separate partition.

Another alternative would be to put the boot partition on a USB stick and boot the "RedHat RO" from there every time you need it.

Otherwise: As sarnold already said: The changes you do in the GRUB command line or GRUB editing are only temporary.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文