Wed 06 Jan 2016 03:16:48 AM UTC, original submission:
I just hit an annoying problem with grub-install. I was using a Linux PC to prepare a bootable USB flash drive. In the manual for grub-install the instructions state "The usage is basically very simple. You only need to specify one argument to the program, namely, where to install the boot loader."
On my computer /dev/sda was the main hard disk. And /dev/sdb was the USB stick that I wanted to configure. It had a single MSDOS partition formatted with FAT32. I ran "sudo grub-install /dev/sdb" as per the instructions.
It ran without error. When I examined the USB stick I found it contained the stage 1 loader (MBR) but was missing the other GRUB files which were meant to be in /boot/grub. Where were they? Well it turned out they had been written to /boot/grub on the OTHER disk. ie the main hard disk of my computer. So grub-install wrote the MBR to the USB stick (/dev/sdb) and the other grub files to a COMPLETELY DIFFERENT DISK (/dev/sda).
Well, thanks a bunch. It's taken me the most of the day to restore my PC so it boots properly again.
After a lot more research I am beginning to think this behaviour might be by design. Apparently, you are meant to mount the USB stick within the filesystem and pass the mount point to grub-install via the --boot-directory parameter.
If so, this needs to be explained properly in the manual. It is completely misleading to say that grub-install needs only one argument.
The most likely use-case is when you are using a working computer to make changes to a second drive that you're configuring. It's quite unlikely that you would want to change the bootloader on the same computer that you're using. And it's completely inconceivable that you would want to write the MBR on to one device and write the other GRUB files on to a completely different device. In fact it's something that should be trapped and prevented in the program.
Please correct me if I have misunderstood how this is meant to work. My version number is grub-install (GRUB) 2.02~beta2-9ubuntu1.7.
|