grub-efi fails to install with Input/output error

Bug #1090829 reported by YannUbuntu on 2012-12-16
This bug affects 55 people
Affects Status Importance Assigned to Milestone
dosfstools (Ubuntu)
grub2 (Ubuntu)

Bug Description

HP G6 laptop with Windows 8 installed, and looking to have a dual-boot with Ubuntu 12.10

With SecureBoot enabled:
And with SecureBoot disabled:

grub-efi fails writing on the original ESP:

# grub-install --efi-directory=/boot/efi --target=x86_64-efi
mkdir: cannot create directory `/boot/efi/EFI/ubuntu': Input/output error

Remark: this is similar but not duplicate of Bug #1091477

**************** WORKAROUND1 (works):
1) Via Gparted create another EFI partition (FAT32, 200MB, located in the first 100GB of the disk), move the 'boot' flag on it
2) Install grub-efi in this new ESP (eg ).

**************** WORKAROUND2 (to be tested):
1) Backup the files in the ESP
2) Format the ESP
3) Recreate the ESP (FAT32, same size) via Gparted, place the 'boot' flag on it
4) Restore the backups into this new ESP
5) Install grub-efi in this new ESP.

YannUbuntu (yannubuntu) on 2012-12-16
summary: - grub-efi cannot install on HP's ESP
+ grub-efi cannot install on HP's original ESP (Input/output error)
YannUbuntu (yannubuntu) on 2012-12-16
summary: - grub-efi cannot install on HP's original ESP (Input/output error)
+ grub-efi cannot install on locked ESP (Input/output error)
description: updated
YannUbuntu (yannubuntu) on 2012-12-16
description: updated
Phillip Susi (psusi) wrote :

This sounds like a corrupt filesystem or bad disk. What does dmesg show?

Changed in grub2 (Ubuntu):
status: New → Incomplete
YannUbuntu (yannubuntu) on 2012-12-17
description: updated
YannUbuntu (yannubuntu) on 2012-12-18
description: updated

Using the workaround above I was able to get grub working and Ubuntu booting on my Series 9 (the one referenced above). Still having some issues with Windows8 booting, but that is probably something I did. Thanks for the help!

YannUbuntu (yannubuntu) wrote :

@Phillip: here is a similar case showing dmesg (from line 1035) and syslog (from line 2178):

YannUbuntu (yannubuntu) wrote :
Phillip Susi (psusi) wrote :

Yes, it looks like the filesystem is corrupt. Try fscking it.

YannUbuntu (yannubuntu) wrote :

@Phillip: fscking the ESP (and all other partitions) returns no warning nor error:

# fsck -fyM /dev/sda2
fsck from util-linux 2.20.1
WARNING: GPT (GUID Partition Table) detected on '/dev/sda'! The util fdisk doesn't support GPT. Use GNU Parted.

and the Input/Output error remains after the fsck.
(Full log: )

Phillip Susi (psusi) wrote :

Could someone provide an image of the filesystem for analysis?

YannUbuntu (yannubuntu) wrote :

What do you mean by "image of the filesystem" ?
a ZIP of the content of the ESP ?

Phillip Susi (psusi) wrote :

No, I mean dd the raw filesystem to an image file ( and bzip2 it ).

YannUbuntu (yannubuntu) wrote :

of the entire HDD(s) ? of the ESP only ?

Phillip Susi (psusi) wrote :

The ESP only.

YannUbuntu (yannubuntu) wrote :
YannUbuntu (yannubuntu) wrote :

the attached esp.tar.bz2 file is the "read-only" ESP (sda2) of comments #4 and #5.

For information, the user worked-around this issue by installing grub-efi in sda4 via Boot-Repair ( ).

Phillip Susi (psusi) wrote :

When I run dosfsck on that image, it reports an error, but appears unable to correct it.

As a workaround, I suggest simply reformatting the ESP.

summary: - grub-efi cannot install on locked ESP (Input/output error)
+ grub-efi cannot install on damaged filesystem (Input/output error)
YannUbuntu (yannubuntu) wrote :

New case: . See log from line 811:

@Phillip: formatting the ESP is not an option as it would destroy the Windows EFI files contained in it. Better creating a 2nd EFI partition and installing GRUB in it.

Phillip Susi (psusi) wrote :

There can only be one ESP, so rather than create a second, change the guids, then copy files over, simply reformat the first and restore the windows files.

YannUbuntu (yannubuntu) wrote :

Are you sure that the Windows EFI files will still work despite the UUID change?

Windows doesn't work now, but Ubuntu does

Sent from my iPhone

On Jan 5, 2013, at 8:39 PM, YannUbuntu <email address hidden> wrote:

> Are you sure that the Windows EFI files will still work despite the UUID
> change?
> --
> You received this bug notification because you are subscribed to a
> duplicate bug report (1094237).
> Title:
> grub-efi cannot install on damaged filesystem (Input/output error)
> Status in “dosfstools” package in Ubuntu:
> New
> Status in “grub2” package in Ubuntu:
> Incomplete
> Bug description:
> HP G6 laptop with Windows 8 installed, and looking to have a dual-boot
> with Ubuntu 12.10
> With SecureBoot enabled:
> And with SecureBoot disabled:
> grub-efi fails writing on the original ESP:
> # grub-install --efi-directory=/boot/efi --target=x86_64-efi
> mkdir: cannot create directory `/boot/efi/EFI/ubuntu': Input/output error
> Remark: this is similar but not duplicate of Bug #1091477
> **************** WORKAROUND:
> 1) via Gparted create another EFI partition (FAT32, 200MB, located in the first 100GB of the disk), move the 'boot' flag on it
> 2) make Ubuntu use this new ESP (eg via Boot-Repair).
> Example:
> *************** Computers that come with a locked ESP:
> - HP G6 laptop: see original bug description
> - Samsung Series 9 NP900X4C-A07US:
> To manage notifications about this bug go to:

