【问题标题】:How to add a menu entry in Grub to start Ubuntu in command line [closed]如何在 Grub 中添加菜单项以在命令行中启动 Ubuntu [关闭]
【发布时间】:2016-09-26 04:35:15
【问题描述】:

我有一个有时只能通过 SSH 远程使用的桌面。在这些情况下,拥有图形界面是没有用的,因此以文本模式启动系统可能会很棒。

我正在使用 Ubuntu,我想在 Grub 中添加一个菜单项来做我想做的事(以文本模式开始,但不是每次都这样)。为此,我将其添加到文件/etc/grub.d/40_custom

menuentry 'Ubuntu (text mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-86845fc2-c8a4-4323-a936-497ae09f288c' {
    recordfail
    load_video
    gfxmode $linux_gfx_mode
    insmod gzio
    if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
    insmod part_msdos
    insmod ext2
    set root='hd1,msdos1'
    if [ x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint-bios=hd1,msdos1 --hint-efi=hd1,msdos1 --hint-baremetal=ahci1,msdos1  86845fc2-c8a4-4323-a936-497ae09f288c
    else
      search --no-floppy --fs-uuid --set=root 86845fc2-c8a4-4323-a936-497ae09f288c
    fi
    linux   /boot/vmlinuz-3.19.0-59-generic root=UUID=86845fc2-c8a4-4323-a936-497ae09f288c ro  text
    initrd  /boot/initrd.img-3.19.0-59-generic
}

然后运行sudo update-grub

问题在于它根本不起作用:当我使用这个新行时,Ubuntu 照常启动,图形界面和 GDM 要求输入我的密码。

有什么想法吗?

【问题讨论】:

  • 在运行级别 3 中启动 ubuntu 将达到您的目的。你可以参考askubuntu.com/questions/228402/boot-to-runlevel-3
  • 谢谢,成功了!但是自从这篇文章之后情况发生了变化,我们不需要再做一些事情了,我在这个问题上添加一个答案来解释。

标签: linux ubuntu grub


【解决方案1】:

感谢 Shubhangi 的建议(请参阅问题的 cmets),我找到了一种方法来做我想做的事。 基于this question,我需要的是在运行级别3 中启动Ubuntu。为此,我们可以在新条目的linux 行中添加3

更准确地说,这里是40_custom的新内容:

menuentry 'Ubuntu (text mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-86845fc2-c8a4-4323-a936-497ae09f288c' {
    recordfail
    load_video
    gfxmode $linux_gfx_mode
    insmod gzio
    if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
    insmod part_msdos
    insmod ext2
    set root='hd1,msdos1'
    if [ x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint-bios=hd1,msdos1 --hint-efi=hd1,msdos1 --hint-baremetal=ahci1,msdos1  86845fc2-c8a4-4323-a936-497ae09f288c
    else
      search --no-floppy --fs-uuid --set=root 86845fc2-c8a4-4323-a936-497ae09f288c
    fi
    linux   /vmlinuz root=UUID=86845fc2-c8a4-4323-a936-497ae09f288c 3 ro  text
    initrd  /initrd.img
}

现在重新启动,选择您的新条目,您将进入文本模式。 :)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-08-17
    • 2014-06-02
    • 1970-01-01
    • 2013-08-20
    • 1970-01-01
    • 2018-05-02
    • 2013-07-31
    • 2020-05-23
    相关资源
    最近更新 更多