Cannot write to boot sector -- Solved

Questions about Grub, UEFI,the liveCD and the installer
Forum rules
Before you post please read how to get help
Punkin
Level 1
Level 1
Posts: 24
Joined: Wed Dec 13, 2017 12:17 pm

Cannot write to boot sector -- Solved

Post by Punkin » Wed Dec 13, 2017 12:36 pm

When I first installed Mint 18.3 Cinnamon, things went perfectly until it came time to install Grub. At that point I got an error message saying another UEFI would not allow it to write. This box has two systems on it, my older PCLinuxOS 64bit Mate and Mint Cinnamon 18.3. So, having extra room on the HD, I installed another version of PCLinuxOS, which picked up Mint and I can boot into Mint that way. The problem is, I updated Mint last night and, true to form, when Grub tried to write to the boot sector, I got the same error message. I have everything in the BIOS set to Legacy. But why PCLinuxOS will write to the boot sector and Mint will not is the puzzle. I have installed earlier versions of Mint on this machine and never had this problem.

Any idea of what it going on?
Last edited by Punkin on Tue Dec 19, 2017 7:58 pm, edited 1 time in total.

Punkin
Level 1
Level 1
Posts: 24
Joined: Wed Dec 13, 2017 12:17 pm

Re: Cannot write to boot sector

Post by Punkin » Thu Dec 14, 2017 12:49 am

In addition, since I ran the update, and the resultant in ability to update Grub2, my wifi drops out about every 10-12hrs and the only cure is to reboot. So I really need to get this problem fixed.

fabien85
Level 6
Level 6
Posts: 1290
Joined: Tue Mar 11, 2014 4:30 pm

Re: Cannot write to boot sector

Post by fabien85 » Thu Dec 14, 2017 11:04 am

Hi and welcome to the forums,
I got an error message saying another UEFI would not allow it to write
I have everything in the BIOS set to Legacy.
there is a contradiction here. Either you have Mint installed in legacy mode, then you would never receive a message about UEFI, or you have it installed in UEFI mode and then your BIOS has to allow it.
To clear up the confusion, please boot Mint, open a terminal and post the output of the following commands:

Code: Select all

sudo efibootmgr -v
sudo parted --list
sudo gdisk /dev/sda
cat /etc/fstab
ls /boot
Post the results between code tags for readability, using the "code" button just above the typing area.

Punkin
Level 1
Level 1
Posts: 24
Joined: Wed Dec 13, 2017 12:17 pm

Re: Cannot write to boot sector

Post by Punkin » Thu Dec 14, 2017 11:13 am

I did a "straight from the DVD" install, i.e., I did not select any installation mode. Whatever you have set as default is what I used.
Here are the outputs:

sudo efibootmgr -v
efibootmgr: EFI variables are not supported on this system.

sudo parted --list
Model: ATA WDC WD10EZEX-00B (scsi)
Disk /dev/sda: 1000GB
Sector size (logical/physical): 512B/4096B
Partition Table: msdos
Disk Flags:

Number Start End Size Type File system Flags
1 32.3kB 126GB 126GB primary ext4 boot
2 126GB 743GB 617GB extended
5 126GB 249GB 123GB logical ext4
6 249GB 371GB 123GB logical ext4
7 371GB 392GB 21.2GB logical linux-swap(v1)
8 392GB 505GB 113GB logical ext4
9 505GB 627GB 122GB logical ext4
10 627GB 743GB 115GB logical ext4



sudo gdisk /dev/sda
GPT fdisk (gdisk) version 1.0.1

Partition table scan:
MBR: MBR only
BSD: not present
APM: not present
GPT: not present


***************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format
in memory. THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit by
typing 'q' if you don't want to convert your MBR partitions
to GPT format!
***************************************************************


Command (? for help):


cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda8 during installation
UUID=cdb529ef-389c-4178-96a7-60fe30169ff5 / ext4 errors=remount-ro 0 1
# /PCLHome was on /dev/sda6 during installation
UUID=e6a0995b-13b9-452f-a70c-b06d29d84d4e /PCLHome ext4 defaults 0 2
# /home was on /dev/sda9 during installation
UUID=8b66331a-445c-44fe-99a2-b1de05330fc2 /home ext4 defaults 0 2
# swap was on /dev/sda7 during installation
UUID=48813fa2-937a-4054-b3fc-ad09f2ae51a8 none swap sw 0 0


