The problem I had installing 24.04LTS from a USB onto a new M.2 on a Dell XPS13 9365 was that the instllation would not complete. A small screen would appear telling me to reboot. I tried, but system would not reboot.
Bios settings were UEFI enabled, Secure Boot disabled. I found the advice below essential to completing my installation:
How can I repair grub? (How to get Ubuntu back after installing Windows?)
I loaded the "Try Ubuntu" installation from the USB, used Fsdisk -l to discover that the M.2 now had a system instllation on partition 2 and an EFI installation on partition 1. I mounted the system partition (p2) on /mnt on the demo 24.04, then mounted the EFIS parition (p1) on /mnt/boot/efi. Next I did a chroot /mnt which made me root on the new installation. Based on advice on reference above, I did a grub-install to system partiion 2 which worked and an update-grub which qiuckly found the kernels I'd just installed but then hung-up running os-prober. I let it run for 10 minutes, then gave up. I thought I could control-c out of this and all would work, but that was wrong. It appears that if os-prober doesn't complete, the new grub will not be installed.
Solution is to do all the above, but before doing update-grub, go to /etc/grub.d on your mounted system partition and mv 30_os-prober to .30_os-prober. That's a "." before the 30.
Now update-grub will not run os-prober, the new grub file will be installed and you can now boot the new system.
It may be that os-prober looks at the bios and that mine wasn't clean enough. It still had a reference to Windows in it, but there was now no windows on the system.