ubuntu – 如何在grub2中添加xen内核启动参数?

前端之家收集整理的这篇文章主要介绍了ubuntu – 如何在grub2中添加xen内核启动参数?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我知道我可以通过编辑将命令行参数添加到grub2命令行
/ etc / default / grub根据这个答案

How do I add a boot parameter to grub2 in Ubuntu 10.10?

但是,这适用于所有内核不会吗?

如何将命令行参数应用于特定内核?即只有xen.

我想附加类似的东西:

Xen的pciback.hide =(06:00.0)

我猜我需要在文件中的某处添加它:

/etc/grub.d/20_linux_xen

其中包含:

  1. #! /bin/sh
  2. set -e
  3.  
  4. # grub-mkconfig helper script.
  5. # Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation,Inc.
  6. #
  7. # GRUB is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation,either version 3 of the License,or
  10. # (at your option) any later version.
  11. #
  12. # GRUB is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with GRUB. If not,see <http://www.gnu.org/licenses/>.
  18.  
  19. prefix=/usr
  20. exec_prefix=${prefix}
  21. bindir=${exec_prefix}/bin
  22. libdir=${exec_prefix}/lib
  23. . ${libdir}/grub/grub-mkconfig_lib
  24.  
  25. export TEXTDOMAIN=grub
  26. export TEXTDOMAINDIR=${prefix}/share/locale
  27.  
  28. CLASS="--class gnu-linux --class gnu --class os --class xen"
  29.  
  30. if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
  31. OS=GNU/Linux
  32. else
  33. OS="${GRUB_DISTRIBUTOR} GNU/Linux"
  34. CLASS="--class $(echo ${GRUB_DISTRIBUTOR} | tr '[A-Z]' '[a-z]' | cut -d' ' -f1) ${CLASS}"
  35. fi
  36.  
  37. # loop-AES arranges things so that /dev/loop/X can be our root device,but
  38. # the initrds that Linux uses don't like that.
  39. case ${GRUB_DEVICE} in
  40. /dev/loop/*|/dev/loop[0-9])
  41. GRUB_DEVICE=`losetup ${GRUB_DEVICE} | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"`
  42. # We can't cope with devices loop-mounted from files here.
  43. case ${GRUB_DEVICE} in
  44. /dev/*) ;;
  45. *) exit 0 ;;
  46. esac
  47. ;;
  48. esac
  49.  
  50. if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \
  51. || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \
  52. || uses_abstraction "${GRUB_DEVICE}" lvm; then
  53. LINUX_ROOT_DEVICE=${GRUB_DEVICE}
  54. else
  55. LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID}
  56. fi
  57.  
  58. linux_entry ()
  59. {
  60. os="$1"
  61. version="$2"
  62. xen_version="$3"
  63. recovery="$4"
  64. args="$5"
  65. xen_args="$6"
  66. if ${recovery} ; then
  67. title="$(gettext_quoted "%s,with Xen %s and Linux %s (recovery mode)")"
  68. else
  69. title="$(gettext_quoted "%s,with Xen %s and Linux %s")"
  70. fi
  71. printf "menuentry '${title}' ${CLASS} {\n" "${os}" "${xen_version}" "${version}"
  72. if ! ${recovery} ; then
  73. save_default_entry | sed -e "s/^/\t/"
  74. fi
  75.  
  76. if [ -z "${prepare_boot_cache}" ]; then
  77. prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
  78. fi
  79. printf '%s\n' "${prepare_boot_cache}"
  80. xmessage="$(gettext_printf "Loading Xen %s ..." ${xen_version})"
  81. lmessage="$(gettext_printf "Loading Linux %s ..." ${version})"
  82. cat << EOF
  83. echo '$xmessage'
  84. multiboot ${rel_xen_dirname}/${xen_basename} placeholder ${xen_args}
  85. echo '$lmessage'
  86. module ${rel_dirname}/${basename} placeholder root=${linux_root_device_thisversion} ro ${args}
  87. EOF
  88. if test -n "${initrd}" ; then
  89. message="$(gettext_printf "Loading initial ramdisk ...")"
  90. cat << EOF
  91. echo '$message'
  92. module ${rel_dirname}/${initrd}
  93. EOF
  94. fi
  95. cat << EOF
  96. }
  97. EOF
  98. }
  99.  
  100. linux_list=`for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* ; do
  101. basename=$(basename $i)
  102. version=$(echo $basename | sed -e "s,^[^0-9]*-,g")
  103. if grub_file_is_not_garbage "$i" && grep -qx "CONFIG_XEN_DOM0=y" /boot/config-${version} 2> /dev/null ; then echo -n "$i " ; fi
  104. done`
  105. xen_list=`for i in /boot/xen*; do
  106. if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
  107. done`
  108. prepare_boot_cache=
  109.  
  110. while [ "x${xen_list}" != "x" ] ; do
  111. list="${linux_list}"
  112. current_xen=`version_find_latest $xen_list`
  113. xen_basename=`basename ${current_xen}`
  114. xen_dirname=`dirname ${current_xen}`
  115. rel_xen_dirname=`make_system_path_relative_to_its_root $xen_dirname`
  116. xen_version=`echo $xen_basename | sed -e "s,.gz$,g;s,^xen-,g"`
  117. echo "submenu \"Xen ${xen_version}\" {"
  118. while [ "x$list" != "x" ] ; do
  119. linux=`version_find_latest $list`
  120. echo "Found linux image: $linux" >&2
  121. basename=`basename $linux`
  122. dirname=`dirname $linux`
  123. rel_dirname=`make_system_path_relative_to_its_root $dirname`
  124. version=`echo $basename | sed -e "s,g"`
  125. alt_version=`echo $version | sed -e "s,\.old$,g"`
  126. linux_root_device_thisversion="${LINUX_ROOT_DEVICE}"
  127.  
  128. initrd=
  129. for i in "initrd.img-${version}" "initrd-${version}.img" \
  130. "initrd-${version}" "initrd.img-${alt_version}" \
  131. "initrd-${alt_version}.img" "initrd-${alt_version}"; do
  132. if test -e "${dirname}/${i}" ; then
  133. initrd="$i"
  134. break
  135. fi
  136. done
  137. if test -n "${initrd}" ; then
  138. echo "Found initrd image: ${dirname}/${initrd}" >&2
  139. else
  140. # "UUID=" magic is parsed by initrds. Since there's no initrd,it can't work here.
  141. linux_root_device_thisversion=${GRUB_DEVICE}
  142. fi
  143.  
  144. linux_entry "${OS}" "${version}" "${xen_version}" false \
  145. "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" "${GRUB_CMDLINE_XEN} ${GRUB_CMDLINE_XEN_DEFAULT}"
  146. if [ "x${GRUB_DISABLE_RECOVERY}" != "xtrue" ]; then
  147. linux_entry "${OS}" "${version}" "${xen_version}" true \
  148. "single ${GRUB_CMDLINE_LINUX}" "${GRUB_CMDLINE_XEN}"
  149. fi
  150.  
  151. list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '`
  152. done
  153. echo "}"
  154. xen_list=`echo $xen_list | tr ' ' '\n' | grep -vx $current_xen | tr '\n' ' '`
  155. done
回答我自己的问题.

添加:GRUB_CMDLINE_XEN =“xen-pciback.hide =(06:00.0)”

to:/ etc / default / grub

然后运行update-grub以提交更改.

猜你在找的Ubuntu相关文章