Received: from list by lists.gnu.org with archive (Exim 4.71) id 1cQZwP-0000fa-W6 for mharc-grub-devel@gnu.org; Mon, 09 Jan 2017 08:24:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57080) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cQZwN-0000dn-H2 for grub-devel@gnu.org; Mon, 09 Jan 2017 08:24:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cQZwK-00051O-Am for grub-devel@gnu.org; Mon, 09 Jan 2017 08:24:47 -0500 Received: from a.mx.secunet.com ([62.96.220.36]:37192) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cQZwK-0004zC-2w for grub-devel@gnu.org; Mon, 09 Jan 2017 08:24:44 -0500 Received: from localhost (localhost [127.0.0.1]) by a.mx.secunet.com (Postfix) with ESMTP id 99CD720096; Mon, 9 Jan 2017 14:24:36 +0100 (CET) X-Virus-Scanned: by secunet Received: from a.mx.secunet.com ([127.0.0.1]) by localhost (a.mx.secunet.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1KrrzXEtZ_vl; Mon, 9 Jan 2017 14:24:36 +0100 (CET) Received: from mail-essen-01.secunet.de (204.40.53.10.in-addr.arpa [10.53.40.204]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a.mx.secunet.com (Postfix) with ESMTPS id 0B4D820068; Mon, 9 Jan 2017 14:24:36 +0100 (CET) Received: from [10.182.7.39] (10.182.7.39) by mail-essen-01.secunet.de (10.53.40.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 9 Jan 2017 14:24:35 +0100 From: Dennis Wassenberg Organization: secunet Security Networks To: , Subject: Got error error message after removing unused removeable device Message-ID: Date: Mon, 9 Jan 2017 14:21:15 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Originating-IP: [10.182.7.39] X-G-Data-MailSecurity-for-Exchange-State: 0 X-G-Data-MailSecurity-for-Exchange-Error: 0 X-G-Data-MailSecurity-for-Exchange-Sender: 23 X-G-Data-MailSecurity-for-Exchange-Server: d65e63f7-5c15-413f-8f63-c0d707471c93 X-EXCLAIMER-MD-CONFIG: 2c86f778-e09b-4440-8b15-867914633a10 X-G-Data-MailSecurity-for-Exchange-Guid: 74E3393B-8C25-4BD3-A036-282153DEE867 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 62.96.220.36 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Jan 2017 13:24:48 -0000 Hi all, I run into a grub2 issue. I have a system with EFI boot enabled and grub2 (grub-2.02-beta2) is stor= ed at my ssd. At the ssd there is a LVM installed. The EFI firmware is co= nfigured to boot at first from internal ssd and after that try a usb hdd.= In the following cases I got this error message: "error: failure reading= sector 0x0 from hd0". Case 1: SD card reader is plugged into a usb port Case 2: An USB Multifunction printers is plugged into a usb port Case 3: I had an usb flash drive installed at boot. If I enter grub2 is u= nplug this usb flash drive (not necessary for booting) and select the men= u-entry to boot. This error is shown 10 seconds and after that the system continues bootin= g without any issues. I made some debugging by myself and found that this error comes from efid= isk.c:grub_efidisk_read because grub_efidisk_readwrite returns with GRUB_= EFI_NOT_FOUND (case 3) in case of searching the LVM partitions at diskfil= ter.c. I saw there was an improvement that if grub_efidisk_readwrite retu= rns with GRUB_EFI_NO_MEDIA this error is filtered out (introduced at grub= -2.02-beta3). Would it be possible to add GRUB_EFI_NOT_FOUND at the filte= red out error codes such that this error will not occur any more? This wi= ll prevent the error message if a removeable device was removed. A patch for this would look like this: From: Dennis Wassenberg Date: Mon, 9 Jan 2017 13:32:17 +0100 Subject: [PATCH] efidisk: prevent errors from diskfilter scan of removed removable drives Map EFI_NOT_FOUND to GRUB_ERR_OUT_OF_RANGE that is ignored by diskfilter. This affects only internally initiated scans. If read/write from removabl= e is explicitly requested, we still return an error and text explanation is mo= re clear for user than generic error. --- grub-core/disk/efi/efidisk.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c index 3b79f7b..db93d3a 100644 --- a/grub-core/disk/efi/efidisk.c +++ b/grub-core/disk/efi/efidisk.c @@ -583,6 +583,8 @@ grub_efidisk_read (struct grub_disk *disk, grub_disk_= addr_t sector, =20 if (status =3D=3D GRUB_EFI_NO_MEDIA) return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("no media in `%s'"), di= sk->name); + else if (status =3D=3D GRUB_EFI_NOT_FOUND) + return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("`%s' not available"), = disk->name); else if (status !=3D GRUB_EFI_SUCCESS) return grub_error (GRUB_ERR_READ_ERROR, N_("failure reading sector 0x%llx from `%s'"), @@ -606,6 +608,8 @@ grub_efidisk_write (struct grub_disk *disk, grub_disk= _addr_t sector, =20 if (status =3D=3D GRUB_EFI_NO_MEDIA) return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("no media in `%s'"), di= sk->name); + else if (status =3D=3D GRUB_EFI_NOT_FOUND) + return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("`%s' not available"), = disk->name); else if (status !=3D GRUB_EFI_SUCCESS) return grub_error (GRUB_ERR_WRITE_ERROR, N_("failure writing sector 0x%llx to `%s'"),