ls /boot
abi-4.10.0-38-generic memtest86+.bin
abi-4.10.0-42-generic memtest86+.elf
config-4.10.0-38-generic memtest86+_multiboot.bin
config-4.10.0-42-generic System.map-4.10.0-38-generic
efi System.map-4.10.0-42-generic
grub vmlinuz-4.10.0-38-generic
initrd.img-4.10.0-38-generic vmlinuz-4.10.0-42-generic
initrd.img-4.10.0-42-generic


Thanks. I am using Mint as my primary OS (after 20yrs with PCLinuxOS) and loving it.

fabien85
Level 6
Level 6
Posts: 1290
Joined: Tue Mar 11, 2014 4:30 pm

Re: Cannot write to boot sector

Post by fabien85 » Fri Dec 15, 2017 12:40 pm

Ok.
I forgot a "-l" in the gdisk command, sorry, but fortunately that didnt make you panick.
What's strange is that you have an efi/ folder in /boot , even though all your install is perfectly in Legacy mode.

Is the machine even compatible with UEFI ? It's a yes if it's an intel mac or if it came with windows 8+ preinstalled, it's most probably a no if it's an earlier mac or came with windows <=7 preinstalled.

Let's try the following commands:

Code: Select all

apt list --installed | grep grub
ls /boot/efi
ls /sys/firmware
Post the results between code tags for readability, using the "code" button just above the typing area.

Additionally I didnt exactly understand "since I ran the update, and the resultant in ability to update Grub2" in your second post. Are you now able to install grub, or just to use sudo update-grub ?

Punkin
Level 1
Level 1
Posts: 24
Joined: Wed Dec 13, 2017 12:17 pm

Re: Cannot write to boot sector

Post by Punkin » Fri Dec 15, 2017 1:22 pm

I have been around linux long enough that I almost always do a "copy and paste" on any instructions. That way my fingers don't go wandering where they shouldn't. ;-)
Here are the results:

deb@deb-desktop ~ $ apt list --installed | grep grub

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

grub-common/sylvia,now 2.02~beta2-36ubuntu3.14+linuxmint1 amd64 [installed]
grub-efi-amd64/sylvia,now 2.02~beta2-36ubuntu3.14+linuxmint1 amd64 [installed,automatic]
grub-efi-amd64-bin/sylvia,now 2.02~beta2-36ubuntu3.14+linuxmint1 amd64 [installed,automatic]
grub-efi-amd64-signed/sylvia,now 1.66.14+2.02~beta2-36ubuntu3.14+linuxmint1 amd64 [installed]
grub2-common/sylvia,now 2.02~beta2-36ubuntu3.14+linuxmint1 amd64 [installed]
grub2-theme-mint/sylvia,sylvia,now 1.1.0 all [installed]


deb@deb-desktop ~ $ ls /boot/efi
EFI


deb@deb-desktop ~ $ ls /sys/firmware
acpi dmi memmap

BTW, in case I get all caught up in the euphoria of getting this system booting correctly, "Thanks"

fabien85
Level 6
Level 6
Posts: 1290
Joined: Tue Mar 11, 2014 4:30 pm

Re: Cannot write to boot sector

Post by fabien85 » Sat Dec 16, 2017 5:10 am

So Mint really tried to install grub in UEFI mode, I dont know why. Somehow you have something in /boot/efi whereas you shouldnt.
Let's see what it is and whether a partition is mounted there

Code: Select all

ls -R /boot/efi
mount | grep /boot/efi
(I have a vague suspicion that the second command will point to /dev/sda1)

To fix the problem, I would remove the UEFI grub and replace it by the version working for BIOS

Code: Select all

apt remove grub-efi-amd64
apt install grub-pc
Note that this will hand control over your grub to Mint. The other OSes will lose control over it (unless you reinstall grub there). So do this only if that's what you want.

If there is any error reported by these commands, please report them here between code tags

