win10+ubuntu18.04如何设置默认启动win10

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
回复
头像
eremiter
帖子: 75
注册时间: 2017-04-22 19:12
系统: Ubuntu22

win10+ubuntu18.04如何设置默认启动win10

#1

帖子 eremiter » 2018-06-10 10:33

我进入ubuntu18,更改/etc/default/grub 把 GRUB_DEFAULT=4 改为4,然后 update-cfg,重启根本没有效果。
相应配置如下

代码: 全选

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

### BEGIN /etc/grub.d/00_header ###
if [ -s $prefix/grubenv ]; then
  set have_grubenv=true
  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="0"
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 recordfail {
  set recordfail=1
  if [ -n "${have_grubenv}" ]; then if [ -z "${boot_once}" ]; then save_env recordfail; fi; 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
}

if [ x$feature_default_font_path = xy ] ; then
   font=unicode
else
insmod part_gpt
insmod ext2
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root  daf3a695-7d76-4947-b796-f25a5de2229c
else
  search --no-floppy --fs-uuid --set=root daf3a695-7d76-4947-b796-f25a5de2229c
fi
    font="/usr/share/grub/unicode.pf2"
fi

if loadfont $font ; then
  set gfxmode=auto
  load_video
  insmod gfxterm
  set locale_dir=$prefix/locale
  set lang=zh_CN
  insmod gettext
fi
terminal_output gfxterm
if [ "${recordfail}" = 1 ] ; then
  set timeout=30
else
  if [ x$feature_timeout_style = xy ] ; then
    set timeout_style=menu
    set timeout=10
  # Fallback normal timeout code in case the timeout_style feature is
  # unavailable.
  else
    set timeout=10
  fi
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
if background_color 44,0,30,0; then
  clear
fi
### END /etc/grub.d/05_debian_theme ###

### BEGIN /etc/grub.d/10_linux ###
function gfxmode {
	set gfxpayload="${1}"
	if [ "${1}" = "keep" ]; then
		set vt_handoff=vt.handoff=1
	else
		set vt_handoff=
	fi
}
if [ "${recordfail}" != 1 ]; then
  if [ -e ${prefix}/gfxblacklist.txt ]; then
    if hwmatch ${prefix}/gfxblacklist.txt 3; then
      if [ ${match} = 0 ]; then
        set linux_gfx_mode=keep
      else
        set linux_gfx_mode=text
      fi
    else
      set linux_gfx_mode=text
    fi
  else
    set linux_gfx_mode=keep
  fi
else
  set linux_gfx_mode=text
fi
export linux_gfx_mode
menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-daf3a695-7d76-4947-b796-f25a5de2229c' {
	recordfail
	load_video
	gfxmode $linux_gfx_mode
	insmod gzio
	if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
	insmod part_gpt
	insmod ext2
	if [ x$feature_platform_search_hint = xy ]; then
	  search --no-floppy --fs-uuid --set=root  daf3a695-7d76-4947-b796-f25a5de2229c
	else
	  search --no-floppy --fs-uuid --set=root daf3a695-7d76-4947-b796-f25a5de2229c
	fi
        linux	/boot/vmlinuz-4.15.0-20-generic root=UUID=daf3a695-7d76-4947-b796-f25a5de2229c ro  quiet splash $vt_handoff
	initrd	/boot/initrd.img-4.15.0-20-generic
}
submenu 'Ubuntu 高级选项' $menuentry_id_option 'gnulinux-advanced-daf3a695-7d76-4947-b796-f25a5de2229c' {
	menuentry 'Ubuntu,Linux 4.15.0-20-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.15.0-20-generic-advanced-daf3a695-7d76-4947-b796-f25a5de2229c' {
		recordfail
		load_video
		gfxmode $linux_gfx_mode
		insmod gzio
		if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
		insmod part_gpt
		insmod ext2
		if [ x$feature_platform_search_hint = xy ]; then
		  search --no-floppy --fs-uuid --set=root  daf3a695-7d76-4947-b796-f25a5de2229c
		else
		  search --no-floppy --fs-uuid --set=root daf3a695-7d76-4947-b796-f25a5de2229c
		fi
		echo	'载入 Linux 4.15.0-20-generic ...'
	        linux	/boot/vmlinuz-4.15.0-20-generic root=UUID=daf3a695-7d76-4947-b796-f25a5de2229c ro  quiet splash $vt_handoff
		echo	'载入初始化内存盘...'
		initrd	/boot/initrd.img-4.15.0-20-generic
	}
	menuentry 'Ubuntu, with Linux 4.15.0-20-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.15.0-20-generic-recovery-daf3a695-7d76-4947-b796-f25a5de2229c' {
		recordfail
		load_video
		insmod gzio
		if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
		insmod part_gpt
		insmod ext2
		if [ x$feature_platform_search_hint = xy ]; then
		  search --no-floppy --fs-uuid --set=root  daf3a695-7d76-4947-b796-f25a5de2229c
		else
		  search --no-floppy --fs-uuid --set=root daf3a695-7d76-4947-b796-f25a5de2229c
		fi
		echo	'载入 Linux 4.15.0-20-generic ...'
	        linux	/boot/vmlinuz-4.15.0-20-generic root=UUID=daf3a695-7d76-4947-b796-f25a5de2229c ro recovery nomodeset 
		echo	'载入初始化内存盘...'
		initrd	/boot/initrd.img-4.15.0-20-generic
	}
}

