【问题标题】:Run script from GRUB menu entry从 GRUB 菜单项运行脚本
【发布时间】:2019-08-30 09:37:07
【问题描述】:

我按照出色的指南 https://willhaley.com/blog/custom-debian-live-environment/ 创建了一张 Debian Live DVD。

我希望在选定的自动登录并运行脚本时畅游两个grub菜单。

    menuentry "Run Script 1" {
        linux /vmlinuz boot=live quiet nomodeset
        initrd /initrd
    }

    menuentry "Run Script 2" {
        linux /vmlinuz boot=live quiet nomodeset
        initrd /initrd
    }

当我以 root 身份自动登录时,如何从 grub 菜单项传递要运行的脚本的绝对路径?

/lib/live/mount/medium/scripts/script1.bash

要自动登录,我已修改 /lib/systemd/system/getty@.service 以使用上述菜单项以 root 身份自动登录。

【问题讨论】:

    标签: linux-kernel grub


    【解决方案1】:

    使用自定义参数启动:

    linux /vmlinuz .... my_dummy_param=/lib/live/mount/medium/scripts/script1.bash
    

    然后稍后读取/proc/cmdline 并在您的登录外壳启动文件中解析它,例如。 .bashrc 用于 bash shell 或 .profile:

    #!/bin/bash
    . /proc/cmdline
    echo "Running $my_dummy_param"
    "$my_dummy_param"
    

    【讨论】:

      猜你喜欢
      • 2016-06-16
      • 2022-01-25
      • 2021-11-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-15
      • 2016-06-01
      相关资源
      最近更新 更多