Changeset 31ef72a9 for postlfs


Ignore:
Timestamp:
08/17/2023 02:36:02 AM (10 months ago)
Author:
Xi Ruoyao <xry111@…>
Branches:
12.0, 12.1, ken/TL2024, ken/tuningfonts, lazarus, plabs/newcss, python3.11, rahul/power-profiles-daemon, renodr/vulkan-addition, trunk, xry111/llvm18
Children:
0f33c8c
Parents:
e282f70
git-author:
Xi Ruoyao <xry111@…> (08/17/2023 02:26:51 AM)
git-committer:
Xi Ruoyao <xry111@…> (08/17/2023 02:36:02 AM)
Message:

efi/grub-setup: Another update attempt

  1. Move kernel section before emergency boot disk section. The reason is in the emergency boot disk section we already need to mount the ESP, so we need VFAT and the related NLS configuration.
  2. Add "codepage=437,iocharset=iso8859-1" mounting the ESP. I'm not sure if grub-install will do things properly if a different NLS setting is used. With some (broken IMO) kernel configuration a mount command without explicit codepage and iocharset setting won't work at all. And I don't like the idea to force the users to set FAT_DEFAULT_CODEPAGE=437 or FAT_DEFAULT_IOCHARSET="iso8859-1" in kernel configuration.
  3. Use "mount --mkdir" instead of a separate "mkdir -pv" command (again).
  4. Wrap long commands at 80 characters.
  5. The ESP entry in fstab is optional. Personally I prefer it in fstab because I hate the Windoge behavior (hiding the ESP from the user).
  6. Update kernel and LFS version in example grub.cfg file (again).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • postlfs/filesystems/uefi-bootloaders/grub-setup.xml

    re282f70 r31ef72a9  
    2222      system to find out how.
    2323    </para>
    24   </sect2>
    25 
    26   <sect2>
    27     <title>Create an Emergency Boot Disk</title>
    28 
    29     <para>
    30       Ensure that an emergency boot disk is ready to <quote>rescue</quote>
    31       the system in case the system becomes un-bootable.  To make an
    32       emergency boot disk with GRUB for an EFI based system, find a spare
    33       USB flash drive and create a
    34       <systemitem class="filesystem">vfat</systemitem> file system on it.
    35       Install <xref linkend="dosfstools"/> first, then
    36       as the <systemitem class="username">root</systemitem> user:
    37     </para>
    38 
    39     <warning>
    40       <para>
    41         The following command will erase all directories and files in the
    42         partition.  Make sure your USB flash drive contains no data which
    43         will be needed, and change <userinput>sdx1</userinput> to the
    44         device node corresponding to the first partition of the USB flash
    45         drive.  Be careful not to overwrite your hard drive with a typo!
    46       </para>
    47     </warning>
    48 
    49     <screen role="nodump"><userinput>mkfs.vfat /dev/sdx1</userinput></screen>
    50 
    51     <para>
    52       Still as the <systemitem class="username">root</systemitem> user, use
    53       the <command>fdisk</command> utility to set the first partition
    54       of the USB flash drive to be an <quote>EFI system</quote> partition
    55       (change <userinput>sdx</userinput> to the device node corresponding
    56       to your USB flash drive):
    57     </para>
    58 
    59 <screen role="nodump"><userinput>fdisk /dev/sdx</userinput>
    60 <literal>
    61 Welcome to fdisk (util-linux 2.38.1).
    62 Changes will remain in memory only, until you decide to write them.
    63 Be careful before using the write command.
    64 
    65 
    66 Command (m for help): </literal><userinput>t</userinput>
    67 <literal>Partition number (1-9, default 9): </literal><userinput>1</userinput>
    68 <literal>Partition type or alias (type L to list all): </literal><userinput>uefi</userinput>
    69 <literal>Changed type of partition 'Linux filesystem' to 'EFI System'.
    70 
    71 Command (m for help): </literal><userinput>w</userinput>
    72 <literal>The partition table has been altered.
    73 Calling ioctl() to re-read partition table.
    74 Syncing disks.</literal></screen>
    75 
    76     <para>
    77       Still as the <systemitem class="username">root</systemitem> user,
    78       create a mount point for the EFI partition on the USB flash drive
    79       and mount it:
    80     </para>
    81 
    82 <screen role="nodump"><userinput>mkdir -pv /mnt/rescue &amp;&amp;
    83 mount -v -t vfat /dev/sdx1 /mnt/rescue</userinput></screen>
    84 
    85     <para>
    86       Install GRUB for EFI on the partition:
    87     </para>
    88 
    89 <screen role="nodump"><userinput>grub-install --target=x86_64-efi --removable --efi-directory=/mnt/rescue --boot-directory=/mnt/rescue</userinput></screen>
    90 
    91     <para>
    92       Unmount the partition:
    93     </para>
    94 
    95 <screen role="nodump"><userinput>umount /mnt/rescue</userinput></screen>
    96 
    97     <para>
    98       Now the USB flash drive can be used as an emergency boot disk on any x86-64
    99       UEFI platform.  It will boot the system and show the GRUB shell.  Then you
    100       can type commands to boot your operating system from the hard drive.
    101       To learn how to select the boot device, read the manual of your
    102       motherboard or laptop.
    103     </para>
    104 
    10524  </sect2>
    10625
     
    15473
    15574  <sect2>
     75    <title>Create an Emergency Boot Disk</title>
     76
     77    <para>
     78      Ensure that an emergency boot disk is ready to <quote>rescue</quote>
     79      the system in case the system becomes un-bootable.  To make an
     80      emergency boot disk with GRUB for an EFI based system, find a spare
     81      USB flash drive and create a
     82      <systemitem class="filesystem">vfat</systemitem> file system on it.
     83      Install <xref linkend="dosfstools"/> first, then
     84      as the <systemitem class="username">root</systemitem> user:
     85    </para>
     86
     87    <warning>
     88      <para>
     89        The following command will erase all directories and files in the
     90        partition.  Make sure your USB flash drive contains no data which
     91        will be needed, and change <userinput>sdx1</userinput> to the
     92        device node corresponding to the first partition of the USB flash
     93        drive.  Be careful not to overwrite your hard drive with a typo!
     94      </para>
     95    </warning>
     96
     97    <screen role="nodump"><userinput>mkfs.vfat /dev/sdx1</userinput></screen>
     98
     99    <para>
     100      Still as the <systemitem class="username">root</systemitem> user, use
     101      the <command>fdisk</command> utility to set the first partition
     102      of the USB flash drive to be an <quote>EFI system</quote> partition
     103      (change <userinput>sdx</userinput> to the device node corresponding
     104      to your USB flash drive):
     105    </para>
     106
     107<screen role="nodump"><userinput>fdisk /dev/sdx</userinput>
     108<literal>
     109Welcome to fdisk (util-linux 2.38.1).
     110Changes will remain in memory only, until you decide to write them.
     111Be careful before using the write command.
     112
     113
     114Command (m for help): </literal><userinput>t</userinput>
     115<literal>Partition number (1-9, default 9): </literal><userinput>1</userinput>
     116<literal>Partition type or alias (type L to list all): </literal><userinput>uefi</userinput>
     117<literal>Changed type of partition 'Linux filesystem' to 'EFI System'.
     118
     119Command (m for help): </literal><userinput>w</userinput>
     120<literal>The partition table has been altered.
     121Calling ioctl() to re-read partition table.
     122Syncing disks.</literal></screen>
     123
     124    <para>
     125      Still as the <systemitem class="username">root</systemitem> user,
     126      create a mount point for the EFI partition on the USB flash drive
     127      and mount it:
     128    </para>
     129
     130<screen role="nodump"><userinput>mount --mkdir -v -t vfat /dev/sdx1 -o codepage=437,iocharset=iso8859-1 \
     131      /mnt/rescue</userinput></screen>
     132
     133    <para>
     134      Install GRUB for EFI on the partition:
     135    </para>
     136
     137<screen role="nodump"><userinput>grub-install --target=x86_64-efi --removable \
     138             --efi-directory=/mnt/rescue --boot-directory=/mnt/rescue</userinput></screen>
     139
     140    <para>
     141      Unmount the partition:
     142    </para>
     143
     144<screen role="nodump"><userinput>umount /mnt/rescue</userinput></screen>
     145
     146    <para>
     147      Now the USB flash drive can be used as an emergency boot disk on any x86-64
     148      UEFI platform.  It will boot the system and show the GRUB shell.  Then you
     149      can type commands to boot your operating system from the hard drive.
     150      To learn how to select the boot device, read the manual of your
     151      motherboard or laptop.
     152    </para>
     153
     154  </sect2>
     155
     156  <sect2>
    156157    <title>Find or Create the EFI System Partition</title>
    157158
     
    198199    </para>
    199200
    200 <screen role="nodump"><userinput>mkdir -pv /boot/efi &amp;&amp;
    201 mount -v -t vfat /dev/sda1 /boot/efi</userinput></screen>
    202 
    203     <para>
    204       Add an entry for the ESP in
    205       <filename>/etc/fstab</filename>, so it will be mounted automatically
    206       during system boot:
     201<screen role="nodump"><userinput>mount --mkdir -v -t vfat /dev/sda1 -o codepage=437,iocharset=iso8859-1 \
     202      /boot/efi</userinput></screen>
     203
     204    <para>
     205      If you want to mount the ESP automatically during system boot,
     206      as the &root; user, add an entry for the ESP into
     207      <filename>/etc/fstab</filename>:
    207208    </para>
    208209
     
    444445fi
    445446
    446 menuentry "GNU/Linux, Linux 6.1.11-lfs-11.3"  {
    447   linux   /boot/vmlinuz-6.1.11-lfs-11.3 root=/dev/sda2 ro
     447menuentry "GNU/Linux, Linux 6.4.10-lfs-12.0"  {
     448  linux   /boot/vmlinuz-6.4.10-lfs-12.0 root=/dev/sda2 ro
    448449}
    449450
Note: See TracChangeset for help on using the changeset viewer.