### 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_memtest86+ ###
### END /etc/grub.d/20_memtest86+ ###

### BEGIN /etc/grub.d/30_os-prober ###
menuentry 'Windows Boot Manager (on /dev/nvme0n1p1)' --class windows --class os $menuentry_id_option 'osprober-efi-FCE9-CE97' {
	insmod part_gpt
	insmod fat
	if [ x$feature_platform_search_hint = xy ]; then
	  search --no-floppy --fs-uuid --set=root  FCE9-CE97
	else
	  search --no-floppy --fs-uuid --set=root FCE9-CE97
	fi
	chainloader /EFI/Microsoft/Boot/bootmgfw.efi
}
set timeout_style=menu
if [ "${timeout}" = 0 ]; then
  set timeout=10
fi
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/30_uefi-firmware ###
menuentry 'System setup' $menuentry_id_option 'uefi-firmware' {
	fwsetup
}
### END /etc/grub.d/30_uefi-firmware ###

### 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 ###
/boot/grub/grub.cfg

代码: 全选

# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

#GRUB_DEFAULT=0
GRUB_DEFAULT=4
#GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=3
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"
附件
2.jpg
1.jpg
onlylove
论坛版主
帖子: 5208
注册时间: 2007-01-14 16:23

Re: win10+ubuntu18.04如何设置默认启动win10

#2

帖子 onlylove » 2018-06-10 10:41

我记得这个是从0开始数数的,然后再根据你的图,所以怎么想也应该是2啊,4,存在?
头像
psunui
帖子: 39
注册时间: 2013-04-24 2:40

Re: win10+ubuntu18.04如何设置默认启动win10

#3

帖子 psunui » 2018-06-10 12:03

启动顺序
sudo mv /etc/grub.d/30_os-prober /etc/grub.d/07_os-prober
sudo update-grub

或者用sudo nautilus命令进入etc/grub.d目录手动把30_os-prober改成07_os-prober然后更新grub
头像
psunui
帖子: 39
注册时间: 2013-04-24 2:40

Re: win10+ubuntu18.04如何设置默认启动win10

#4

帖子 psunui » 2018-06-10 12:12

另外,你的方式没问题,是命令敲错了,改完后用sudo update-grub应该就可以了
poloshiao
论坛版主
帖子: 18279
注册时间: 2009-08-04 16:33

Re: win10+ubuntu18.04如何设置默认启动win10

#5

帖子 poloshiao » 2018-06-10 12:15

