MyTetra Share
Делитесь знаниями!
Актуальная информация милавица на сайте.
Change default booting OS
Время создания: 12.09.2017 21:29
Текстовые метки: boot, grub
Раздел: root - Linux

Customizing the /etc/default/grub file


There are two ways of doing this using editing a grub file. These are described in the Ubuntu Community Documentation Grub2 page


The two ways are:

  • Boot which ever operating system you booted last time, the "saved method"
  • Boot a specific operating system by default.


Finding the menuentry to set as the new default

To start we need to find out what we are booting or want to boot. Open a terminal with Ctrl+Alt+T and type in

grep menuentry /boot/grub/grub.cfg

Example:

menuentry 'Ubuntu, with Linux 2.6.35-31-generic' --class ubuntu --class gnu-linux --class gnu --class os {

menuentry 'Ubuntu, with Linux 2.6.35-31-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {

menuentry 'Ubuntu, with Linux 2.6.35-30-generic' --class ubuntu --class gnu-linux --class gnu --class os {

menuentry 'Ubuntu, with Linux 2.6.35-30-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {

menuentry "Memory test (memtest86+)" {

menuentry "Memory test (memtest86+, serial console 115200)" {

menuentry "Windows NT/2000/XP (loader) (on /dev/sda1)" {

menuentry "Ubuntu, with Linux 2.6.32-34-generic (on /dev/sdb1)" {

menuentry "Ubuntu, with Linux 2.6.32-34-generic (recovery mode) (on /dev/sdb1)" {

menuentry "Ubuntu, with Linux 2.6.32-33-generic (on /dev/sdb1)" {

menuentry "Ubuntu, with Linux 2.6.32-33-generic (recovery mode) (on /dev/sdb1)" {

menuentry "Windows Vista (loader) (on /dev/sdc1)" {


You can see that the "saved" method can come in handy when booting multiple operating systems. Save the name of the entry you want e.g. Windows NT/2000/XP (loader) (on /dev/sda1), we need it later.


Editing the /etc/default/grub file


A. Saved method:

I changed the value of GRUB_DEFAULT to saved:

GRUB_DEFAULT=saved


I enabled the SAVEDEFAULT functionality by adding the following line:

GRUB_SAVEDEFAULT=true


B. Specific menuentry:

Change the value of GRUB_DEFAULT to the name of the Windows system you want to always boot. The name of the corresponding Grub menuentry can be found as described in the previous section.

I wanted to have Window XP always set as default at boot, I would set GRUB_DEFAULT to "Windows NT/2000/XP (loader) (on /dev/sda1)":

GRUB_DEFAULT="Windows NT/2000/XP (loader) (on /dev/sda1)"


You could also set GRUB_DEFAULT to the line number in the menu entry list (with 0 being the first), but when the kernel in Ubuntu is updated grub adds the new kernel to the top of the list, you would have to change the number, since Windows is the last one in the menu entry list. You can see this in my menu entry list.


Update the boot configuration

sudo update-grub


 
MyTetra Share v.0.53
Яндекс индекс цитирования