AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-119849

john smith's questions

Martin Hope
john smith
Asked: 2024-01-06 09:25:40 +0800 CST

测试单词扩展和路径名扩展的简单脚本

  • 6

我正在尝试验证我在这里读到的以下内容:

重要的是要记住,shell 执行我们按顺序描述的所有类型的扩展。这意味着单词扩展在路径名扩展之前执行。因此,如果您循环遍历扩展路径的结果,则不会对这些结果执行分词。

我编写了一个非常简单的脚本,用于验证上面关于单词和路径名扩展的操作顺序的引用:

$ cat test.sh
for path in /home/john/Downloads/*.xlsx

do
    echo "${path}"
done

结果

$ ./test.sh
/home/john/Downloads/CCIE-Collaboration-v3-Learning-Matrix.xlsx
/home/john/Downloads/x y.xlsx

据我所知,单词扩展发生在路径扩展之前,他们使用了一个与此非常相似的脚本来演示它。但我实在不明白这个例子是如何演示的?据我所知,“path”是一个变量,在该变量标识路径之后,该变量将是$path。那么地球上哪里会有单词扩展呢,因为我看不到任何可以考虑扩展的单词。

为了澄清,如果我们运行第一次迭代,$path 是空的,直到它检查“/home/john/Downloads/*.xlsx”,此时它被定义为“/home/john/Downloads/CCIE-Collaboration” -v3-Learning-Matrix.xlsx”,因为这是第一个条目。此时 $path 已被定义。它没有机会应用单词扩展(例如,他们是否说在实际路径名定义第一个结果之前将单词扩展应用于“null”)?

bash
  • 3 个回答
  • 68 Views
Martin Hope
john smith
Asked: 2023-12-22 04:29:53 +0800 CST

Vim 不断将 textwidth 重置为 0,为什么?

  • 5

我试图理解为什么 VIM 不断将我的 textwidth 重置为 0。

为了创建这个问题,我在 Vim 中打开一个新文件,然后输入:

:set textwidth=72

然后我输入一两句话,我可以看到它确保了文本的宽度永远不会超过 72 个字符。都好。当我使用下面的命令保存文档时,问题就出现了,然后当我重新打开文件时,setwidth 重置为 0。

:wq!

因此,如果我现在重新打开该文件,文本宽度将设置回零。我通过输入以下内容进行确认:

: set textwidth?

结果是 0。这非常烦人。我该如何解决这个问题?

有一个人回复并解决了这个问题。对于任何想知道我到底做了什么的人:

$ touch ~/.vimrc
$ cat > .vimrc << EOF
> set number
> set textwidth=72
> EOF

完成,持久文本宽度。

vim
  • 1 个回答
  • 18 Views
Martin Hope
john smith
Asked: 2022-12-24 05:28:54 +0800 CST

当我从数组中删除值时,它弄乱了 printf,因为它有一个带分隔符的空白空间

  • 5

下面的脚本让你将一堆 vlan 写入一个数组,然后我想用它来删除另一条关于“dhcp snooping”行的配置

$ cat nm
#!/bin/bash

echo "enter old vlans"
while read line
do
    oldvlans=("${oldvlans[@]}" $line)
done

delete=790
for del in ${delete[@]}
do
    oldvlans=("${oldvlans[@]/$del}")
done
    printf -v joinedoldvlans '%s,' "${oldvlans[@]}"
    echo "no ip dhcp snooping vlan ${joinedoldvlans%,}"

$ ./nm
enter old vlans
119
790
999
no ip dhcp snooping vlan 119,,999

我现在的问题是格式。我希望最后一行的输出看起来像这样:

no ip dhcp snooping vlan 119,999

但我不确定如何解决它。

bash
  • 1 个回答
  • 36 Views
Martin Hope
john smith
Asked: 2022-12-24 01:19:03 +0800 CST

我可以将两个条件都移动到 1 个条件吗

  • 8

我只编写了几个星期的脚本,我已经设法在这篇文章的底部编写脚本并让它运行。但是,我知道我真正需要做的是将底部的 if 语句条件移动到上面的 if 语句中。所以我需要做这样的条件:

如果文件存在(并且不是空字符串)并且是以下两个之一:(“switchport mode access”或“switchport trunk allowed vlan”)。

我觉得如果我做了类似下面的事情(不确定语法是否正确,但没关系,因为我只是在解释):

     ###### 1 #####        ################ 2 ####################     ######## 3 ########
if ([ ! -z "${prev}" ] && [ "$line" = "switchport access vlan $i" ] || [[ $line =~ $regex ]]);then

然后我担心我不明白它是如何分组的。因此,如果我们将每个条件称为 1、2、3。那么这是否意味着条件 1&2 OR 3。或者这个人条件 1 & (2-OR-3)?就像,有没有一种方法可以通过在要分组的位周围加上括号来消除任何歧义,就像您在数学中所做的那样。正确的做法是什么?

tmpfiles="$PWD/configs/*.tmp"
prev=
for basefile in $tmpfiles
do
while read line
do
    ## get old vlans and interfaces
    for i in "${oldvlans[@]}"
    do
        if ([ ! -z "${prev}" ] && [ "$line" = "switchport access vlan $i" ]);then
            line1="${prev}"
            line2="${line}"
            echo "${line1}"
            echo "${line2}"
        fi
    done
    ### check for lines with "trunk allowed vlans" on and do a no trunk allowed vlan on them
    regex="switchport trunk allowed vlan*"
    if [ ! -z "${prev}" ] && [[ $line =~ $regex ]];then
        line1="${prev}"
        line2="${line}"
        echo "${line1}"
        echo "no ${line2}"
    fi

    prev="${line}"
done < "$basefile" > "$basefile.done"

编辑:我在下面做了一些测试来尝试找出逻辑,因为 stephane 说 () 不是用于分组测试条件,我相信我证明了他/她错了):

$ var1=sumit ; [ -z "var1" ] && ([ "$var1" = "sxxt" ] || [ "$var1" = "sumit" ]);  echo $?
1
$ var1=sumit ; [ -n "var1" ] && ([ "$var1" = "sxxt" ] || [ "$var1" = "sumit" ]);  echo $?
0

所以我认为这是在我想要的地方进行测试的正确方法:

If [condition1] AND if ([condition 2] OR [condition 3] are true). 

但我只是在胡说八道,只需要尝试澄清一下。

bash
  • 2 个回答
  • 60 Views
Martin Hope
john smith
Asked: 2022-12-20 14:57:59 +0800 CST

我觉得我的状态有问题

  • 5

我正在尝试读取一个文件,条件是如果我的当前行具有以下正则表达式,则同时打印当前行和上一行。但是我根本没有得到任何输出。

$ cat xc
#!/bin/bash
prev=
regex="switchport trunk allowed vlan*"
while read line
do
    if [ -n "${prev}" ] && [[ $line =~ $regex ]];then
        line1="${prev}"
        line2="${line}"
        echo "${line1}"
        echo "${line2}"
    fi
done < as159.tmp

$ ./xc

在没有 $prev 部分的情况下测试条件时(我将其注释掉,如下所示),我可以看到我确实得到了输出:

$ cat xc
#!/bin/bash
prev=
regex="switchport trunk allowed vlan*"
while read line
do
    #if [ -n  "${prev}" ] && 
    if [[ $line =~ $regex ]];then
        line1="${prev}"
        line2="${line}"
        echo "${line1}"
        echo "${line2}"
    fi
done < as159.tmp


$ ./xc

switchport trunk allowed vlan 40,10,30

switchport trunk allowed vlan 10,20,30,50,100

所以这一定是一个条件问题,我不确定它是什么。

bash
  • 1 个回答
  • 39 Views
Martin Hope
john smith
Asked: 2022-12-19 11:57:48 +0800 CST

什么是操作数?

  • 4

我只想有人解释什么是“操作数”,因为我就是不明白。这是我正在阅读的上下文:

在bash shell 手册中有关Shell Arithmetic的部分:

允许 Shell 变量作为操作数;参数扩展在计算表达式之前执行。在表达式中,也可以在不使用参数扩展语法的情况下通过名称引用 shell 变量。

bash
  • 2 个回答
  • 85 Views
Martin Hope
john smith
Asked: 2022-12-19 08:29:34 +0800 CST

算术展开式如何处理没有 $(美元)符号的变量?

  • 8

我认为下面的行应该以不同的方式编写,并且该命令应该会出错。

$ echo $((x=2, y=3, x+y))
5

我认为写这个的方法是:

$ echo $((x=2, y=3, $x+$y))
5

两者都有效,现在让我感到困惑。我假设我在某处有误解,所以我将解释我如何确定第一个回声是错误的。x+y 没有引用一个变量,所以 bash 怎么可能知道 x 和 y 是一个变量。如果您告诉我这是因为表达式开头的 $,那么您一定是错的,因为 x 和 y 会定义在 $x=2 和 $y=2 处,这将是定义变量的错误方法。所以我完全不知道 bash 如何知道 x 和 y 是变量。

bash
  • 1 个回答
  • 449 Views
Martin Hope
john smith
Asked: 2022-12-15 10:00:33 +0800 CST

使用 While 循环进行读取的正确方法是什么

  • 7

我来到了 bash 书中的一个章节,该章节试图向我展示您可以结合 while 循环使用 read 语句来读取文件的每一行,然后将前两个单词捕获到两个变量中。但是,我在下面编写了自己的脚本来对其进行测试。

$ cat hoststest 
192.168.1.1 pc1 word3 word4
192.168.1.2 pc2 word3 word4
$ cat t13
#!/bin/bash
while read ip_address pc_number restofstuff
do
if [ ! -z "$ip_address" ]; then
    echo "IP is $ip_address and its for $pc_number"
fi
done < "/home/john/hoststest"
$ ./t13
IP is 192.168.1.1 and its for pc1
IP is 192.168.1.2 and its for pc2

在我最初的测试中,我没有第三个变量“restofstuff”。发生的事情是,pc_number 变量不是只获取 pc1 或 pc2 作为它的值,而是将 pc_number 作为该行的其余部分存储。所以我添加了这第三个变量,只是为了不把该行的所有其余部分作为 pc_number 的一部分。我现在所做的工作,使用这个“restofstuff”变量,但感觉我做的不对。我只是基本上做了一个什么都不做的“死”变量。如果我试图继续使用 read + while 循环,那么正确的方法是什么(注意,这是我正在使用/学习的 while 循环 + read 组合,所以我想专注于那)。

bash
  • 1 个回答
  • 332 Views
Martin Hope
john smith
Asked: 2022-12-13 14:58:02 +0800 CST

为什么 * 在我的场景中有时不被解释为正则表达式

  • 6

我不明白为什么下面的第一个命令有效,当我使用 expr 命令时它需要 * 被转义。在我看来,* 应该总是被转义,因为它是 BRE 的一部分,因此应该被转义而不代表“任何”。所以我不明白为什么第一个命令实际上有效。

$  a=2; b=3; echo $((a*b))
6
$ var1=$(expr 2 * 3) ; echo $var1
expr: syntax error: unexpected argument ‘Desktop’
$ var1=$(expr 2 \* 3) ; echo $var1
6
bash
  • 1 个回答
  • 40 Views
Martin Hope
john smith
Asked: 2022-12-07 15:38:56 +0800 CST

HISTSIZE 环境变量不行吗?

  • 5

我试图了解有关环境变量的一些信息,并检查了 LPIC 考试指南中列出的一些常见变量。它在其他 HIST 变量中谈论 HISTSIZE,但它说 HISTSIZE 和 HISTCONTROL 之类的东西是常见的环境变量。但是我的测试没有定论。在我下面的测试中,我检查 HISTSIZE 是否是一个全局环境变量,但它不是。但是当我回应它时,我看到了一个结果,所以我的假设是它是一个本地/shell 变量。但是,我生成了一个新的 bash 子 shell 并且该值仍然存在,因此它必须是一个全局/环境变量。那么为什么它不是 printenv 或 export 的结果呢?

$ printenv HISTSIZE
$ export | grep HISTSIZE
$ echo $HISTSIZE
1000
$ bash
$ echo $HISTSIZE
1000
bash
  • 1 个回答
  • 25 Views
Martin Hope
john smith
Asked: 2022-11-29 10:42:05 +0800 CST

GNU grep 手册中的字符类

  • 5

试图理解为什么 grep 手册用一个方括号来说明字符类。

https://www.gnu.org/software/grep/manual/html_node/Character-Classes-and-Bracket-Expressions.html

例如,它指出:使用 [:lower:] 匹配小写。然而在终端中,我使用它,结果是:

$ grep [:lower:] test
grep: character class syntax is [[:space:]], not [:space:]

我在尝试使用/理解本手册时遇到了无数问题,它有什么问题吗?它似乎只适用于双 [[]],但没有任何解释说明为什么手册说只使用 []。

grep
  • 1 个回答
  • 47 Views
Martin Hope
john smith
Asked: 2022-11-26 09:20:19 +0800 CST

dnf列表输出的澄清

  • 5

我刚刚安装了 Centos stream 9。我试图了解dnf list. 似乎有三列。最右边的列主要是“anaconda”、“AppStream”、“baseos”。

或相同,但@前面有一个,例如:@anaconda. 有什么区别,这些东西是什么?我想做的就是浏览官方仓库以获取可用程序。

dnf
  • 1 个回答
  • 36 Views
Martin Hope
john smith
Asked: 2019-12-17 13:02:16 +0800 CST

我只使用 dhcpcd,我想让 /etc/resolv.conf 添加搜索 domain.local

  • 3

我有许多不使用网络管理器的机器,只使用 dhcpcd 来设置 IP 地址。比如我的树莓派 4。我已经在 /etc/dhcpcd.conf 文件中静态分配了 IP 地址,并且可以正常工作,我很高兴。我想要做的是,如果我输入 nslookup machine2 (例如),它将配置的域附加到该查找。

在另一台使用 dhcpcd 的机器(我的 ArchLinux PC)中,我通过 dhcpcd 将地址配置为使用 dhcp(这次不是静态的)。在我的 DHCP 服务器上,我对其进行了设置,以便将“域名”字段指定为返回给客户端的选项。结果是我的 /etc/resolv.conf 文件更新为以下行:

域 mydomain.local

由于在这个文件中设置了这个“域”值,我只需键入 nslookup machine2,它会将 mydomain.local 附加到该查询,我的 dns 服务器会解析 machine2.mydomain.local 的 fqdn 的 IP。

所以理想情况下,我想模仿这个设置,这样我的树莓派 pi4 就会做同样的事情,但是它是静态设置的,那么我该怎么做呢?

请注意,我已经尝试将“search domain.local”添加到 /etc/resolv.conf 文件中,它会执行我想要它执行的操作,但是这些设置在重新启动时会丢失,因此我无法在此处设置此值. 我需要使用 dhcpcd 的适当工作解决方案。

更新:

我被要求将我的 /etc/resolv.conf 的输出放在这里:

$ cat /etc/resolv.conf
# Generated by resolvconf
nameserver 10.10.0.1
dns domain
  • 2 个回答
  • 7320 Views
Martin Hope
john smith
Asked: 2019-02-14 15:52:06 +0800 CST

Debian 和 CentOS UEFI 双启动 - 无法加载 Debian

  • -2

我正在尝试使用 UEFI 引导在一个磁盘上安装 Debian 和 CentOS。当 Debian 启动时,我得到下图中的错误:

在此处输入图像描述

为了解释我是如何尝试设置的,我将展示我对分区所做的工作。下面是我最初的 Debian 分区的图片(注意我在最后留下了一些空闲空间来放置 CentOS "/" 挂载点)。

在此处输入图像描述

之后运行并安装它工作正常。然后我插入一个 USB 驱动器来启动和安装 CentOS。当我进入分区屏幕时,它看起来是这样的(在进行任何修改之前):

在此处输入图像描述

I then made one 20GiB partition for the / of CentOS. Additionally, under the Debian partition section, I modified the /boot/efi partition to have the "mount point (see far right of the image)" of /boot/efi. This then seemed to duplicate itself over to the CentOS partition section. The result is shown below: 在此处输入图像描述

Upon boot, I see two options, one for CentOS and one for Debian. If I select CentOS it works fine. If I select Debian, I get the error shown in the first link of this post. My question is why?

My EFI directory is below.

[root@localhost EFI]# cd /boot/efi/EFI
[root@localhost EFI]# ls
BOOT  centos  debian
[root@localhost EFI]# ls centos debian
centos:
BOOT.CSV     fonts  fwupia32.efi  grub.cfg  grubx64.efi  MokManager.efi  shimx64-centos.efi
BOOTX64.CSV  fw     fwupx64.efi   grubenv   mmx64.efi    shim.efi        shimx64.efi

debian:
grubx64.efi

My /boot/efi/EFI/centos/grub.cfg is below:

#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub2-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
set pager=1

if [ -s $prefix/grubenv ]; then
  load_env
fi
if [ "${next_entry}" ] ; then
   set default="${next_entry}"
   set next_entry=
   save_env next_entry
   set boot_once=true
else
   set default="${saved_entry}"
fi

if [ x"${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
else
  menuentry_id_option=""
fi

export menuentry_id_option

if [ "${prev_saved_entry}" ]; then
  set saved_entry="${prev_saved_entry}"
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

function savedefault {
  if [ -z "${boot_once}" ]; then
    saved_entry="${chosen}"
    save_env saved_entry
  fi
}

function load_video {
  if [ x$feature_all_video_module = xy ]; then
    insmod all_video
  else
    insmod efi_gop
    insmod efi_uga
    insmod ieee1275_fb
    insmod vbe
    insmod vga
    insmod video_bochs
    insmod video_cirrus
  fi
}

terminal_output console
if [ x$feature_timeout_style = xy ] ; then
  set timeout_style=menu
  set timeout=5
# Fallback normal timeout code in case the timeout_style feature is
# unavailable.
else
  set timeout=5
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/00_tuned ###
set tuned_params=""
set tuned_initrd=""
### END /etc/grub.d/00_tuned ###

### BEGIN /etc/grub.d/01_users ###
if [ -f ${prefix}/user.cfg ]; then
  source ${prefix}/user.cfg
  if [ -n "${GRUB2_PASSWORD}" ]; then
    set superusers="root"
    export superusers
    password_pbkdf2 root ${GRUB2_PASSWORD}
  fi
fi
### END /etc/grub.d/01_users ###

### BEGIN /etc/grub.d/10_linux ###
menuentry 'CentOS Linux (3.10.0-957.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-957.el7.x86_64-advanced-4b9ca680-8e47-494f-8a98-991aab9d51e6' {
    load_video
    set gfxpayload=keep
    insmod gzio
    insmod part_gpt
    insmod xfs
    set root='hd0,gpt3'
    if [ x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt3 --hint-efi=hd0,gpt3 --hint-baremetal=ahci0,gpt3  4b9ca680-8e47-494f-8a98-991aab9d51e6
    else
      search --no-floppy --fs-uuid --set=root 4b9ca680-8e47-494f-8a98-991aab9d51e6
    fi
    linuxefi /boot/vmlinuz-3.10.0-957.el7.x86_64 root=UUID=4b9ca680-8e47-494f-8a98-991aab9d51e6 ro crashkernel=auto rhgb quiet 
    initrdefi /boot/initramfs-3.10.0-957.el7.x86_64.img
}
menuentry 'CentOS Linux (0-rescue-6afd59629baf4fd295f2313dd51b9e9e) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-6afd59629baf4fd295f2313dd51b9e9e-advanced-4b9ca680-8e47-494f-8a98-991aab9d51e6' {
    load_video
    insmod gzio
    insmod part_gpt
    insmod xfs
    set root='hd0,gpt3'
    if [ x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt3 --hint-efi=hd0,gpt3 --hint-baremetal=ahci0,gpt3  4b9ca680-8e47-494f-8a98-991aab9d51e6
    else
      search --no-floppy --fs-uuid --set=root 4b9ca680-8e47-494f-8a98-991aab9d51e6
    fi
    linuxefi /boot/vmlinuz-0-rescue-6afd59629baf4fd295f2313dd51b9e9e root=UUID=4b9ca680-8e47-494f-8a98-991aab9d51e6 ro crashkernel=auto rhgb quiet 
    initrdefi /boot/initramfs-0-rescue-6afd59629baf4fd295f2313dd51b9e9e.img
}
if [ "x$default" = 'CentOS Linux (3.10.0-957.el7.x86_64) 7 (Core)' ]; then default='Advanced options for CentOS Linux>CentOS Linux (3.10.0-957.el7.x86_64) 7 (Core)'; fi;
### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ###

### BEGIN /etc/grub.d/20_ppc_terminfo ###
### END /etc/grub.d/20_ppc_terminfo ###

### BEGIN /etc/grub.d/30_os-prober ###
menuentry 'Debian GNU/Linux (9.8) (on /dev/sda2)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-simple-9a0b0533-9320-45f1-9b3d-0860da8822be' {
    insmod part_gpt
    insmod ext2
    set root='hd0,gpt2'
    if [ x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2  9a0b0533-9320-45f1-9b3d-0860da8822be
    else
      search --no-floppy --fs-uuid --set=root 9a0b0533-9320-45f1-9b3d-0860da8822be
    fi
    linux /boot/vmlinuz-4.9.0-8-amd64 root=UUID=9a0b0533-9320-45f1-9b3d-0860da8822be ro quiet
    initrd /boot/initrd.img-4.9.0-8-amd64
}
submenu 'Advanced options for Debian GNU/Linux (9.8) (on /dev/sda2)' $menuentry_id_option 'osprober-gnulinux-advanced-9a0b0533-9320-45f1-9b3d-0860da8822be' {
    menuentry 'Debian GNU/Linux (on /dev/sda2)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz-4.9.0-8-amd64--9a0b0533-9320-45f1-9b3d-0860da8822be' {
        insmod part_gpt
        insmod ext2
        set root='hd0,gpt2'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2  9a0b0533-9320-45f1-9b3d-0860da8822be
        else
          search --no-floppy --fs-uuid --set=root 9a0b0533-9320-45f1-9b3d-0860da8822be
        fi
        linux /boot/vmlinuz-4.9.0-8-amd64 root=UUID=9a0b0533-9320-45f1-9b3d-0860da8822be ro quiet
        initrd /boot/initrd.img-4.9.0-8-amd64
    }
    menuentry 'Debian GNU/Linux, with Linux 4.9.0-8-amd64 (on /dev/sda2)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz-4.9.0-8-amd64--9a0b0533-9320-45f1-9b3d-0860da8822be' {
        insmod part_gpt
        insmod ext2
        set root='hd0,gpt2'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2  9a0b0533-9320-45f1-9b3d-0860da8822be
        else
          search --no-floppy --fs-uuid --set=root 9a0b0533-9320-45f1-9b3d-0860da8822be
        fi
        linux /boot/vmlinuz-4.9.0-8-amd64 root=UUID=9a0b0533-9320-45f1-9b3d-0860da8822be ro quiet
        initrd /boot/initrd.img-4.9.0-8-amd64
    }
    menuentry 'Debian GNU/Linux, with Linux 4.9.0-8-amd64 (recovery mode) (on /dev/sda2)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz-4.9.0-8-amd64-root=UUID=9a0b0533-9320-45f1-9b3d-0860da8822be ro single-9a0b0533-9320-45f1-9b3d-0860da8822be' {
        insmod part_gpt
        insmod ext2
        set root='hd0,gpt2'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2  9a0b0533-9320-45f1-9b3d-0860da8822be
        else
          search --no-floppy --fs-uuid --set=root 9a0b0533-9320-45f1-9b3d-0860da8822be
        fi
        linux /boot/vmlinuz-4.9.0-8-amd64 root=UUID=9a0b0533-9320-45f1-9b3d-0860da8822be ro single
        initrd /boot/initrd.img-4.9.0-8-amd64
    }
}

### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###

### BEGIN /etc/grub.d/41_custom ###
if [ -f  ${config_directory}/custom.cfg ]; then
  source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f  $prefix/custom.cfg ]; then
  source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###

UPDATE - Got A Working Solution, but not happy how I got there (I would like to someone to tell me why my system ended up this way) : In my /boot/efi/EFI/centos/grub.cfg file I manually edited the lines under the Debian menu entry (or sub-menu entries) starting with the word "linux" or initrd" to the words "linuxefi" and "initrdefi" respectively. I can't understand why I've had to manually edit this grub file to make my debian system boot. I must be doing something very wrong right from the installation/setup stages of the operating systems for me to run into this problem. What is happening?

dual-boot
  • 1 个回答
  • 554 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve