Restoring the OS bootloader
Note
This guide only applies to Linux servers configured for legacy BIOS boot. Restoring GRUB on UEFI systems requires a different procedure.
If your BareMetal legacy BIOS server experiences GRUB
To restore the bootloader:
-
Start the server from the Rescue CD image.
In the main SystemRescue menu, select Boot SystemRescue using default options, press ENTER and wait for SystemRescue to load.
-
List server disks and their partitions:
fdisk -lResult:
Disk /dev/sda: 838.36 GiB, 900185481216 bytes, 1758174768 sectors Disk model: SAMSUNG MZ7GE900 Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/0 size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: gpt Disk identifier: D79F5407-DEEC-4A1D-983F-3AC5******** Device Start End Sectors Size Type /dev/sda1 2048 614399 612352 299M BIOS boot /dev/sda2 614400 21585919 20971520 10G Linux filesystem /dev/sda3 21585920 34168831 12582912 6G Linux filesystem /dev/sda4 34168832 1732861951 1698693120 810G Linux filesystem Disk /dev/sdb: 838.36 GiB, 900185481216 bytes, 1758174768 sectors Disk model: SAMSUNG MZ7GE900 Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/0 size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: gpt Disk identifier: CDZACB4C-1618-4BAF-A6BB-D2B9******** Device Start End Sectors Size Type /dev/sdb1 2048 614399 612352 299M BIOS boot /dev/sdb2 614400 21585919 20971520 10G Linux filesystem /dev/sdb3 21585920 34168831 12582912 6G Linux filesystem /dev/sdb4 34168832 1732861951 1698693120 810G Linux filesystem Disk /dev/md127: 6 GiB, 6438256640 bytes, 12574720 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/0 size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/md126: 9.99 GiB, 10729029632 bytes, 20955136 sectors = 512 bytes Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/0 size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/md125: 809.88 GiB, 869596659712 bytes, 1698430976 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/0 size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/loop: 824.97 MiB, 865046528 bytes, 1689544 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytesIn the example above, the
fdiskutility displayed information about the/dev/sdaand/dev/sdbphysical disks, their partitions, and the partitions of the server’s RAID array:/dev/md127,/dev/md126, and/dev/md125.The reference server uses the following partition scheme:
/dev/md126:/bootpartition./dev/md127:SWAPpartition./dev/md125:/root partition.
You need to mount the
/bootand/partitions in SystemRescue. -
Mount BareMetal server’s root and boot partitions in SystemRescue:
mount /dev/md125 /mnt/ mount /dev/md126 /mnt/bootNote
If the system has no RAID array, you need to mount physical disk partitions, e.g.,
/dev/sda1,/dev/sda2, directly.If you installed your OS using LVM
, you need to mount the/dev/mapperpartition.When using an UEFI
bootloader, also mount the corresponding EFI system partition, e.g.,mount /dev/sda3 /mnt/boot/efi, where/dev/sda3is the EFI partition. -
Mount the
/sys,/proc, and/devdirectories:mount --bind /sys /mnt/sys mount --bind /proc /mnt/proc mount --bind /dev /mnt/dev -
Create a new SystemRescue shell environment using the server OS’s previously mounted BareMetal filesystem:
chroot /mnt /bin/bash -
If GRUB is not installed, install it on all disks you are planning to use as OS boot drives. If GRUB is already installed, proceed to the next step.
In our example, you need to install GRUB on the
/dev/sdaand/dev/sdbdisks.grub-install /dev/sda grub-install /dev/sdbResult:
Installing for i386-pc platform. Installation finished. No error reported. -
Generate a GRUB configuration file:
update-grubResult:
Sourcing file '/etc/default/grub' Sourcing file '/etc/default/grub.d/init-select.cfg' Generating grub configuration file ... Found linux image: /boot/uml inuz-5.15.0-130-generic Found initrd image: /boot/initrd.img-5.15.0-130-generic Found linux image: /boot/vmlinuz-5.15.0-113-generic Found initrd image: /boot/initrd.img-5.15.0-113-generic Found linux image: /boot/vmlinuz-5.15.0-25-generic Found initrd image: /boot/initrd.img-5.15.0-25-generic Warning: os-prober will not be executed to detect other bootable partitions. Systems on them will not be added to the GRUB boot configuration. Check GRUB_DISABLE_OS_PROBER documentation entry. done -
Exit the
chrootenvironment:exit -
Disable the virtual CD drive in the KVM console:
- Click the CD icon or select Media → Virtual Media Wizard... in the top menu of the KVM console window.
- In the window that opens, click Disconnect under CD/DVD Media1.
- Click Close.
-
Restart the server:
reboot