Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1oycPT-0000IO-6h for mharc-grub-devel@gnu.org; Fri, 25 Nov 2022 12:22:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oycPQ-0000GF-BN for grub-devel@gnu.org; Fri, 25 Nov 2022 12:22:40 -0500 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oycPN-0001EF-92 for grub-devel@gnu.org; Fri, 25 Nov 2022 12:22:40 -0500 Received: by mail-wr1-x42e.google.com with SMTP id cl5so7728944wrb.9 for ; Fri, 25 Nov 2022 09:22:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akeo.ie; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=a2zTjm9vCtrNWxJxNEZThlCEHEtSKTOzi0tNjMjrzUM=; b=CcmZxSMSwpRU3Y8aNhHe2+clwSCvaywYReKu275PWJ4vIMrll6J2mn3Vg9zuCh7El/ l2DzLGXqcgpbdOqmbnEPUxrsxsCch3pbg918OaX2qUCzT2TZPZ1LngMElWf6DFtnmyYq MOzmtIRMCiw6Q06wbYPL9/83gSWJi/yc5Cmtw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=a2zTjm9vCtrNWxJxNEZThlCEHEtSKTOzi0tNjMjrzUM=; b=7mPAVK/UHCX3RNWMALftmz7gLaDkmDXFkx91Iy/LDCzgW9VbkRAAmUlWlLEwaMevlT H4lneA74vr8m1L9rPqimUQHbCAGsCM28v5EmP9D+W3qhzuj/sajWmFBqBnmrdlR+JWio 5v+5hC1ScuiVH2kg5Nlw5wvKpTqgKwYPVXFtzgrxTvQFD5POkAwL71IohDCKgw3DG17b 64uyo9fa3hIUdp2IUHD0ekFoMOjmV6f+EhjWwP1VEt0JD7VFiqtEUa/cCwnD3Pm/6JK0 0otDa7Hpz6CZQ+W6NffqpRKiEETWxhxwOJ+9mxIpTQplGeOIyusEiSVrDJRYSrMRdpQc jmYQ== X-Gm-Message-State: ANoB5pma+CJkvDZibgNTrtiGffjlqjEIBm0JfelBaKwTtkd85wWFUbNh IrMUIdZ20OpXNhsN3EmUpE7Ay7orDetJMFM4 X-Google-Smtp-Source: AA0mqf7zjTpfwVd1E3UsV7On6UKyFoOBE6Vd0m3enj2vTI/2Ep5csw8YkhYF7COo+U98zlSh384VoA== X-Received: by 2002:adf:e508:0:b0:236:588f:b5d with SMTP id j8-20020adfe508000000b00236588f0b5dmr12659545wrm.255.1669396953443; Fri, 25 Nov 2022 09:22:33 -0800 (PST) Received: from localhost.localdomain (ip-84-203-35-79.broadband.digiweb.ie. [84.203.35.79]) by smtp.gmail.com with ESMTPSA id u13-20020a5d514d000000b002365b759b65sm4166324wrt.86.2022.11.25.09.22.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Nov 2022 09:22:33 -0800 (PST) From: Pete Batard To: grub-devel@gnu.org Cc: Pete Batard Subject: [PATCH v2 0/3] Add support for EFI file system transposition Date: Fri, 25 Nov 2022 17:22:14 +0000 Message-Id: <20221125172217.936-1-pete@akeo.ie> X-Mailer: git-send-email 2.36.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=pete@akeo.ie; helo=mail-wr1-x42e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Nov 2022 17:22:40 -0000 Changes from v1: - Rebased against latest GRUB - Validated patches against coding guidelines - Clarified comments Note: If you are interested in testing this series, I have jolted down some= guidelines at: https://gist.github.com/pbatard/0deddbd71eefc35a3ed0b08e12a9e7e3 ------------------------------------------ Hello everyone, This series of patches adds file system transposition support, for UEFI boo= t media created with grub-mkrescue. File system transposition means the ability to take the content of a UEFI b= ootable media and copy it, at the file system level, to a partition that wa= s independently created and formatted by the user, while preserving the abi= lity of the media to boot in UEFI mode. We see this as a much needed improvement to GRUB since one of the core conc= ept of EFI is to do away with the requirement to have to create boot media = at the block level, one of the major pain points of BIOS systems' users. Currently, grub-mkrescue fails to meet the goal of UEFI file system transpo= sition on 3 accounts: 1. It does not include file system support for FAT or NTFS, whereas these a= re the native file systems supported by UEFI (with FAT being mandatory per = UEFI specs, and NTFS being found more and more commonly on x64 commodity ha= rdware such as, from my direct experience, about any motherboards that has = been produced by ASUS, Gigabyte or Intel in the past 10 years). 2. It uses a efi.img to embed the UEFI bootloaders, but does not keep a cop= y of these bootloaders on the ISO9660 file system itself, with the end resu= lt that, when copying the media at the file system level, the '/efi/boot/' = directory and its content is missing. 3. It relies on volume UUID to locate the boot media, a method that does no= t survive transposition when the content is copied to a newly user-created = partition. The following patches fix each one of these issues. More specifically: 1. Adding fat and ntfs support can easily be added as additional modules an= d, considering that these are file systems natively supported on commonplac= e UEFI hardware, the benefits vastly outweighs the very limited increase in= size. 2. Duplicating the 'efi.img' bootloaders onto the ISO9660 file system is al= so easily accomplished by dropping the use of a temporary directory to gene= rate the 'efi.img' and instead moving copying that content to the ISO9660 r= oot level. At this stage, we will point out that we consider it should real= ly be the job of xorriso, rather than grub-mkrescue, to accomplish this dup= lication. There again, in terms of increase in size, we see the cost/benefi= t ratio as non issue. 3. Searching for the boot media is now carried out by looking for a '/.disk= /.uuid' file rather than an actual partition UUID, as real = world usage does show that relying on specific labels or UUIDs being assign= ed to specific partitions is actually a brittle solution. We only apply the= se alterations for EFI boot, and don't modify the existing BIOS/Legacy medi= a search method. It should also be noted that the reason we chose a '.disk/= ' directory to place the UUID file is because '.disk/' has become a de-fact= o standard to place disk related content for both Debian and Ubuntu, which,= in the fragmented world of Linux distribution, is as good as a standard as= you will get. We did briefly consider using '/System/', but decided agains= t it as this latter directory is geared towards MacOS usage, and we see goi= ng with a more generic dot directory as a better approach. We have validate= d that, if the added content already contains a '.disk/' directory, then ou= r new '.disk/#####.uuid' file does get properly merged with that content. With these limited changes, grub-mkrescue can now be used to produce media = that properly survives file system transposition, thereby satisfying one of= the implicit goals of EFI of allowing end-users to carry out the creation = of bootable EFI media at the file system level exclusively. Now, because this is relevant to this patchset (it's pretty much the motiva= tion behind it), and because it is my understanding that some of the people= creating ISOHybrid boot media, especially if they are using UNIX derivativ= es as their main work environments, are not always aware of the issues that= arise from treating ISOHybrid as a glorified dd image, I will use this opp= ortunity to elaborate on issues that arise from dealing with ISOHybrid medi= a that lacks support for file system transposition. But first I should point out that these notes should not be construed as cr= iticism of ISOHybrid per se, as we very much recognise the great benefits o= f ISOHybrid and the major technical achievements that went into it. We howe= ver do see it as important to try to debunk the idea that, once you have an= ISOHybrid image that works well for both dd and optical, your job is done = and remind people who place their trust in ISOHybrid image that, for the re= asons highlighted below, having a working dd image is only half the job. And so, without further ado: * One massive real-world problem, that Linux-oriented people tend to ignore= , is that for the most widely used Operating System out there (Windows) the= "ISOHybrid =3D dd" approach is a *MASSIVE* pain point for users, on accoun= t that the resulting media is either something that Windows will not mount,= or only mount the ESP of, with the direct result that a fair amount of use= rs assume that their media was not properly created and, therefore, won't e= ven try to boot it. I genuinely cannot stress enough how this is far from b= eing a limited problem, or something that one should feel entitled to ask W= indows users to "just plow through". See for instance [1], [2], [3], [4], [= 5], [6], [7], [8], [9], [10], [11], [12] if you need some convincing, knowi= ng that I could easily add a dozen more refs, and that I didn't have to loo= k further than a couple days ago to find a recent one [4]. Thus, one of the= results of *restricting* the creation of ISOHybrid media on Windows, throu= gh the use of block copy only, is a very poor first time experience for use= rs of ISOHybrid-contained software... * Having a file system transposable UEFI media does open the door to some v= ery desirable usage, such as single media OS installation (See for instance= the installation of vanilla Debian on Pi 4 using a single media as install= er and target [13]), which can be critical for of users of SoC based system= s that do not have the luxury or resources to run to their (not-always-so-l= ocal) corner shop in order to buy another flash drive. Currently, I don't r= eally see dd-written ISOHybrid media being able to provide that kind of fea= ture whereas it is easy envision all kind of other scenarios where file sys= tem transposition can be a boon for users, such as allowing the copying of = non-free WiFi firmware blobs onto the boot media, in order to be able to pr= oceed with a networked installation... * Formatting a partition, and even repartitioning a drive, is typically a l= ot less error prone for non tech-savvy users than using a dd like utility, = in terms of preventing the erasure of the wrong disk. This is especially tr= ue on non Linux platforms where GUI tools or context menus will usually gui= de the user into selecting the appropriate target. * dd writing a GPT-based ISOHybrid media does result in a disk that has an = invalid backup GPT, on account that one never has a media that is the exact= same size as the original image, thereby resulting in garbage residing in = the last 33 sectors of the disk. Some pedantic UEFI firmwares, as well as s= ome ill-programmed OSes (e.g. Windows 7 will BSOD on this) may take objecti= on to an improper backup GPT... * As mentioned earlier, one of the established goals of EFI was to get rid = of the requirement to write any parts of a media at the block level to make= it bootable. As such, it has been quite surprising to see a lot of the pro= ponents of ISOHybrid pushing towards a complete 180 on this goal, by enforc= ing the use of block level tools. This is even more problematic as, for Win= dows users, this means installation of third-party software, which some use= rs may rightfully take objection to, in terms of not adding potential holes= into a trust chain that is critical for OS installation. * Finally, there's really no reason why GRUB (and by extension Linux) boot = media should remain inferior to Windows boot media in that respect, since W= indows installation ISOs have been supporting EFI file system transposition= for years. Thankfully, some major Linux distributions, such as Debian, Ubu= ntu and (for the most part) Arch, have grasped the importance of file syste= m transposition for their ISOHybrid media, and are making a concerted effor= t to support it. But we do feel that it should very much have been the job = of GRUB to lead the way in that respect. Regards, /Pete [1] https://old.reddit.com/r/linuxquestions/comments/j4nolf/creating_a_boot= able_usb_drive_for_linux [2] https://old.reddit.com/r/ManjaroLinux/comments/gofq71/problem_with_rufu= s_310_and_manjaro_2001 [3] https://old.reddit.com/r/ManjaroLinux/comments/gjdpi4/cannot_create_boo= table_usb_usb_size_shrinks_after [4] https://old.reddit.com/r/Proxmox/comments/v2en1r/proxmox_couldnt_find_i= so_before_launching_setup/iarz6hb/?context=3D3 [5] https://old.reddit.com/r/techsupport/comments/499b5c/usb_stick_capacity= _shrunk_to_2mb [6] https://superuser.com/questions/752874/16-gb-usb-flash-drive-capacity-d= own-to-938-mb [7] https://forums.tomshardware.com/threads/usb-flash-drive-8gb-is-now-only= -1gb.660997/ [8] https://www.eassos.com/blog/how-to-restore-usb-drive-back-to-full-capac= ity [9] https://www.easeus.com/partition-master/fix-usb-drive-incorrect-size.ht= ml [10] https://www.quora.com/After-making-my-32-GB-pen-drive-Kali-Linux-boota= ble-its-size-reduced-to-712-KB-Is-it-normal-If-not-then-how-can-I-fix-it [11] https://askubuntu.com/questions/289971/usbs-storage-capacity-reduced-t= o-2-mb-from-16-gb [12] https://askubuntu.com/questions/611325/capacity-of-pen-drive-shown-is-= less-than-the-actual [13] https://forums.raspberrypi.com/viewtopic.php?f=3D50&t=3D282839 Pete Batard (3): grub-mkrescue: Add support for FAT and NTFS on EFI boot grub-mkrescue: Preserve a copy of the EFI bootloaders on the ISO9660 file system grub-mkrescue: Search by file UUID file rather than partition UUID for EFI boot util/grub-mkrescue.c | 60 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 47 insertions(+), 13 deletions(-) --=20 2.36.0.windows.1