No, I'm not sure, but you should at least be able to use the windows cd to repair it. Actually, I wonder if windows chkdsk can find and fix the error?

Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in dosfstools (Ubuntu):
status: New → Confirmed
YannUbuntu (yannubuntu) wrote :
summary: - grub-efi cannot install on damaged filesystem (Input/output error)
+ grub-efi fails to install with Input/output error
YannUbuntu (yannubuntu) wrote :

Same case as post #23, but with :
- dmesg (from line 811)
- syslog (from line 1765)

Phillip Susi (psusi) wrote :

In one dup of this bug the user reported that it was resolved by running chkdsk a few times in windows to repair the fs. With the attached esp image, I found that dosfsck -a detected errors but failed to repair. It seems dosfstools has a bug when it comes to saving lost chains as recovered files, and in that image, the /EFI/ubuntu directory consists of a FAT chain that contains a free cluster, which is invalid. Running dosfsck -r and saying yes a few times eventually repaired the problem.

I wonder why so many people seem to have corrupt filesystems on their ESP.

YannUbuntu (yannubuntu) wrote :

@Phillip: here is the ESP (sda1) of case #24:
The user tried several times chkdsk C: /R and chkdsk C: /F , without getting any error. This didn't solve the bug.
Hope this will help.

YannUbuntu (yannubuntu) wrote :

A new case: (Win8 + 12.10, UEFI with SecureBoot enabled)

Phillip Susi (psusi) wrote :

That image seems to have the same problem. If chkdsk doesn't find it then I guess Microsoft has a bug ( surprise surprise ). The question is, why is the ubuntu directory corrupt? I'm getting the feeling that there is a bug in the kernel.

Fred Palmer (oldfred) wrote :

Edit - found reference to the bit that is set, but need to find how to reset it. It is intended for other efi type partitions like a vendor recovery so users would not damage a vendor recovery. If HP is setting it on the efi partition it is wrong. Bug is not really related to current issue.
Quote from UEFI spec:
Partition creators may prevent UEFI firmware from examining and using a specific partition by setting bit 1 of the Partition Attributes (see 5.3.3) which will exclude the partition as a potential ESP.

Phillip Susi (psusi) wrote :

The bug you linked appears to be private and the bit unrelated to this issue. That bit would make the firmware refuse to boot the ESP. This bug report is about the ESP being corrupted thus preventing writing to it.

David Wallis (inshallah573) wrote :