Punkin
Level 1
Level 1
Posts: 24
Joined: Wed Dec 13, 2017 12:17 pm

Re: Cannot write to boot sector

Post by Punkin » Sat Dec 16, 2017 9:49 am

That is exactly what I want. Now lets see if it worked.

Be back after the reboot (hopefully)

Punkin
Level 1
Level 1
Posts: 24
Joined: Wed Dec 13, 2017 12:17 pm

Re: Cannot write to boot sector

Post by Punkin » Sat Dec 16, 2017 9:53 am

Its a "Good News" "Bad News" result

The good news is I can boot back into Mint

The bad news is, that unless you are running exactly the same splash screen PCLinuxOS is, we did not update Grub.

fabien85
Level 6
Level 6
Posts: 1290
Joined: Tue Mar 11, 2014 4:30 pm

Re: Cannot write to boot sector

Post by fabien85 » Sat Dec 16, 2017 2:41 pm

I'm not sure what you mean by splash screen
What I normally understand as splash screen is the screen you get *after* grub, when the kernel is loading. It looks like this, and that doesnt depend on which grub you used to launch the kernel, or even if you used another bootloader (eg refind, (e)lilo, or directly the kernel).
Maybe you mean the background image of grub ? That can indeed be customized by the distribution.

Did you get any error when installing grub-pc ?
Please post the output of

Code: Select all

ls -R /boot/efi
mount | grep /boot/efi
if the output of the second commands indicates /dev/sda1, please tell us what this partition is supposed to be, like is it part of your PClinuxOS ?
Before proceeding further it would be good to understand what this is, it seems like a remnant of a failed UEFI install, and that could confuse the system.

Punkin
Level 1
Level 1
Posts: 24
Joined: Wed Dec 13, 2017 12:17 pm

Re: Cannot write to boot sector

Post by Punkin » Sat Dec 16, 2017 6:35 pm

I realized I should have given the printouts. Here is the result of the latest commands you sent.

ls -R /boot/efi
mount | grep /boot/efi

deb@deb-desktop ~ $ ls -R /boot/efi
/boot/efi:
EFI

/boot/efi/EFI:
ubuntu

/boot/efi/EFI/ubuntu:
fw

/boot/efi/EFI/ubuntu/fw:
deb@deb-desktop ~ $ mount | grep /boot/efi

/sda1 -- is my original PCLinuxOS install
/sda2 -- is an extended partition and is the / partition for the second install of PCLinuxOS
/sda5 -- is the install of PCLinuxOS that gave me access to Mint
/sda6 -- is the /home partition for the original PCLinuxOS
/sda7 -- is the Swap
/sda8 -- is the / partition for Mint
/sda9 -- is the /home partition for Mint
/sda10 -- is the /home partition for the second install of PCLinuxOS

As a matter of note, there was a previous installation of Mint on /sad8 & /sda9, but those partitions have been reformatted before this install of Mint

What I called the "Splash" screen was the opening screen for Grub. I realized I had probably misnamed it, but wanted to call attention to the fact that the layout and color of the screen told me I was still using the PCLinuxOS

One last thing - all installations have been "as default to the install disk." But what I see from the output above, the system thinks its booting off a Ubuntu/Mint version of Grub. Am I correct ?

fabien85
Level 6
Level 6
Posts: 1290
Joined: Tue Mar 11, 2014 4:30 pm

Re: Cannot write to boot sector

Post by fabien85 » Sun Dec 17, 2017 5:34 am

If I understand correctly, nothing is mounted on /boot/efi. That's consistent with your fstab, but well it's always better to check.
So this is just an empty series of folders that can possibly confuse the system in thinking it should install grub in UEFI mode. So it's better to get rid of it

Code: Select all

sudo rm -r /boot/efi
But what I see from the output above, the system thinks its booting off a Ubuntu/Mint version of Grub. Am I correct ?
As far as I know, once it's booted the system doesnt know anything about how it was booted. It just knows the kernel options which were passed on, but then the kernel takes full control over the machine and it shouldnt matter what happened before (exceptions being low-level hardware initializations performed correctly by the firmware/BIOS, and secure boot). In this sense it doesnt matter if Mint is launched by a grub from PClinuxOS or a grub from Mint or from another distro, or even with another bootloader (there are several others, grub is just the default one on most linux distributions).

