设为首页 收藏本站
查看: 826|回复: 0

[经验分享] ubuntu双系统开机默认启动windows设置

[复制链接]

尚未签到

发表于 2018-5-9 06:23:16 | 显示全部楼层 |阅读模式
    一、
  我的电脑原来先装的Windows XP,后来由于工作需要,又装了一个Linux_Ubuntu 9.04,我设置了定时开机,但是总是默认启动到Ubuntu环境。
  通过下面的操作把Windows XP改为默认启动系统:
  启动ubuntu后,输入:sudo gedit /boot/grub/menu.lst
  输入正确密码,打开menu.lst。
  从第一行往下看,找到第一个开头没有#的行
  default 0
  继续往下看,找到所有以title开头的行(注意,以#开头的都不要理)。
  我的文件中,以title开头的共(开头没有#)有7行,依次为:
  title Ubuntu 8.04.1, kernel 2.6.24-21-generic
  title Ubuntu 8.04.1, kernel 2.6.24-21-generic (recovery mode)
  title Ubuntu 8.04.1, kernel 2.6.24-16-generic
  title Ubuntu 8.04.1, kernel 2.6.24-16-generic (recovery mode)
  title Ubuntu 8.04.1, memtest86+
  title Other operating systems:
  title Windows NT/2000/XP
  这些行不是像这样连在一起的,它们分散在文件中。把这7行写一起,为的是让我们看得清楚些。事实上,除去每行前面的title,这7行就是我开机时出现的启动菜单项,系统在启动时读的就是该文件。
  default 0
  表示默认情况下启动以上菜单上第1行(0+1)的系统。
  我们看到windows处于第7(6+1)行,所以现在把default的值改为6,保存文件,重启系统,默认启动的系统就改为Windows了。
  二、在Ubuntu 10.04中,并没有menu.lst文件,文件名已经变成grub.cfg。
  更改操作如下:
  1、备份原文件为grub.cfg.bak
  代码:sudo cp /boot/grub/grub.cfg /boot/grub/grub.cfg.bak
  2、修改启动顺序
  代码:sudo gedit /boot/grub/grub.cfg
  在打开顶文件中找到set default="0",可以看出默认是第一项(从0开始计数)。
  然后找到以menuentry开头的所有行,下面是我电脑上该文件的内容,一共7行,最后一行是Windows XP项。以我的文件内容为例,我只要set default="6(注意:从0开始计数)就可以把Windows XP改为默认启动系统。
  menuentry 'Ubuntu,Linux 2.6.32-22-generic'
  menuentry 'Ubuntu,Linux 2.6.32-22-generic (恢复模式)'
  menuentry 'Ubuntu,Linux 2.6.32-21-generic'
  menuentry 'Ubuntu,Linux 2.6.32-21-generic (恢复模式)'
  menuentry "Memory test (memtest86+)"
  menuentry "Memory test (memtest86+, serial console 115200)"
  menuentry "Microsoft Windows XP Professional (on /dev/sda1)"
  三、当系统“/boot/grub/   ”里根本没有“menu.lst”这个文件时,具体步骤如下:
  1.用root身份登录Ubuntu
  默认下是静止本地root登录的,解决方法是:系统-系统管理-登录窗口-安全-选择允许本地系统管理员登录;sudo passwd回车;输入你的密码;为root设定密码;重复;就可以登录root了。
  2./boot/grub/目录下没有menu.lst这个文件,可以自己新建一个,然后把下面这些代码复制到新建的menu.lst这个文件里,将default的值改成4,保存即可。
  开始:
  # menu.lst - See: grub(8), info grub, update-grub(8)
  #            grub-install(8), grub-floppy(8),
  #            grub-md5-crypt, /usr/share/doc/grub
  #            and /usr/share/doc/grub-doc/.
  ## default num
  # Set the default entry to the entry number NUM. Numbering starts from 0, and
  # the entry number 0 is the default if the command is not used.
  #
  # You can specify 'saved' instead of a number. In this case, the default entry
  # is the entry saved with the command 'savedefault'.
  # WARNING: If you are using dmraid do not use 'savedefault' or your
  # array will desync and will not let you boot your system.
  default        0
  ## timeout sec
  # Set a timeout, in SEC seconds, before automatically booting the default entry
  # (normally the first entry defined).
  timeout        10
  ## hiddenmenu
  # Hides the menu by default (press ESC to see the menu)
  #hiddenmenu
  # Pretty colours
  #color cyan/blue white/blue
  ## password ['--md5'] passwd
  # If used in the first section of a menu file, disable all interactive editing
  # control (menu entry editor and command-line) and entries protected by the
  # command 'lock'
  # e.g. password topsecret
  #      password --md5 $1$gLhU0/$aW78kHK1QfV3P2b2znUoe/
  # password topsecret
  #
  # examples
  #

  #>  # root        (hd0,0)
  # makeactive
  # chainloader    +1
  #

  #>  # root        (hd0,1)
  # kernel    /vmlinuz root=/dev/hda2 ro
  #
  #
  # Put static boot stanzas before and/or after AUTOMAGIC KERNEL LIST
  ### BEGIN AUTOMAGIC KERNELS LIST
  ## lines between the AUTOMAGIC KERNELS LIST markers will be modified
  ## by the debian update-grub script except for the default options below
  ## DO NOT UNCOMMENT THEM, Just edit them to your needs
  ## ## Start Default Options ##
  ## default kernel options
  ## default kernel options for automagic boot options
  ## If you want special options for specific kernels use kopt_x_y_z
  ## where x.y.z is kernel version. Minor versions can be omitted.
  ## e.g. kopt=root=/dev/hda1 ro
  ##      kopt_2_6_8=root=/dev/hdc1 ro
  ##      kopt_2_6_8_2_686=root=/dev/hdc2 ro
  # kopt=root=UUID=04d0edaf-6a91-46c5-8bec-35a97eeaa27f ro
  ## default grub root device
  ## e.g. groot=(hd0,0)
  # groot=04d0edaf-6a91-46c5-8bec-35a97eeaa27f

  ## should update-grub create>
  ## e.g.>  ##      alternative=false

  #>
  ## should update-grub lock>  ## e.g. lockalternative=true
  ##      lockalternative=false
  # lockalternative=false
  ## additional options to use with the default boot option, but not with the

  ##>  ## e.g. defoptions=vga=791 resume=/dev/hda5
  # defoptions=quiet splash
  ## should update-grub lock old automagic boot options
  ## e.g. lockold=false
  ##      lockold=true
  # lockold=false
  ## Xen hypervisor options to use with the default Xen boot option
  # xenhopt=
  ## Xen Linux kernel options to use with the default Xen boot option
  # xenkopt=console=tty0

  ##>
  ## multiple>
  ## e.g.>  ##      altoptions=(recovery) single

  #>  ## controls how many kernels should be put into the menu.lst
  ## only counts the first occurence of a kernel, not the
  ##>  ## e.g. howmany=all
  ##      howmany=7
  # howmany=all
  ## specify if running in Xen domU or have grub detect automatically
  ## update-grub will ignore non-xen kernels when running in domU and vice versa
  ## e.g. indomU=detect
  ##      indomU=true
  ##      indomU=false
  # indomU=detect
  ## should update-grub create memtest86 boot option
  ## e.g. memtest86=true
  ##      memtest86=false
  # memtest86=true
  ## should update-grub adjust the value of the default booted system
  ## can be true or false
  # updatedefaultentry=false
  ## should update-grub add savedefault to the default options
  ## can be true or false
  # savedefault=false
  ## ## End Default Options ##
  title        Ubuntu 9.04, kernel 2.6.28-11-generic
  uuid        04d0edaf-6a91-46c5-8bec-35a97eeaa27f
  kernel        /boot/vmlinuz-2.6.28-11-generic root=UUID=04d0edaf-6a91-46c5-8bec-35a97eeaa27f ro quiet splash
  initrd        /boot/initrd.img-2.6.28-11-generic
  quiet
  title        Ubuntu 9.04, kernel 2.6.28-11-generic (recovery mode)
  uuid        04d0edaf-6a91-46c5-8bec-35a97eeaa27f
  kernel        /boot/vmlinuz-2.6.28-11-generic root=UUID=04d0edaf-6a91-46c5-8bec-35a97eeaa27f ro single
  initrd        /boot/initrd.img-2.6.28-11-generic
  title        Ubuntu 9.04, memtest86+
  uuid        04d0edaf-6a91-46c5-8bec-35a97eeaa27f
  kernel        /boot/memtest86+.bin
  quiet
  ### END DEBIAN AUTOMAGIC KERNELS LIST
  # This is a divider, added to separate the menu items below from the Debian
  # ones.
  title        Other operating systems:
  root
  # This entry automatically added by the Debian installer for a non-linux OS
  # on /dev/sda1
  title        Microsoft Windows XP Professional
  rootnoverify    (hd0,0)
  savedefault
  makeactive
  chainloader    +1
  结束。
  问题得到解决了吧!呵呵!

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-457248-1-1.html 上篇帖子: 用wubi安装的Ubuntu出现Grub rescue的解决办法 下篇帖子: ubuntu 下搭建arm
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表