I had this on a fujitsu Lifebook AH512 running windows 8. (
Still unresolved. I can boot straight to ubuntu with no bootloader, but running windows breaks it.

Phillip Susi (psusi) wrote :

I don't understand what you mean by "I can boot straight to ubuntu with no bootloader, but running windows breaks it.", could you elaborate?

Also have you run chkdsk on the esp from windows?

antoine_h (ahgnn) wrote :

I had the problem to with an HP Pavilion g7-2242sf.

I solved it with trials and error, and inspecting what was going on in the files, etc...
At the end, I roughly did the same as the work around you provide.
see :

May be these elements may help :

When starting the machine, I click ESC to have the boot options, then F9 to go to "Boot Device Options".
There, you get : "Boot Menu Option", with several ways to start :
 - OS boot Manager
 - Ubuntu (TOSHIBA MQ.... the disk refence...)
 - Boot from EFI file...
 - Notebook Hard Drive
 - Internal CD/DVD ROM Drive

When going to the "Boot from EFI file..." option, you get a screen, with capability to navigate in the EFI partition (a File Explorer), and select the folders and files (efi files).
It is a kind of Dos File Explorer, navigation in the folder (like in the old days...).
There, when you go to the EFI folder (root folder), then you find the folders for "boot", for "Windows", for "HP" (recovery) etc.... and the one for "Ubuntu".
In the Ubuntu folder, you find the grubx64.efi file.

Before the workaroud (and strugglin), when selecting this file (select highlight in the list, and click Enter), then I was getting the same "navigation screen", but with nothing proposed in it.
As if I was entering a sub folder, but there is nothing in it, not even the "." and ".." lines of the usual minimum directory listing.
The file is corrupted, and the selection+ENTER does not trigger the launching, it only propose a corrupted navigation, so a kind of Folder presentation, but with really nothing in it.
The only way to get out is shut down the pc.

After the workaroud and with a proper grubx64.efi, when selecting the file and clicking Enter, the Grub start, and propose the list of OS to choose for booting.
Normal behavior.

IMHO : I don't think that the whole partition is corrupted, or read only.
I think that only the grubx64.efi file is corrupted.
I think that something goes wrong when Ubuntu do the installation, ... and then the grubx64.efi file is left "as is", ... even if the installation process continues and says it is ok.

why :
if the the whole partition is corrupted : the computer should not be able to start with the Windows 8 boot.
if the whole partition is read only : then the process of installation of Ubuntu should not be able to create the grubx64.efi file (not even an empty file with 0 octet).

The file was written, ... but it cannot be used properly by the EFI process because it is incompleted or corrupted.

Why the grubx64.efi file is not correctly set ?
I don't know.
I did the process of installation of Ubuntu twice (may be 3 times) : each time, the same result.
But I did not notice anything usefull when Ubuntu was installing.

YannUbuntu (yannubuntu) wrote :

Thanks Antoine.

In all the previous logs, we can see that:
- an /efi/ubuntu is created
- but there is no grubx64.efi file in it.

eg line 4191 of the log of Comment #31 above ( ).

So I am surprised when Antoine says he could see the /ubuntu/grubx64.efi file when browsing from the UEFI firmware... can anybody else with the bug can also see the file?

Phillip Susi (psusi) on 2013-02-27
description: updated
description: updated
YannUbuntu (yannubuntu) on 2013-02-27
description: updated
Stephan Frank (sfrank) wrote :

I would like to comment that I had the same problem on an Fujitsu Lifebook T902; Win8 was not detecting any errors on the ESP file system but after running dosfschk I was finally able to install 12.10.

Ubfan (ubfan1) wrote :

How I corrupted the ubuntu directory:
On a Toshiba Satellite S855 with Windows 8 preinstalled and Secure boot enabled, successfully installed 12.10 64b to a 4G stick, without making a efi partition on it. This created a good EFI/ubuntu directory on the hard disk, but left the EFI/Boot directory containing ony a grub.cfg file to boot the stick (so Windows would no longer boot), (although the 4G stick would boot).
  In this condition, I then installed 12.10 to a previously freed up space on the hard disk, which failed at the bootloader part, but
did end up in a condition which Windows booted. Tried again to install to the 4G stick, this time with an efi partition on the stick, which failed with the "grub-install dummy" error. Looking at the EFI with ls -l, the ubuntu directory just showed a name the "d" for directory, and all else appeared as "?"s. Apparently, the second (or maybe third) install of Ubuntu corrupted the ubuntu directory in the Windows EFI directory,. Examining the failed stick, the /etc/fstab file refers to the hard disk's EFI partition (by UUID), not the one on the stick (which was empty).

YannUbuntu (yannubuntu) wrote :

@Ubfan: please create a new bug report for your issue.

Ubfan (ubfan1) wrote :

@yannbuntu: My issue is the same as yours: the underlying bad EFI/ubuntu directory.

I think I can narrow the cause to grub-efi itself:
 1) I have never booted the pc with Secure boot disabled.
 2) I have never run any third party tools like your boot-repair.
 3) I have never added, changed or renamed anything in the EFI partition.
 4) First installation of 12.10 did produce a normal ubuntu directory,
