CompTIA Linux+ (XK0-006)System ManagementMedium
A technician replaced a failed disk in a BIOS-based server and restored the operating system data to the new disk, /dev/sda. The system fails to boot because no bootloader is installed on the new disk. After booting into a rescue environment and chrooting into the restored system, which command should the technician run to install GRUB onto the disk's boot sector?
- Aupdate-grub
- Bdracut -f
- Cgrub2-install /dev/sda
- Dgrub2-mkconfig -o /boot/grub2/grub.cfg
Show answer & explanationAnswer & explanation
Correct answer: C. grub2-install /dev/sda
'grub2-install /dev/sda' writes the GRUB boot code to the disk's MBR/boot sector, which is required after replacing a disk that has no bootloader installed. 'grub2-mkconfig' and 'update-grub' only regenerate the grub.cfg configuration file, and 'dracut' rebuilds the initramfs image, neither of which installs the actual bootloader.
Why the other options are wrong
- A. Debian-based wrapper for grub2-mkconfig, also just regenerates the config file.
- B. Rebuilds the initramfs image, unrelated to installing the bootloader.
- D. Regenerates the grub.cfg file but assumes GRUB is already installed to the disk.
grub2-install
Command that writes the GRUB2 bootloader code to a disk's boot sector (MBR) or EFI partition, required whenever a new disk lacks a bootloader.
- Different from grub2-mkconfig, which only writes the config file
- Must target the whole disk device (e.g., /dev/sda), not a partition, for BIOS systems
- Often run inside a chroot after disk restoration or recovery
Memory trick: Install puts GRUB's boots on the disk; mkconfig just writes its itinerary.