Let's try this:
- open gparted, select the / partition of Mint, sda8, and put the boot flag on it (via Partition > Manage flags)
- from Mint, install grub manually

Code: Select all

sudo grub-install  --target=i386-pc  --boot-directory=/boot  /dev/sda
where this specifies manually that you want a Legacy/BIOS install of grub, and that the config file controlling the grub menu should be found on /boot/grub of the Mint partition

If there is any error, or the boot flag doesnt appear, please report any error message you get.

Punkin
Level 1
Level 1
Posts: 24
Joined: Wed Dec 13, 2017 12:17 pm

Re: Cannot write to boot sector

Post by Punkin » Sun Dec 17, 2017 9:12 am

I set the "Boot" flag in Gparted.

I then ran the command (via Copy and Paste) and here is the result:

deb@deb-desktop ~ $ sudo grub-install --target=i386-pc --boot-directory=/boot /dev/sda
[sudo] password for deb:
grub-install.real: error: /usr/lib/grub/i386-pc/modinfo.sh doesn't exist. Please specify --target or --directory.
deb@deb-desktop ~ $

fabien85
Level 6
Level 6
Posts: 1290
Joined: Tue Mar 11, 2014 4:30 pm

Re: Cannot write to boot sector

Post by fabien85 » Mon Dec 18, 2017 5:13 am

There seems to be a package missing, grub-pc-bin, although it should have been installed together with grub-pc when running apt install grub-pc earlier.
Check which grub packages are installed with apt list --installed | grep grub
you should have at least : grub-common, grub-pc, grub-pc-bin, grub2-common, grub2-theme-mint
If one of them is missing, install it with apt, then retry the grub-install command.

If that's not enough, use boot-repair with the default option "recommended repair".

Punkin
Level 1
Level 1
Posts: 24
Joined: Wed Dec 13, 2017 12:17 pm

Re: Cannot write to boot sector

Post by Punkin » Mon Dec 18, 2017 8:34 am

I have no problem running "boot-repair." However, before I do, take a look at the output of the "apt list -- installed | grep grub and comment. It looks like its set for an EFI install and not a legacy install. Should I proceed with "boot-repair?"


deb@deb-desktop ~ $ apt list --installed | grep grub

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

grub-common/sylvia,now 2.02~beta2-36ubuntu3.14+linuxmint1 amd64 [installed]
grub-efi-amd64/sylvia,now 2.02~beta2-36ubuntu3.14+linuxmint1 amd64 [installed,automatic]
grub-efi-amd64-bin/sylvia,now 2.02~beta2-36ubuntu3.14+linuxmint1 amd64 [installed,automatic]
grub-efi-amd64-signed/sylvia,now 1.66.14+2.02~beta2-36ubuntu3.14+linuxmint1 amd64 [installed]
grub2-common/sylvia,now 2.02~beta2-36ubuntu3.14+linuxmint1 amd64 [installed]
grub2-theme-mint/sylvia,sylvia,now 1.1.0 all [installed]

fabien85
Level 6
Level 6
Posts: 1290
Joined: Tue Mar 11, 2014 4:30 pm

Re: Cannot write to boot sector

Post by fabien85 » Mon Dec 18, 2017 10:19 am

A few posts above, I gave you a command that should have removed grub-efi-amd64 and installed grub-pc instead. Did you run it ?
If not, no wonder that grub cannot be installed in Legacy mode.

Let's be more aggressive and purge the whole grub-efi :

Code: Select all

apt purge grub-efi-amd64-bin
Report if there is any error.
If there is none, proceed to install grub-pc :

Code: Select all

apt install grub-pc
again, report if there is any error.
If there is none, make a reboot to check whether you now get to Mint's grub.

Punkin
Level 1
Level 1
Posts: 24
Joined: Wed Dec 13, 2017 12:17 pm

Re: Cannot write to boot sector

Post by Punkin » Mon Dec 18, 2017 10:59 am

Sorry for the oversight.

