출처 : https://www.gnu.org/software/grub/manual/legacy/Booting-once_002donly.html


ou can teach GRUB to boot an entry only at next boot time. Suppose that your have an old kernel old_kernel and a new kernel new_kernel. You know that old_kernel can boot your system correctly, and you want to test new_kernel.

To ensure that your system will go back to the old kernel even if the new kernel fails (e.g. it panics), you can specify that GRUB should try the new kernel only once and boot the old kernel after that.

First, modify your configuration file. Here is an example:

     default saved        # This is important!!!
     timeout 10
     
     title the old kernel
     root (hd0,0)
     kernel /old_kernel
     savedefault
     
     title the new kernel
     root (hd0,0)
     kernel /new_kernel
     savedefault 0         # This is important!!!

Note that this configuration file uses `default saved' (see default) at the head and `savedefault 0' (see savedefault) in the entry for the new kernel. This means that GRUB boots a saved entry by default, and booting the entry for the new kernel saves `0' as the saved entry.

With this configuration file, after all, GRUB always tries to boot the old kernel after it booted the new one, because `0' is the entry of the old kernel.

The next step is to tell GRUB to boot the new kernel at next boot time. For this, execute grub-set-default (see Invoking grub-set-default):

     # grub-set-default 1

This command sets the saved entry to `1', that is, to the new kernel.

This method is useful, but still not very robust, because GRUB stops booting, if there is any error in the boot entry, such that the new kernel has an invalid executable format. Thus, it it even better to use the fallback mechanism of GRUB. Look at next subsection for this feature.


WRITTEN BY
RootFriend
개인적으로... 나쁜 기억력에 도움되라고 만들게되었습니다.

,


In dual-boot system (Win 10 and Kali), whenever Win 10 is updated , the Grub is replaced by window boot manager.


The Grub can be recovered with the Kali live boot USB.


After boot process with Kali live, check the linux and EFI partitions.


# fdisk -l 



In my case, 

EFI partition ==> /dev/sda1

Linux partition ==> /dev/sda7

keep that in mind,


# mount /dev/sda7 /mnt

# mount --bind /dev /mnt/dev

# mount --bind /dev/pts /mnt/dev/pts

# mount --bind /proc /mnt/proc

# mount --bind /sys /mnt/sys

# mount --bind /dev/sda1 /mnt/boot/efi

# chroot /mnt /bin/bash

# grub-install /dev/sda

# update-grub

# exit

# umount /mnt/boot/efi

# umount /mnt/sys

# umount /mnt/proc

# umount /mnt/dev/pts

# umount /mnt/dev

# umount /mnt

# shutdown -h 0 -r


After reboot, you can see the grub entry, but window partition might not be seen,

Thus, after boot up, do "update-grub" again, 


$ sudo update-grub


Then, after next boot, you can see the window boot manager in Grub entry .




WRITTEN BY
RootFriend
개인적으로... 나쁜 기억력에 도움되라고 만들게되었습니다.

,

because I'm familiar with CentOS, i couldn't set default kernel easily in grub.cfg in kali(debian) linux


basically, there is main menu which in turns, includes submenu.


what I want to do is setting default kernel to third entry in submenu within secondary entry in main menu.


here is the example


$ vim  /etc/default/grub

and set GRUB_DEFAULT="1>2"


$ sudo update-grub 




WRITTEN BY
RootFriend
개인적으로... 나쁜 기억력에 도움되라고 만들게되었습니다.

,