which allowed the installation (but not Windows) to run.
 5) Second and third attempts at installation failed at the grub part.

And yes, after the ubuntu directory is corrupted, grub-efi will complain about it, along with virtually every other tool attempting to access it.

Repeated runs of dosfsck -r did eventually fix the corruption, by deleting the ubuntu directory.

YannUbuntu (yannubuntu) wrote :

Hi Ubfan,
We don't know if your issue is the current bug (Input/Output error), or Bug #1091477 ("Read-Only" error), or else, because you didn't mention the output of "grub-install --efi-directory=/boot/efi --target=x86_64-efi".

Ubfan (ubfan1) wrote :

I see lots of Input/Output errors when accessing the EFI/ubuntu directory, and see a (bogus?) read only filesystem message in dmesg:
dmesg lines (probably caused by the ls command):
FAT-fs (sda2); error, fat_get_cluster: invalid cluster chain (i_pos 0)
FAT-fs (sda2): Filesystem has been set read only

But the mount command still lists the sda2 mount as rw.

The Input/Output error appears with any attempted access to the directory:
ls ubuntu, sudo mv ubuntu ..., sudo rm -rf ubuntu all produce the Input/Output error.
I forget the error message from the third installation attempt, but it was a failure
I expected and might have been the IO error (it was NOT the error window produced from
the second installation attempt which apparently caused the corrupted directory).

The error window on the second installation (to hard disk) was:
Window title: Unable to install Grub in a dummy
Text: Executing 'grub-install dummy' failed
      This is a fatal error.

Since I fixed the bad directory, and I'm not really working on my own UEFI machine, I'll hold off on doing anything more, like running the grub-install. I hope this helps in improving things.

A guess as to what's wrong:
Looks like an "off-by-one" error on a loop index in grub install when it encounters an existing EFI/ubuntu directory. The directory is probably rewritten with an extra (free) block added at the start. The dosfsck reports such in the below terminal capture. Confirm this by looking at the filesystem image posted above.