No error on the purge. However, the "apt install grub-pc" got to the 75% point (screen opens and tells you you are getting ready to tell it where to install Grub) and froze. The terminal is still open, and will remain so until I hear back from you.

fabien85
Level 6
Level 6
Posts: 1290
Joined: Tue Mar 11, 2014 4:30 pm

Re: Cannot write to boot sector

Post by fabien85 » Tue Dec 19, 2017 12:38 pm

I just made a try with an install with a virtualbox. I cannot get the thing to crash, no matter what I tried.
It's possible the terminal is not frozen, simply the interface is not very informative and needs to be navigated with the good keys. So I'm going to describe very preisely how to proceed below

When installing grub-pc, at first you get terminal outputs telling which packages are going to be installed, size etc and asking to confirm you want to continue [Y/N] to which you answer Y.
Then apt downloads the packages and starts to configure them, at which point you get a first screen in the terminal, blue background with a grey box titled "configuring grub-pc". There you can scroll to read the text with the down arrow, and to proceed you have to use the right arrow key to select <Ok> and press enter.
Next screen, still on blue background with the same title, you get to choose where grub should be installed. Here you should select the whole hard drive /dev/sda (normally this should be the first option). To do so, select the entry with the up and down arrow key, and press space on it, then press enter.
Then you get back to the terminal output, where you have a "Installing for i386-pc platform". It takes a while but finally you should get an "Installation finished. No error reported." then it goes to generate the grub configuration file, you will get a useless warning about GRUB_TIMEOUT, outputs about the kernels which were found etc. And finally you get back to the terminal command prompt.
There it's finished, you can close the terminal and other applications and reboot.

If for some reason the terminal is really frozen, then it's a bit bad news. Not too bad normally because grub was not yet overwritten, so you should still be able to boot. But the Mint system is then in a delicate state where no package can be touched until the situation is resolved.
To prepare in case of troubles, make sure you still have the live medium (USB or DVD) you used for install of Mint (or any other linux should work too). Then note down the instructions on this link : https://sites.google.com/site/easylinuxtipsproject/grub to be able to reinstall grub from the live medium, if needs be.
Then shutdown, reboot, see if you can get to Mint and if so, you need to retry configuring grub-pc :

Code: Select all

sudo dpkg --configure -a

Punkin
Level 1
Level 1
Posts: 24
Joined: Wed Dec 13, 2017 12:17 pm

Re: Cannot write to boot sector

Post by Punkin » Tue Dec 19, 2017 3:20 pm

I got to the second configure-pc screen, the one with this on it:

│ Running grub-install automatically is recommended in most situations, to
│ prevent the installed GRUB core image from getting out of sync with GRUB
│ modules or grub.cfg.

│ If you're unsure which drive is designated as boot drive by your BIOS,
│ it is often a good idea to install GRUB to all of them.

│ Note: it is possible to install GRUB to partition boot records as well,
│ and some appropriate partitions are offered here. However, this forces
│ GRUB to use the blocklist mechanism, which makes it less reliable, and
│ therefore is not recommended.

That is where it froze, and its still frozen 24hrs later.

So, will try the reboot. I have the repair link up on my there computer so I will not be totally clueless.

Here goes.

Punkin
Level 1
Level 1
Posts: 24
Joined: Wed Dec 13, 2017 12:17 pm

Re: Cannot write to boot sector

Post by Punkin » Tue Dec 19, 2017 3:32 pm

How do I put a big "SOLVED" on this topic ?

The terminal was not locked after all and I am up and running.

I had hit every key I could think of and got not response from the terminal. Every key but "Tab" that is. I hit the Tab key, the "Ok" lit up and we moved to the next screen. Then it took a bit to figure how to select what, but got it done and told it to install. Install went smooth as silk, except for the harmless (I hope) error messages about "kill" commands on various lines. But it picked up both PCLinuxOS installations and, most importantly, booted directly to the Mint partition with the Mint Grub in control.

Thanks for your patience and extremely clear instructions.

One last question, "In PCLinuxOS I could choose to uninstall kernel versions in Synaptic. That does not appear to be on option in Mint. What keeps the kernel from getting hoplessly bloated? "

Thanks again.

Post Reply

Return to “Installation & Boot”