Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
    • Yandex Cloud Partner program
  • Blog
  • Pricing
  • Documentation
© 2025 Direct Cursus Technology L.L.C.
Yandex BareMetal
  • Getting started
    • All guides
      • Leasing a server
      • Updating a server
      • Stopping and starting a server
      • Resetting a password on the server
      • Cancel a server lease
      • Connecting to the KVM console
      • Replacing a disk in a RAID array
      • Using Rescue CD
      • Adding a new user SSH key
      • Restoring the OS bootloader
      • Upload image
      • Connecting a BareMetal server to Cloud Backup
    • Service overview
      • Overview
      • Server configurations
      • Overview
      • DHCP
      • Restrictions in BareMetal networks
    • Quotas and limits
    • All tutorials
    • Connecting a BareMetal server to Cloud Backup
    • Configuring VRRP for a cluster of BareMetal servers
    • Setting up network connectivity in a BareMetal subnet
    • Setting up network connectivity between BareMetal and Virtual Private Cloud subnets
    • Delivering USB devices to a BareMetal server or virtual machine
  • Monitoring metrics
  • Audit Trails events
  • Access management
  • Pricing policy
  • FAQ
  1. Step-by-step guides
  2. Servers
  3. Restoring the OS bootloader

Restoring the OS bootloader

Written by
Yandex Cloud
Updated at February 17, 2025

Note

This guide applies to Linux servers running in legacy mode. The procedure for restoring GRUB in UEFI mode is different.

In the event of BareMetal server issues with the GRUB bootloader for Linux distributions running in legacy mode, you can use a Rescue CD boot image to restore GRUB. Proceed in the KVM console.

To restore the bootloader:

  1. 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.

  2. View information about the server storage devices (disks and partitions created on them):

    fdisk -l
    

    Result:

    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 bytes
    

    In the above example, the fdisk utility outputs information about the physical disks (/dev/sda and /dev/sdb), their partitions, and the RAID created from them containing three partitions (/dev/md127, /dev/md126, and /dev/md125).

    The example server is partitioned as follows:

    • /dev/md126: /boot partition.
    • /dev/md127: SWAP partition.
    • /dev/md125: / partition with the root file system.

    You need to mount the /boot and / partitions in SystemRescue.

  3. Mount the partitions with the root file system and boot files for the BareMetal server OS in SystemRescue:

    mount /dev/md125 /mnt/
    mount /dev/md126 /mnt/boot
    

    Note

    If there is no RAID in the OS, you need to mount the physical disk partitions (/dev/sda1, /dev/sda2, etc.).

    If the OS was installed on the disk using LVM, you need to mount the /dev/mapper partition.

    If using the UEFI bootloader, mount the relevant EFI partition as well, e.g., mount /dev/sda3 /mnt/boot/efi, where /dev/sda3 is the EFI partition.

  4. Mount the /sys, /proc, and /dev directories:

    mount --bind /sys /mnt/sys
    mount --bind /proc /mnt/proc
    mount --bind /dev /mnt/dev
    
  5. Create a new SystemRescue OS shell with the environment in the previously mounted BareMetal server OS file system:

    chroot /mnt /bin/bash
    
  6. If GRUB is not installed on the disks, install it. GRUB must be installed on all the disks you are going to boot the server OS from. If GRUB is already installed, proceed to the next step.

    For the example server, you need to install GRUB on the /dev/sda and /dev/sdb disks.

    grub-install /dev/sda
    grub-install /dev/sdb
    

    Result:

    Installing for i386-pc platform.
    Installation finished. No error reported.
    
  7. Generate a GRUB configuration file:

    update-grub
    

    Result:

    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
    
  8. Exit the chroot environment you created:

    exit
    
  9. Disable the virtual CD drive in the KVM console:

    1. In the KVM console window, in the top menu, select Media → Virtual Media Wizard... or click the CD icon.
    2. In the window that opens, click Disconnect under CD/DVD Media1.
    3. Click Close.
  10. Restart the server:

    reboot
    

See alsoSee also

  • Using the Rescue CD recovery and diagnostics disk
  • Resetting the root user password on a server
  • Adding a new user SSH key
  • Replacing a disk in a RAID array

Was the article helpful?

Previous
Adding a new user SSH key
Next
Upload image
© 2025 Direct Cursus Technology L.L.C.