0

I have a dual boot UEFI system with Windows 11 on one SSD and Ubuntu Desktop 24.04 LTS on another. I use the grub menu to select which OS to boot. I've studied several web postings describing the steps for adding a bootable iso to the grub menu. They all involve launching Linux distros by adding commands to the /etc/grub.d/40_custom file. Here's one such posting:

https://www.linuxbabe.com/desktop-linux/boot-from-iso-files-using-grub2-boot-loader

I'm trying to figure out how to adapt the procedure to the 2024 Sergei Strelec WinPE utility iso. The iso currently resides in my "Home" folder. I don't know the proper lines to add to the /etc/grub.d/40_custom to pull this off. In fact, my Ubuntu does not even have the 40_custom file to edit. Any guidance would be appreciated. I'm a linux beginner. Thanks.

Here's the iso I'm trying to launch:

https://www.majorgeeks.com/files/details/sergei_strelecs_winpe.html

...an extremely useful tool.

3 Answers3

1

Since the application information says that it is a Windows ISO

You can try to boot the contents of the ISO as if it were Windows.

To do this you need to:

Create an NTFS partition and extract all the contents of the ISO to it.

Then create or modify the file /etc/grub.d/40_custom, from the Ubuntu installation that installed Grub.

In this file you must add:

We assume that the original operating systems are in a GPT partition with UEFI boot

menuentry "Sergei Strelec WinPE " {
set root=(hd0,6)
insmod part_gpt
insmod ntfs
insmod chain
chainloader /efi/boot/bootx64.efi
}

In set root=(hd0,6) you must correctly indicate the disk hd0 or hd1 and the correct partition number where the iso was unzipped.

Once the file has been saved, you must run

sudo update-grub

So that the change is made in the Grub menu

kyodake
  • 17,808
0

How To Add Grub Entries Ubuntu 24.04
In Ubuntu 24.04, Grub2 is the default bootloader.

To add custom entries, you’ll need to modify the /etc/default/grub file and the scripts in the /etc/grub.d/ directory.

Here’s a step-by-step guide:

Backup important files:

Before making changes, backup /etc/default/grub and /etc/grub.d/* files using sudo cp /etc/default/grub /etc/grub.d/* /path/to/backup/directory.

Edit /etc/default/grub:
Open the file with a text editor (e.g., sudo nano /etc/default/grub) and add the following lines at the end:

GRUB_CUSTOM_MENUENTRY="Your Custom Menu Entry"
GRUB_DEFAULT="0"  # Set the default entry to the new custom one

Replace “Your Custom Menu Entry” with the desired name and description for your custom entry.

Create a new script in /etc/grub.d/: Create a new file (e.g., sudo nano /etc/grub.d/40_custom) and add the following contents:

#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
menuentry "Your Custom Menu Entry" {
    insmod part_msdos
    insmod ext2
    set root='hd0,msdos1'
    linux /boot/vmlinuz-6.8.0-41-generic root=/dev/sda1 ro
    initrd /boot/initrd.img-6.8.0-41-generic
}

Replace the kernel and initrd versions with the ones you want to use.

Adjust the set root line to match your partition layout.

Make the script executable: Run sudo chmod +x /etc/grub.d/40_custom to make the script executable.

Update Grub configuration: Run sudo update-grub to rebuild the Grub configuration file (/boot/grub/grub.cfg).

Verify the custom entry: Reboot your system and check the Grub menu to ensure your custom entry is present and functional.

Remember to be cautious when editing system files, and make sure to backup important files before making changes. If you encounter issues, you can restore the original files from your backup directory.

0

Okay all, I got it working. Kyodake put me on the right trail. I created a small fat32 partition on one of my SSD's and set the flags to:

boot, esp, no_automount

I copied the contents of the Sergei Strelec WinPE iso to the new partition. GParted indicated the partition as /dev/sda4...which I interpretted as "hd0 gpt4"...but that's apparently wrong. Here's the code I used in the /etc/grub.d/40_custom file:

!/bin/sh

exec tail -n +3 $0

menuentry "Sergei Strelec WinPE " {

    insmod part_gpt
insmod fat

set root='hd1,gpt4'

chainloader /efi/boot/bootx64.efi

}

And, BOOM, the entry booted up "slick as a whistle". Thanks for all of your input. If anyone can help me understand the hard drive number discrepancy, I'd appreciate it. It's strange because my Windows 11 is on that same hard drive, and Grub Customizer shows scripting for it that points to hd0,gpt1. Strange. Happy New Year.

ADDENDUM. A storage drive that I had attached to the system was some how causing a discrepancy with disk numbering at boot up. So although Ubuntu showed the target for my Sergei Strelec to be hd0 gpt4, I had to substitute hd1 gpt4 to make it work. With the storage drive removed, I can use hd0 gpt4. What makes this really confusing is that my Windows 11 booting from hd0 gpt1 isn't affected by the presence of the storage drive in the system. My Ubuntu boot up is also not affected. It would be nice if I could solve this last remaining issue so that I can add or remove the storage drive without breaking my boot menu.

ADDENDUM 2. This method also works using an NTFS partition and no special flags.