Guest User

Untitled

a guest
Sep 27th, 2018
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.34 KB | None | 0 0
  1. head -20 /etc/default/grub
  2. # If you change this file, run 'update-grub' afterwards to update
  3. # /boot/grub/grub.cfg.
  4. # For full documentation of the options in this file, see:
  5. # info -f grub -n 'Simple configuration'
  6.  
  7. GRUB_DEFAULT=0
  8. GRUB_TIMEOUT=5
  9. GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
  10. GRUB_CMDLINE_LINUX_DEFAULT="quiet"
  11. GRUB_CMDLINE_LINUX=""
  12.  
  13.  
  14. #! /bin/sh
  15. set -e
  16.  
  17. # grub-mkconfig helper script.
  18. # Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc.
  19. #
  20. # GRUB is free software: you can redistribute it and/or modify
  21. # it under the terms of the GNU General Public License as published by
  22. # the Free Software Foundation, either version 3 of the License, or
  23. # (at your option) any later version.
  24. #
  25. # GRUB is distributed in the hope that it will be useful,
  26. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  27. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  28. # GNU General Public License for more details.
  29. #
  30. # You should have received a copy of the GNU General Public License
  31. # along with GRUB. If not, see <http://www.gnu.org/licenses/>.
  32.  
  33. prefix="/usr"
  34. exec_prefix="/usr"
  35. datarootdir="/usr/share"
  36. quick_boot="0"
  37.  
  38. export TEXTDOMAIN=grub
  39. export TEXTDOMAINDIR="${datarootdir}/locale"
  40.  
  41. . "$pkgdatadir/grub-mkconfig_lib"
  42.  
  43. found_other_os=
  44.  
  45. adjust_timeout () {
  46. if [ "$quick_boot" = 1 ] && [ "x${found_other_os}" != "x" ]; then
  47. cat << EOF
  48. set timeout_style=menu
  49. if [ "\${timeout}" = 0 ]; then
  50. set timeout=10
  51. fi
  52. EOF
  53. fi
  54. }
  55.  
  56. if [ "x${GRUB_DISABLE_OS_PROBER}" = "xtrue" ]; then
  57. exit 0
  58. fi
  59.  
  60. if [ -z "`which os-prober 2> /dev/null`" ] || [ -z "`which linux-boot-prober 2> /dev/null`" ] ; then
  61. # missing os-prober and/or linux-boot-prober
  62. exit 0
  63. fi
  64.  
  65. OSPROBED="`os-prober | tr ' ' '^' | paste -s -d ' '`"
  66. if [ -z "${OSPROBED}" ] ; then
  67. # empty os-prober output, nothing doing
  68. exit 0
  69. fi
  70.  
  71. osx_entry() {
  72. found_other_os=1
  73. if [ x$2 = x32 ]; then
  74. # TRANSLATORS: it refers to kernel architecture (32-bit)
  75. bitstr="$(gettext "(32-bit)")"
  76. else
  77. # TRANSLATORS: it refers to kernel architecture (64-bit)
  78. bitstr="$(gettext "(64-bit)")"
  79. fi
  80. # TRANSLATORS: it refers on the OS residing on device %s
  81. onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
  82. cat << EOF
  83. menuentry '$(echo "${LONGNAME} $bitstr $onstr" | grub_quote)' --class osx --class darwin --class os \$menuentry_id_option 'osprober-xnu-$2-$(grub_get_device_id "${DEVICE}")' {
  84. EOF
  85. save_default_entry | grub_add_tab
  86. prepare_grub_to_access_device ${DEVICE} | grub_add_tab
  87. cat << EOF
  88. load_video
  89. set do_resume=0
  90. if [ /var/vm/sleepimage -nt10 / ]; then
  91. if xnu_resume /var/vm/sleepimage; then
  92. set do_resume=1
  93. fi
  94. fi
  95. if [ \$do_resume = 0 ]; then
  96. xnu_uuid ${OSXUUID} uuid
  97. if [ -f /Extra/DSDT.aml ]; then
  98. acpi -e /Extra/DSDT.aml
  99. fi
  100. if [ /kernelcache -nt /System/Library/Extensions ]; then
  101. $1 /kernelcache boot-uuid=\${uuid} rd=*uuid
  102. elif [ -f /System/Library/Kernels/kernel ]; then
  103. $1 /System/Library/Kernels/kernel boot-uuid=\${uuid} rd=*uuid
  104. xnu_kextdir /System/Library/Extensions
  105. else
  106. $1 /mach_kernel boot-uuid=\${uuid} rd=*uuid
  107. if [ /System/Library/Extensions.mkext -nt /System/Library/Extensions ]; then
  108. xnu_mkext /System/Library/Extensions.mkext
  109. else
  110. xnu_kextdir /System/Library/Extensions
  111. fi
  112. fi
  113. if [ -f /Extra/Extensions.mkext ]; then
  114. xnu_mkext /Extra/Extensions.mkext
  115. fi
  116. if [ -d /Extra/Extensions ]; then
  117. xnu_kextdir /Extra/Extensions
  118. fi
  119. if [ -f /Extra/devprop.bin ]; then
  120. xnu_devprop_load /Extra/devprop.bin
  121. fi
  122. if [ -f /Extra/splash.jpg ]; then
  123. insmod jpeg
  124. xnu_splash /Extra/splash.jpg
  125. fi
  126. if [ -f /Extra/splash.png ]; then
  127. insmod png
  128. xnu_splash /Extra/splash.png
  129. fi
  130. if [ -f /Extra/splash.tga ]; then
  131. insmod tga
  132. xnu_splash /Extra/splash.tga
  133. fi
  134. fi
  135. }
  136. EOF
  137. }
  138.  
  139. used_osprober_linux_ids=
  140.  
  141. wubi=
  142.  
  143. for OS in ${OSPROBED} ; do
  144. DEVICE="`echo ${OS} | cut -d ':' -f 1`"
  145. LONGNAME="`echo ${OS} | cut -d ':' -f 2 | tr '^' ' '`"
  146. LABEL="`echo ${OS} | cut -d ':' -f 3 | tr '^' ' '`"
  147. BOOT="`echo ${OS} | cut -d ':' -f 4`"
  148. if UUID="`${grub_probe} --target=fs_uuid --device ${DEVICE%@*}`"; then
  149. EXPUUID="$UUID"
  150.  
  151. if [ x"${DEVICE#*@}" != x ] ; then
  152. EXPUUID="${EXPUUID}@${DEVICE#*@}"
  153. fi
  154.  
  155. if [ "x${GRUB_OS_PROBER_SKIP_LIST}" != "x" ] && [ "x`echo ${GRUB_OS_PROBER_SKIP_LIST} | grep -i -e '\b'${EXPUUID}'\b'`" != "x" ] ; then
  156. echo "Skipped ${LONGNAME} on ${DEVICE} by user request." >&2
  157. continue
  158. fi
  159. fi
  160.  
  161. BTRFS="`echo ${OS} | cut -d ':' -f 5`"
  162. if [ "x$BTRFS" = "xbtrfs" ]; then
  163. BTRFSuuid="`echo ${OS} | cut -d ':' -f 6`"
  164. BTRFSsubvol="`echo ${OS} | cut -d ':' -f 7`"
  165. fi
  166.  
  167. if [ -z "${LONGNAME}" ] ; then
  168. LONGNAME="${LABEL}"
  169. fi
  170.  
  171. # os-prober returns text string followed by optional counter
  172. CLASS="--class $(echo "${LABEL}" | LC_ALL=C sed 's,[[:digit:]]*$,,' | cut -d' ' -f1 | tr 'A-Z' 'a-z' | LC_ALL=C sed 's,[^[:alnum:]_],_,g')"
  173.  
  174. gettext_printf "Found %s on %s\n" "${LONGNAME}" "${DEVICE}" >&2
  175.  
  176. case ${BOOT} in
  177. chain)
  178.  
  179. case ${LONGNAME} in
  180. Windows*)
  181. if [ -z "$wubi" ]; then
  182. if [ -x /usr/share/lupin-support/grub-mkimage ] && \
  183. /usr/share/lupin-support/grub-mkimage --test; then
  184. wubi=yes
  185. else
  186. wubi=no
  187. fi
  188. fi
  189. if [ "$wubi" = yes ]; then
  190. echo "Skipping ${LONGNAME} on Wubi system" >&2
  191. continue
  192. fi
  193. ;;
  194. esac
  195.  
  196. found_other_os=1
  197. onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
  198. cat << EOF
  199. menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' $CLASS --class os \$menuentry_id_option 'osprober-chain-$(grub_get_device_id "${DEVICE}")' {
  200. EOF
  201. save_default_entry | grub_add_tab
  202. prepare_grub_to_access_device ${DEVICE} | grub_add_tab
  203.  
  204. if [ x"`${grub_probe} --device ${DEVICE} --target=partmap`" = xmsdos ]; then
  205. cat << EOF
  206. parttool \${root} hidden-
  207. EOF
  208. fi
  209.  
  210. case ${LONGNAME} in
  211. Windows\ Vista*|Windows\ 7*|Windows\ Server\ 2008*)
  212. ;;
  213. *)
  214. cat << EOF
  215. drivemap -s (hd0) \${root}
  216. EOF
  217. ;;
  218. esac
  219.  
  220. cat <<EOF
  221. chainloader +1
  222. }
  223. EOF
  224. ;;
  225. efi)
  226.  
  227. found_other_os=1
  228. EFIPATH=${DEVICE#*@}
  229. DEVICE=${DEVICE%@*}
  230. onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
  231. cat << EOF
  232. menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' $CLASS --class os \$menuentry_id_option 'osprober-efi-$(grub_get_device_id "${DEVICE}")' {
  233. EOF
  234. save_default_entry | sed -e "s/^/\t/"
  235. prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
  236.  
  237. cat <<EOF
  238. chainloader ${EFIPATH}
  239. }
  240. EOF
  241. ;;
  242. linux)
  243. if [ "x$BTRFS" = "xbtrfs" ]; then
  244. LINUXPROBED="`linux-boot-prober btrfs ${BTRFSuuid} ${BTRFSsubvol} 2> /dev/null | tr ' ' '^' | paste -s -d ' '`"
  245. else
  246. LINUXPROBED="`linux-boot-prober ${DEVICE} 2> /dev/null | tr ' ' '^' | paste -s -d ' '`"
  247. fi
  248. prepare_boot_cache=
  249. boot_device_id=
  250. is_top_level=true
  251. title_correction_code=
  252. OS="${LONGNAME}"
  253.  
  254. for LINUX in ${LINUXPROBED} ; do
  255. LROOT="`echo ${LINUX} | cut -d ':' -f 1`"
  256. LBOOT="`echo ${LINUX} | cut -d ':' -f 2`"
  257. LLABEL="`echo ${LINUX} | cut -d ':' -f 3 | tr '^' ' '`"
  258. LKERNEL="`echo ${LINUX} | cut -d ':' -f 4`"
  259. LINITRD="`echo ${LINUX} | cut -d ':' -f 5`"
  260. LPARAMS="`echo ${LINUX} | cut -d ':' -f 6- | tr '^' ' '`"
  261.  
  262. if [ -z "${LLABEL}" ] ; then
  263. LLABEL="${LONGNAME}"
  264. fi
  265.  
  266. if [ "${LROOT}" != "${LBOOT}" ]; then
  267. LKERNEL="${LKERNEL#/boot}"
  268. LINITRD="${LINITRD#/boot}"
  269. fi
  270.  
  271. if [ -z "${prepare_boot_cache}" ]; then
  272. prepare_boot_cache="$(prepare_grub_to_access_device ${LBOOT} | grub_add_tab)"
  273. [ "${prepare_boot_cache}" ] || continue
  274. fi
  275.  
  276. found_other_os=1
  277. onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
  278. recovery_params="$(echo "${LPARAMS}" | grep 'single\|recovery')" || true
  279. counter=1
  280. while echo "$used_osprober_linux_ids" | grep 'osprober-gnulinux-$LKERNEL-${recovery_params}-$counter-$boot_device_id' > /dev/null; do
  281. counter=$((counter+1));
  282. done
  283. if [ -z "$boot_device_id" ]; then
  284. boot_device_id="$(grub_get_device_id "${DEVICE}")"
  285. fi
  286. used_osprober_linux_ids="$used_osprober_linux_ids 'osprober-gnulinux-$LKERNEL-${recovery_params}-$counter-$boot_device_id'"
  287.  
  288. if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then
  289. cat << EOF
  290. menuentry '$(echo "$OS $onstr" | grub_quote)' $CLASS --class gnu-linux --class gnu --class os \$menuentry_id_option 'osprober-gnulinux-simple-$boot_device_id' {
  291. EOF
  292. save_default_entry | grub_add_tab
  293. printf '%s\n' "${prepare_boot_cache}"
  294. cat << EOF
  295. linux ${LKERNEL} ${LPARAMS}
  296. EOF
  297. if [ -n "${LINITRD}" ] ; then
  298. cat << EOF
  299. initrd ${LINITRD}
  300. EOF
  301. fi
  302. cat << EOF
  303. }
  304. EOF
  305. echo "submenu '$(gettext_printf "Advanced options for %s" "${OS} $onstr" | grub_quote)' \$menuentry_id_option 'osprober-gnulinux-advanced-$boot_device_id' {"
  306. is_top_level=false
  307. fi
  308. title="${LLABEL} $onstr"
  309. cat << EOF
  310. menuentry '$(echo "$title" | grub_quote)' --class gnu-linux --class gnu --class os \$menuentry_id_option 'osprober-gnulinux-$LKERNEL-${recovery_params}-$boot_device_id' {
  311. EOF
  312. save_default_entry | sed -e "s/^/$grub_tab$grub_tab/"
  313. printf '%s\n' "${prepare_boot_cache}" | grub_add_tab
  314. cat << EOF
  315. linux ${LKERNEL} ${LPARAMS}
  316. EOF
  317. if [ -n "${LINITRD}" ] ; then
  318. cat << EOF
  319. initrd ${LINITRD}
  320. EOF
  321. fi
  322. cat << EOF
  323. }
  324. EOF
  325. if [ x"$title" = x"$GRUB_ACTUAL_DEFAULT" ] || [ x"Previous Linux versions>$title" = x"$GRUB_ACTUAL_DEFAULT" ]; then
  326. replacement_title="$(echo "Advanced options for ${OS} $onstr" | sed 's,>,>>,g')>$(echo "$title" | sed 's,>,>>,g')"
  327. quoted="$(echo "$GRUB_ACTUAL_DEFAULT" | grub_quote)"
  328. title_correction_code="${title_correction_code}if [ \"x\$default\" = '$quoted' ]; then default='$(echo "$replacement_title" | grub_quote)'; fi;"
  329. grub_warn "$(gettext_printf "Please don't use old title \`%s' for GRUB_DEFAULT, use \`%s' (for versions before 2.00) or \`%s' (for 2.00 or later)" "$GRUB_ACTUAL_DEFAULT" "$replacement_title" "gnulinux-advanced-$boot_device_id>gnulinux-$version-$type-$boot_device_id")"
  330. fi
  331. done
  332. if [ x"$is_top_level" != xtrue ]; then
  333. echo '}'
  334. fi
  335. echo "$title_correction_code"
  336. ;;
  337. macosx)
  338. if [ "${UUID}" ]; then
  339. OSXUUID="${UUID}"
  340. osx_entry xnu_kernel 32
  341. osx_entry xnu_kernel64 64
  342. fi
  343. ;;
  344. hurd)
  345. found_other_os=1
  346. onstr="$(gettext_printf "(on %s)" "${DEVICE}")"
  347. cat << EOF
  348. menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' --class hurd --class gnu --class os \$menuentry_id_option 'osprober-gnuhurd-/boot/gnumach.gz-false-$(grub_get_device_id "${DEVICE}")' {
  349. EOF
  350. save_default_entry | grub_add_tab
  351. prepare_grub_to_access_device ${DEVICE} | grub_add_tab
  352. grub_device="`${grub_probe} --device ${DEVICE} --target=drive`"
  353. mach_device="`echo "${grub_device}" | sed -e 's/(\(hd.*\),msdos\(.*\))/\1s\2/'`"
  354. grub_fs="`${grub_probe} --device ${DEVICE} --target=fs`"
  355. case "${grub_fs}" in
  356. *fs) hurd_fs="${grub_fs}" ;;
  357. *) hurd_fs="${grub_fs}fs" ;;
  358. esac
  359. cat << EOF
  360. multiboot /boot/gnumach.gz root=device:${mach_device}
  361. module /hurd/${hurd_fs}.static ${hurd_fs} --readonly \\
  362. --multiboot-command-line='\${kernel-command-line}' \\
  363. --host-priv-port='\${host-port}' \\
  364. --device-master-port='\${device-port}' \\
  365. --exec-server-task='\${exec-task}' -T typed '\${root}' \\
  366. '\$(task-create)' '\$(task-resume)'
  367. module /lib/ld.so.1 exec /hurd/exec '\$(exec-task=task-create)'
  368. }
  369. EOF
  370. ;;
  371. minix)
  372. cat << EOF
  373. menuentry "${LONGNAME} (on ${DEVICE}, Multiboot)" {
  374. EOF
  375. save_default_entry | sed -e "s/^/\t/"
  376. prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/"
  377. cat << EOF
  378. multiboot /boot/image_latest
  379. }
  380. EOF
  381. ;;
Add Comment
Please, Sign In to add comment