默认启动 win10
1. grub 開機選單 默认启动項目 會呈現亮光條
這個時候 如果你不要按向上/向下鍵 時間到 就載入默认启动項目 開機
1-1. 意思是 你只要讓 亮光條 顯示在 'Windows Boot Manager (on /dev/nvme0n1p1)' 這一行 即可
我进入ubuntu18,更改/etc/default/grub 把 GRUB_DEFAULT=4 改为4,然后 update-cfg,重启根本没有效果。
/boot/grub/grub.cfg
#GRUB_DEFAULT=0
GRUB_DEFAULT=4
1. 如果你維持
GRUB_DEFAULT=0
那麼 開機 grub 開機選單 亮光條 一直出現在第一個項目
通常是 Ubuntu 的最新版本 linux kernel
1-1. 如果你曾經更動 GRUB_DEFAULT<>0
只要改回 GRUB_DEFAULT=0
並且執行 sudo update-grub
那麼 開機 grub 開機選單 亮光條 就會重新出現在第一個項目
### BEGIN /etc/grub.d/30_os-prober ###
menuentry 'Windows Boot Manager (on /dev/nvme0n1p1)' --class windows --class os $menuentry_id_option 'osprober-efi-FCE9-CE97' {
...
### END /etc/grub.d/30_os-prober ###
2. 如果你改變
GRUB_DEFAULT=Windows Boot Manager (on /dev/nvme0n1p1)

GRUB_DEFAULT="Windows Boot Manager (on /dev/nvme0n1p1)"
# 請用複製/貼上 以免打錯字
並且執行 sudo update-grub
那麼 開機 grub 開機選單 亮光條 就會重新出現在 Windows Boot Manager (on /dev/nvme0n1p1) 這一行
2-1. 注意 上述引號可能不同

3. 詳細參閱
https://www.gnu.org/software/grub/manua ... figuration
6.1 Simple configuration handling
‘GRUB_DEFAULT’
For example, if you have:
menuentry 'Example GNU/Linux distribution' --class gnu-linux --id example-gnu-linux {
...
}
then you can make this the default using:
GRUB_DEFAULT=example-gnu-linux

4. 使用這個方法的好處是 不必煩惱 GRUB_DEFAULT=n, n 的數字值 會改變
头像
eremiter
帖子: 75
注册时间: 2017-04-22 19:12
系统: Ubuntu22

Re: win10+ubuntu18.04如何设置默认启动win10

#6

帖子 eremiter » 2018-06-10 21:19

poloshiao 写了:
默认启动 win10
1. grub 開機選單 默认启动項目 會呈現亮光條
這個時候 如果你不要按向上/向下鍵 時間到 就載入默认启动項目 開機
1-1. 意思是 你只要讓 亮光條 顯示在 'Windows Boot Manager (on /dev/nvme0n1p1)' 這一行 即可
我进入ubuntu18,更改/etc/default/grub 把 GRUB_DEFAULT=4 改为4,然后 update-cfg,重启根本没有效果。
/boot/grub/grub.cfg
#GRUB_DEFAULT=0
GRUB_DEFAULT=4
1. 如果你維持
GRUB_DEFAULT=0
那麼 開機 grub 開機選單 亮光條 一直出現在第一個項目
通常是 Ubuntu 的最新版本 linux kernel
1-1. 如果你曾經更動 GRUB_DEFAULT<>0
只要改回 GRUB_DEFAULT=0
並且執行 sudo update-grub
那麼 開機 grub 開機選單 亮光條 就會重新出現在第一個項目
### BEGIN /etc/grub.d/30_os-prober ###
menuentry 'Windows Boot Manager (on /dev/nvme0n1p1)' --class windows --class os $menuentry_id_option 'osprober-efi-FCE9-CE97' {
...
### END /etc/grub.d/30_os-prober ###
2. 如果你改變
GRUB_DEFAULT=Windows Boot Manager (on /dev/nvme0n1p1)

GRUB_DEFAULT="Windows Boot Manager (on /dev/nvme0n1p1)"
# 請用複製/貼上 以免打錯字
並且執行 sudo update-grub
那麼 開機 grub 開機選單 亮光條 就會重新出現在 Windows Boot Manager (on /dev/nvme0n1p1) 這一行
2-1. 注意 上述引號可能不同

3. 詳細參閱
https://www.gnu.org/software/grub/manua ... figuration
6.1 Simple configuration handling
‘GRUB_DEFAULT’
For example, if you have:
menuentry 'Example GNU/Linux distribution' --class gnu-linux --id example-gnu-linux {
...
}
then you can make this the default using:
GRUB_DEFAULT=example-gnu-linux

4. 使用這個方法的好處是 不必煩惱 GRUB_DEFAULT=n, n 的數字值 會改變
非常感謝熱心詳細的解答,我看教程是4,原來我的情況,要改為2,就可以默認啟動win10
poloshiao
论坛版主
帖子: 18279
注册时间: 2009-08-04 16:33

Re: win10+ubuntu18.04如何设置默认启动win10

#7

帖子 poloshiao » 2018-06-10 23:29

4. 使用這個方法的好處是 不必煩惱 GRUB_DEFAULT=n, n 的數字值 會改變
我看教程是4,原來我的情況,要改為2,就可以默認啟動win10
1. 如果你使用 2 可以默認啟動 win10
1-1. 這個 2 將來可能會改變 # 例如 ubuntu 自動更新 Linux kernel 時
1-2. 改變時 你就要記得修改一次
头像
Archer123
帖子: 146
注册时间: 2008-05-18 10:16

Re: win10+ubuntu18.04如何设置默认启动win10

#8

帖子 Archer123 » 2018-06-21 14:19

boot-repair 如果你是win10 ubuntu18.04 双系统的话, 可以尝试用 boot-repair 修复 会直接找到win10的启动引导的.

我是easybcd 添加ubutnu失败 用的boot-repair 修复 直接找到win10 添加到grub2启动引导里的.

http://forum.ubuntu.org.cn/viewtopic.php?f=186&t=487389
头像
Archer123
帖子: 146
注册时间: 2008-05-18 10:16

Re: win10+ubuntu18.04如何设置默认启动win10

#9

帖子 Archer123 » 2018-06-21 14:23

想修改和配置 启动顺序的话 可以用这个 grub-customizer 一个图形化的grub配置工具. 当然修改配置文件也可以.
grub.png
我就是用它来改的win10 第一顺位启动.
头像
tang.zhe
帖子: 1505
注册时间: 2010-07-15 13:31

Re: win10+ubuntu18.04如何设置默认启动win10

#10

帖子 tang.zhe » 2018-06-21 19:37

:em11
头像
qq420100523
帖子: 1684
注册时间: 2009-07-31 18:56
系统: windows、ubuntu
来自: 广东阳江

Re: win10+ubuntu18.04如何设置默认启动win10

#11

帖子 qq420100523 » 2018-06-29 10:38

poloshiao 写了:
默认启动 win10
1. grub 開機選單 默认启动項目 會呈現亮光條
這個時候 如果你不要按向上/向下鍵 時間到 就載入默认启动項目 開機
1-1. 意思是 你只要讓 亮光條 顯示在 'Windows Boot Manager (on /dev/nvme0n1p1)' 這一行 即可
我进入ubuntu18,更改/etc/default/grub 把 GRUB_DEFAULT=4 改为4,然后 update-cfg,重启根本没有效果。
/boot/grub/grub.cfg
#GRUB_DEFAULT=0
GRUB_DEFAULT=4
1. 如果你維持
GRUB_DEFAULT=0
那麼 開機 grub 開機選單 亮光條 一直出現在第一個項目
通常是 Ubuntu 的最新版本 linux kernel
1-1. 如果你曾經更動 GRUB_DEFAULT<>0
只要改回 GRUB_DEFAULT=0
並且執行 sudo update-grub
那麼 開機 grub 開機選單 亮光條 就會重新出現在第一個項目
### BEGIN /etc/grub.d/30_os-prober ###
menuentry 'Windows Boot Manager (on /dev/nvme0n1p1)' --class windows --class os $menuentry_id_option 'osprober-efi-FCE9-CE97' {
...
### END /etc/grub.d/30_os-prober ###
2. 如果你改變
GRUB_DEFAULT=Windows Boot Manager (on /dev/nvme0n1p1)

GRUB_DEFAULT="Windows Boot Manager (on /dev/nvme0n1p1)"
# 請用複製/貼上 以免打錯字
並且執行 sudo update-grub
那麼 開機 grub 開機選單 亮光條 就會重新出現在 Windows Boot Manager (on /dev/nvme0n1p1) 這一行
2-1. 注意 上述引號可能不同

3. 詳細參閱
https://www.gnu.org/software/grub/manua ... figuration
6.1 Simple configuration handling
‘GRUB_DEFAULT’
For example, if you have:
menuentry 'Example GNU/Linux distribution' --class gnu-linux --id example-gnu-linux {
...
}
then you can make this the default using:
GRUB_DEFAULT=example-gnu-linux

4. 使用這個方法的好處是 不必煩惱 GRUB_DEFAULT=n, n 的數字值 會改變
如何取得我本机上的

代码: 全选

GRUB_DEFAULT=[color=#FF0000]Windows Boot Manager (on /dev/nvme0n1p1)
poloshiao
论坛版主
帖子: 18279
注册时间: 2009-08-04 16:33

Re: win10+ubuntu18.04如何设置默认启动win10

#12

帖子 poloshiao » 2018-06-29 11:32

如何取得我本机上的 ...
猜測 你是想要取得 grub 2 開機選單內的 Windows 開機選項 ?

試試
把下面指令 複製 貼進終端機 執行

代码: 全选

sudo cat /boot/grub/grub.cfg | grep menuentry | grep Windows
回复