help-grub
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: grub-mkconfig for removable drive


From: Goh Lip
Subject: Re: grub-mkconfig for removable drive
Date: Thu, 17 Nov 2022 16:24:58 +0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0

Another method which I prefer and chroot again is not required, is to have the usb ready for installation. For bios-legacy, a single partition in usb is needed, while for efi grub, 2 partitions in the usb are needed - one for /boot and another for /efi

So prepare usb, with /boot partition in ext2 and /efi partition in fat32 with said directories /boot and /efi.
150 MB is sufficient for /boot and 10 MB for /efi

So say sdc1 for /boot in bios-legacy and sdd1 for /efi and sdd2 for /boot



Boot into OS

1. Boot into any linux OS with grub installed, know if that is bios-legacy or efi installation.
2a. For bios-legacy,
    sudo mount /dev/sdc2 /mnt
sudo grub-install --target=i386-pc --boot-directory=/mnt/boot /dev/sdc --removable
2b. For efi
    sudo mount /dev/sdd2 /mnt
    sudo mount /dev/sdd1 /mnt/boot/efi
sudo grub-install --target=x86_64-efi --efi-directory=/mnt/boot/efi --bootloader-id=usbboot --boot-directory=/mnt/boot --removable --recheck --debug

3. Go to /boot/grub, create grub.cfg file and manually make entries for them. You can copy existing working grub.cfg to it but make sure the 'grub root' is set to the usb, not the originating 'grub root' it was copied from.
    Use this as an example or a precaution
    set root='hd0,gpt2'
search.fs_uuid 90bf7a94-3cc1-460a-ac4b-9eb7a141b59a root #(use your usb uuid, of course)#
    set prefix=($root)/boot/grub

And if you copy grub.cfg, watch out for themes, gfxterms, terminal output etc...or make your own simple one and replace all the originating non-entry parameters at the begining.
To like this

    insmod part_gpt
    insmod part_msdos

    set root='hd0,gpt2'
    search.fs_uuid 90bf7a94-3cc1-460a-ac4b-9eb7a141b59a root
    set prefix=($root)/boot/grub

    timeout_style=menu
    timeout=-1

    set gfxmode=1024x768x32
    set gfxpayload=1024x768x32

    insmod efi_gop
    insmod gfxterm
    insmod gettext

    terminal_output gfxterm
    insmod gfxmenu
    insmod png
    insmod font

    loadfont ($root)/boot/grub/fonts/unicode.pf2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]