Install Grub setup and set up Linux bootloader

Diese Seite gibt es auch in Deutsch

Ubuntu and most other Linux-based operating systems use GRUB2 as a boot loader. In GRUB, settings such as the default operating system or the use of a background image can be set. In addition, GRUB can be configured to load multiple operating systems: Dualboot.

Grub can start the most different operating systems and reads the following file systems: ext2, ext3, UFS, UFS2, ReiserFS, FAT, NTFS, ISO9660, JFS, Minix, FFS, XFS

Install or repair Grub afterwards

If the GRUB bootloader is no longer working properly, it can be repaired by booting the Ubuntu Live DVD. (Ubuntu Live DVD see: Install Ubuntu or start live system; Ubuntu Live USB Stick, see: bootable live USB stick with Ubuntu; for details on booting from DVD / USB see: Booting the computer from USB or DVD - UEFI o. BIOS )

To boot the Ubuntu live system when booting from the disk:

"Try Ubuntu without installation" select:

The following example is a dual-boot installation:

Windows was installed at the beginning and Linux at the end of the hard disk.

The partitions can be displayed in the terminal with sudo fdisk -l:

Then select the hard disk with the existing Linux installation and mount it, in my case: sda6:

sudo mount /dev/sda6 /mnt
sudo mount -o bind /dev /mnt/dev
sudo mount -o bind /sys /mnt/sys
sudo mount -t proc /proc /mnt/proc
sudo cp /proc/mounts /mnt/etc/mtab
sudo chroot /mnt /bin/ba

and finally the actual reinstallation of the Grub bootloader:

grub-install /dev/sda
grub-install --recheck /dev/sda
update-grub

At this point, an existing Windows installation is also found and included.

Customize Grub

Originally Grub was configured in the menu.lst file. Since Ubuntu 10.04 there is no menu.lst anymore, Grub2 should be customized with the file /etc/default/grub.

Set default operating system

Normally Linux is loaded automatically after a certain timeout. The behavior can easily be adjusted in the file /etc/default/grub:

GRUB_DEFAULT=0

loads the first entry in the menu; 1 the second entry, ...

in the following example the Windows installation is the entry number 4:

GRUB_DEFAULT=saved

boots the last operating system used.

In addition, a label can be used for loading, e.g.

GRUB_DEFAULT="Windows Recovery Environment (loader)"

The wait time of the bootloader can be set with "GRUB_TIMEOUT":

The background image with:

GRUB_BACKGROUND="/home/user/Pictures/Background.png".

Important: Take over the settings

The following command is used to take over the settings:

sudo update-grub

"update-grub" then writes the changes into the file /boot/grub/grub.cfg, only then they are active.

Boot Flag

If Linux does not boot after Windows has been installed, this could be caused by the boot flag.

The boot flag points in this case to the Windows and no longer to the Linux partition.

The GRUB menu is no longer displayed, Windows starts automatically.

Temporarily Linux can be started by pressing the key 1 shortly before Windows starts.
Permanently the error can be solved with the help of the Gnome Partition Editor. For the Windows partition the flag boot must be removed under "manage flags" and the setting for the Linux partition must be activated.

positive Bewertung({{pro_count}})
Rate Post:
{{percentage}} % positive
negative Bewertung({{con_count}})

THANK YOU for your review!

Publication: 2022-05-13 from Bernhard 🔔


Top articles in this section


Windows : create a missing recovery partition
When cloning a large hard disk to a smaller one, I lost the recovery partition. So far not bad, Windows works without recovery partition, but in case of an error the partition helps to get the PC up and running again. To summarize, here's how it works with the recovery partition: As long as the partition is still there, it can be deactivated and written to a file. If the partition gets lost unexpectedly, it can be recovered from the Windows setup media. This post is also available as a vide...

clone a large hard disk to a smaller one with the help of free tools
Free tools for cloning a hard disk cannot usually clone a large partition and thus a large hard disk onto a smaller one. Thanks to the command "Shrink Volume" in the disk management of Windows, the hard disk can be prepared for the cloning process and then cloned with the help of open source tools. Thus, for example, a Windows installation with all data can be moved to another disk.To speed up the PC with very little effort, a smaller SSD is usually used as the target. With the procedure describ...

use dd to clone the hard disk block by block or create an image
The Linux command dd can be used to write one hard disk block by block to another. Since all blocks are transferred, it does not matter which file system, partition layout or operating system is to be cloned, only the target hard disk should not be larger than the partition layout of the source hard disk, see: cloning a large hard disk to a smaller one using free tools.

Questions / Comments


By continuing to browse the site, you agree to our use of cookies. More Details