The fix to get rid of the corrupted directory (since rm won't work) applying Phillip's (comment #25) suggestion:
$ sudo mount -tvfat /dev/sda2 /mnt/sda2
ubuntu@ubuntu:/mnt/sda7/etc$ ls !$
ls /mnt/sda2

ubuntu@ubuntu:/mnt/sda7/etc$ sudo dosfsck -r /dev/sda2
dosfsck 3.0.13, 30 Jun 2012, FAT32, LFN
  Contains a free cluster (12149). Assuming EOF.
Reclaimed 277 unused clusters (1134592 bytes).
Perform changes ? (y/n) y
/dev/sda2: 326 files, 12146/65536 clusters

ubuntu@ubuntu:/mnt/sda7/etc$ sudo dosfsck -r /dev/sda2
dosfsck 3.0.13, 30 Jun 2012, FAT32, LFN
 Start does point to root directory. Deleting dir.
Reclaimed 276 unused clusters (1130496 bytes).
Perform changes ? (y/n) y
/dev/sda2: 326 files, 12146/65536 clusters

ubuntu@ubuntu:/mnt/sda7/etc$ sudo dosfsck -r /dev/sda2
dosfsck 3.0.13, 30 Jun 2012, FAT32, LFN
Orphaned long file name part "ubuntu"
1: Delete.
2: Leave it.
? 1
Perform changes ? (y/n) y
/dev/sda2: 325 files, 12146/65536 clusters

ubuntu@ubuntu:/mnt/sda7/etc$ sudo dosfsck -r /dev/sda2
dosfsck 3.0.13, 30 Jun 2012, FAT32, LFN
/dev/sda2: 325 files, 12146/65536 clusters

ubuntu@ubuntu:/mnt/sda7/etc$ ls /mnt/sda2/EFI
Boot Microsoft toshiba

YannUbuntu (yannubuntu) wrote :

Thanks Ubfan.
If possible, please could you attach your /var/log/installer/syslog and /var/log/installer/partman files ?

@yannubuntu: Sorry, bug 1159016 had me running non-persistent on my live
media. At the time I didn't remember to capture any log files on another

Ubfan (ubfan1) wrote :

@yannubuntu re: #34: Yes, I too see the efi firmware path ubuntu/grubx64.efi when it should be ...shim.efi . Looks like grub-install defaulted to that when the path test for shim failed. I haven't done much except get rid of the usb boot for Ubuntu -- I was surprised the F12/select HDD/select ubuntu worked for booting Ubuntu, since secure boot rejects grubx64.efi, but it turned out the grubx64 silently failed, then the fallback was to try EFI/Boot/bootx64.efi, which was a copy of shim (and grubx64 was present in Boot also), so it worked. If you think a copy of my efivars would help, I could post them.

Roderick Smith (rodsmith) wrote :

I'm speculating, but I suspect that this problem may have to do with the Windows "fast startup" feature. This feature essentially turns the "shutdown" option in Windows into something more akin to a suspend-to-disk operation. As such, any filesystems that are mounted at the time of "shutdown" (perhaps including the ESP) will be left in an inconsistent state. If they're then accessed from another OS (such as Linux), the result could be disk corruption, which could then be worsened when Windows is booted again. (Windows might write back the disk state from before Linux wrote files to the ESP, causing those files to disappear or be corrupted.) This can quickly turn into a real mess.

I'd like to emphasize that this is speculative; I haven't run any controlled tests to see how this feature affects the ESP. The symptoms reported seem consistent with what I'd expect, though, with the possible exception of I/O errors. (Those might occur if filesystem data structures were left pointing outside of the partition, but that seems odd.)

If this hypothesis is correct, the solution is to disable the "fast startup" feature -- preferably BEFORE installing Linux. Various Web pages describe how to do this; for instance:

Ideally, the Ubuntu installer should attempt to detect this condition and refuse to install until the feature is disabled in Windows, since failure to disable "fast startup" will almost certainly lead to problems.

Ubfan (ubfan1) wrote :

Boot Speed = Normal as the default on the Toshiba S55 5378. Bios InsyderH2o Ver 3.7. Firmware 6.6, EC ver 6.10
I never changed the Boot Speed from it "normal" selection.

Phillip Susi (psusi) wrote :

This is a Windows option, not a bios one, and that does sound like a plausible explanation.

Ubfan (ubfan1) wrote :

Well, since "Boot Speed = normal" appeared in my UEFI/BIOS settings, I assumed it was a ...BIOS setting, but maybe there is another Windows setting I should track down. The corruption just happened once though.

Ubfan (ubfan1) wrote :

The Windows setting on this Toshiba S855 is a checkbox labeled "Fast Startup", and it is not checked by default, and is not even active until another link for additional settings is clicked. Definitely not the cause my situation. Not to say that others may have only disabled one of multiple places necessary to prevent unwanted Windows boot behavior. Or maybe there's yet another place for me to disable it ; 0.

YannUbuntu (yannubuntu) wrote :

Here is another case where running dosfsck -a on the "Input/Output error" ESP failed (see line 1015 to 1021):

dosfsck -a /dev/sda2
Unable to create unique name
dosfsck 3.0.14, 23 Jan 2023, FAT32, LFN
There are differences between boot sector and its backup.
Differences: (offset:original/backup)
5:44/57, 6:4f/49, 7:53/4e, 8:35/34, 10:30/31, 14:fe/28, 15:1b/00, 36:01/08
Not automatically fixing this.

Eric (paralis) wrote :

Same bug here on Asus N550JV. Tried to use Boot-repair. Had the same 'Locked-ESP detected' message.

My post on Ubuntu forum:
More info:

Pressing ESC at start, I can see ubuntu (which was automatically added to that menu with no intervention from me whatsoever). Trying to boot it: black screen then it boots up W8.

YannUbuntu (yannubuntu) wrote :

@Eric: your log shows that you had a "Read-Only" error, so you were affected not by Bug #1090829 but more likely by Bug #1091477 .

zEn (der-eremit) wrote :

for me boot-repair could also continue following the dosfsck tipp from comment #40

alea (olivier-garet-p) wrote :

Suddenly, my Asus (dual boot Win/Linux Mint Petra 16) did'nt boot.
I repaired it with boot-repair on a Ubuntu disk, together with the dosfsck tipp from comment #40.

To post a comment you must log in.