Skip to content
Search

Grub

lastmod 2026-02-06created 2015-02-1314 edits

GNU GRUB (usually GRUB) is the boot loader of the GNU Project. It can load the kernels of most operating systems and can also pass arguments to them. GNU GRUB was formerly called GRand Unified Bootloader, a parody of the English name of the grand unified theory. Most Linux distributions use it as their boot loader.

List of commands

halt
Shut down the system
normal
If you pressed Esc in the menu to enter interactive mode (the grub> prompt) and want to go back to the menu, type normal.

How to boot manually

For GRUB to use the Linux kernel image and load the initial file system image into a RAMDISK, two files are needed. One is vmlinuz, and the other is the initrd.img file. If you set these two up properly, you can boot Linux manually without much difficulty.

grub> ls

First, check the disk information of your computer that GRUB is reading. Here you need to know where you installed Linux.

If you are not sure, you can use the ls command on each disk.

grub> ls (hd0,gpt1)/boot

On Ubuntu, kernel images are usually in the /boot path. So use the ls command on each point to check whether the vmlinuz and initrd files are there.

grub> set root=(hd0,gpt1)

Once you have checked, change the root path to that disk.

grub> linux /boot/vmlinuz root=/dev/nvme0n1p1

Give the Linux kernel image path to the linux command, and enter the dev path that holds the top-level mount point. If the disk number is wrong, Linux will not boot properly and busybox will run instead.

grub> initrd /boot/initrd.img

Finally, set the path of the initial mount file system image used to mount the real Linux root file system.

grub> boot

Now run the boot command and the manual boot is complete.

bootloader-id

An ID given to each operating system.

Example

Ubuntu 16.04 and Ubuntu 18.04 are installed. Boot into Ubuntu 16.04 and run:

$ sudo grub-install --bootloader-id=Ubuntu1604

Then, after booting into Ubuntu 18.04:

$ sudo grub-install --bootloader-id=Ubuntu1804

Start UEFI. In the settings I see new boot entries named Ubuntu1604 and Ubuntu1804, and rearrange the boot order so that the new entry is set first.

Set older kernel as default grub entry

How to change the default GRUB entry.

Open the /etc/default/grub file, and

GRUB_DEFAULT="1>2"

if there is a submenu, separate with the ">" character as above. Note that menu indexes start at 0.

With the entry above, it enters index2 of the submenu of index1.

All of the following examples indicate the first menuentry in the first submenu. Titles are easier to use but numbers are also acceptable for either or both values.

Examples: In the following examples, the main menu consists of the current kernel, a recovery mode option, and the submenu "Previous Linux versions" as the third entry. The desired default is the first entry in the first submenu.

  • GRUB_DEFAULT="Previous Linux versions>Ubuntu, with Linux 3.2.0-18-generic-pae"
  • GRUB_DEFAULT="Previous Linux versions>0"
  • GRUB_DEFAULT="2>0"
  • GRUB_DEFAULT="2>Ubuntu, with Linux 3.2.0-18-generic-pae"

Here is a graphic example. Note that the 2 menuentries immediately below the "Previous Linux versions" would not be visible on booting until the "Previous Linux versions" entry was selected.

Grub_submenu-examples.png

nomodeset

The newest kernels have moved the video mode setting into the kernel. So all the programming of the hardware specific clock rates and registers on the video card happen in the kernel rather than in the X driver when the X server starts.. This makes it possible to have high resolution nice looking splash (boot) screens and flicker free transitions from boot splash to login screen. Unfortunately, on some cards this doesnt work properly and you end up with a black screen. Adding the nomodeset parameter instructs the kernel to not load video drivers and use BIOS modes instead until X is loaded.

Summary version:

최신 커널은 비디오 모드 설정을 커널로 옮겼어. 그래서 비디오 카드의 하드웨어별 클럭 속도와 레지스터를 프로그래밍하는 모든 작업이 X 서버가 시작될 때 X 드라이버가 아닌 커널에서 이루어져. 덕분에 고해상도 멋진 스플래시(부팅) 화면과 부팅 스플래시에서 로그인 화면으로의 깜빡임 없는 전환이 가능해졌지. 안타깝게도, 일부 카드에서는 이게 제대로 작동하지 않아서 검은 화면만 뜨는 경우가 있어. nomodeset 매개변수를 추가하면 커널이 비디오 드라이버를 로드하지 않고 X가 로드될 때까지 BIOS 모드를 사용하도록 지시하는 거야.

Troubleshooting

General fixes when USB boot doesn't work

See Dd#General fixes when USB boot doesn't work for details.

See also

Favorite site

author Zer0 sitemap