Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1nyFwd-0003du-8H for mharc-grub-devel@gnu.org; Mon, 06 Jun 2022 12:51:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57516) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nyFwU-0003XH-Bv for grub-devel@gnu.org; Mon, 06 Jun 2022 12:51:02 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:34537) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nyFwR-0006fD-HO for grub-devel@gnu.org; Mon, 06 Jun 2022 12:51:02 -0400 Received: by mail-wr1-x431.google.com with SMTP id q26so10269990wra.1 for ; Mon, 06 Jun 2022 09:50:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akeo.ie; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=QcJ2ONJ7SQvpBMucNqgcrevwhPdb4c/Rxy1hqpjg/QM=; b=DVg9e3ft8EqQypz9L8hTBq7MbwLX2NaPRrV1TGHMQr0LKwS2YWeo3diu8r/Cf8UeYU v6ieu0qDumQXWJpArwyRUIDFbOwJwKY0K2MNx/bZwhIRJnbkjyHmQbSK0g3UdLP/FeYg cIKWAGMNZ3x4aqpc2hTgVvWrqmxKgDnxdzZUE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=QcJ2ONJ7SQvpBMucNqgcrevwhPdb4c/Rxy1hqpjg/QM=; b=Av4vw36Ytp8bnIhAFS+L4N9pJbD8wtMl5WEYmEz3EKbypcbvC0/yno5prjo9c+OL// Kj0V0shtM/iGQbEevfOzVFf6R+Xp6gTPXDXPb3V77N+YHBzdsi4+5Xxtvn0QoNwJQ+EB A8xZXqZ0iTNLRlAhoR648yWQts6DFvfdmuUd/kjv06IBdO8QXT0zMB0Lyrez9Uj25pjt mHbmFVY5WZTBJ5vsR8dFspEDCi7DKVcDX9NiIVYiecd/ML32EKrEfjPQe6BZugVDPyRe ewR0bncBeUm8EhczuD8Nq2eX5TkWICHRdt38kAdAqegUNX8zJguM/A7v3IFp+p7NJZF+ MPSA== X-Gm-Message-State: AOAM530WP9f0cL/1/yHUTnUEWer1GUmhf/ae4TbwipdeTYYbfY9TV+Rc YsbbXnGbfr7SDcEDK+cjK63EydP0BNwRHw== X-Google-Smtp-Source: ABdhPJyo4OY9eAtI7Yi1o2k7RR9bv8JXgvrzuGFdUonBd8KS4vbd4qL19KIzefzpu6F8PlCqxZuoow== X-Received: by 2002:a05:6000:1a85:b0:20f:eb36:2958 with SMTP id f5-20020a0560001a8500b0020feb362958mr22031097wry.574.1654534249389; Mon, 06 Jun 2022 09:50:49 -0700 (PDT) Received: from localhost.localdomain (ip-84-203-46-176.broadband.digiweb.ie. [84.203.46.176]) by smtp.gmail.com with ESMTPSA id i19-20020a1c5413000000b0039c457cea21sm8066068wmb.34.2022.06.06.09.50.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 09:50:48 -0700 (PDT) From: Pete Batard To: grub-devel@gnu.org Cc: scdbackup@gmx.net, Pete Batard Subject: [PATCH 0/3] Add support for EFI file system transposition Date: Mon, 6 Jun 2022 17:50:30 +0100 Message-Id: <20220606165034.811-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::431; envelope-from=pete@akeo.ie; helo=mail-wr1-x431.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, T_SCC_BODY_TEXT_LINE=-0.01 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: Mon, 06 Jun 2022 16:51:03 -0000 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 when one of the core conce= pt of EFI is to do away with the requirement to have to create boot media a= t 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 with NTFS being found more and more commonly on x64 commodi= ty hardware 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 (hence why I am CC'ing Thomas), but we don't know the technical di= fficulties that result from trying to map back the content of a FAT image b= ack onto the ISO9660 structure. There again, in terms of increase in size, = we see the cost/benefit ratio as non issue. 3. Searching for the boot media is now be carried by looking for a '/.disk/= .uuid' file rather than an actual partition UUID, as real w= orld usage does show that relying on specific labels or UUIDs being assigne= d to specific partitions is actually a brittle solution. Note that we only = carry out these alterations for EFI boot, and don't modify the existing BIO= S/Legacy media search method. It should also be noted that the reason we ch= ose a '.disk/' directory to place the UUID file is because '.disk/' has bec= ome a de-facto standard to place disk related content for Debian and Ubuntu= , which, in the fragmented world of Linux distribution, is as good as a sta= ndard as you can get. We did briefly consider using '/System/', but decided= against it as this latter directory is geared towards MacOS usage, and we = see going with a more generic dot directory as a better approach. We have v= alidated that, if the added content already contains a '.disk/' directory, = then our new '.disk/#####.uuid' file does get properly merged with that con= tent. 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 fait amount of use= rs assume that their media was not properly created and, therefore, don'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 of thi= s, knowing that I could easily add a dozen more refs, and that I didn't hav= e to look further than a couple days ago to find a recent one [4]. Thus, on= e of the results of *restricting* the creation of ISOHybrid media on Window= s, through the use of block copy only, is that this will result in many use= rs having a very poor first time experience of your ISOHybrid-contained sof= tware... * 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 to push for a complete 180 on this goal, by enforcing = the use of block level tools. This is even more problematic as, for Windows= users, this means installation of third-party software, which some users m= ay rightfully take objection to, in terms of not adding potential holes int= o 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 images have been designed to support EFI file system transposition f= or years. Thankfully, some major Linux distributions, such as Debian, Ubunt= u and (for the most part) Arch, have grasped the importance of file system = transposition for their ISOHybrid media, and are making a concerted effort = 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