Can grub.cfg in CentOS iso used for loopback booting?

General support questions
Post Reply
reversiblean
Posts: 2
Joined: 2015/12/13 13:31:20

Can grub.cfg in CentOS iso used for loopback booting?

Post by reversiblean » 2015/12/13 15:21:49

Hi CentOS fora ;)
I'm trying to boot off CentOS iso from an USB drive. I've already got grub installed on my usb device.

For example I can easily boot Ubuntu/Debian based distros with the help of their loopback.cfg grub config file provided in their iso files as follows..

Code: Select all

menuentry "Ubuntu 15.04" {
	set iso_path='/iso/ubuntu-15.04-desktop-amd64.iso'
	export iso_path
	loopback loop (hd0,1)$iso_path

   # load config file
	set root=(loop)
	configfile /boot/grub/loopback.cfg
}
But I can't get `/EFI/BOOT/grub.cfg` file provided with CentOS iso to work like that. For example the menuentry bellow does not work,

Code: Select all

menuentry "[LinuxDev] CentOS" {
	set iso_path='/iso/CentOS-7-x86_64-DVD-1503-01.iso'
	export iso_path
	loopback loop (hd0,1)$iso_path
	
   # load config file
   set root=(loop)
	configfile /EFI/BOOT/grub.cfg
}
I could get it working only by using a modified `/EFI/BOOT/grub.cfg` clone (by changing inst.stage2= parameter in `/EFI/BOOT/grub.cfg`, from inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 to inst.stage2=hd:/dev/sdb1:${iso_path})

Code: Select all

search --no-floppy --set=root -l 'CentOS 7 x86_64'

# THIS WORK
menuentry 'Install CentOS 7' {
	linuxefi /images/pxeboot/vmlinuz inst.stage2=hd:/dev/sdb1:${iso_path} quiet
	initrdefi /images/pxeboot/initrd.img
}
NOTE: iso images are stored in the first partition of the usb device (/dev/sdb1) and grub is installed on (/dev/sdb2)

As you could see, using a config file (comes with the iso) make things simpler as we don't have to rewrite all the menu entries and boot parameters manually.

So I'd like to know if I can use the default `/EFI/BOOT/grub.cfg` for Loopback booting? If so how?

gerald_clark
Posts: 10642
Joined: 2005/08/05 15:19:54
Location: Northern Illinois, USA

Re: Can grub.cfg in CentOS iso used for loopback booting?

Post by gerald_clark » 2015/12/14 12:53:05

CentOS only supports a direct copy of the ISO to the RAW USB flash drive.
dd if=the_file.iso of=/dev/sdx

reversiblean
Posts: 2
Joined: 2015/12/13 13:31:20

Re: Can grub.cfg in CentOS iso used for loopback booting?

Post by reversiblean » 2015/12/15 14:05:06

gerald_clark wrote:CentOS only supports a direct copy of the ISO to the RAW USB flash drive.
dd if=the_file.iso of=/dev/sdx
I manage to boot directly from the ISO however.. Is it a bad practice?

I just wanna play with my multiboot usb. I know dd is the most recommended way, BTW.

rn.mast@zonnet.nl
Posts: 1
Joined: 2018/07/18 20:14:52

Re: Can grub.cfg in CentOS iso used for loopback booting?

Post by rn.mast@zonnet.nl » 2018/07/18 20:32:40

As I was also playing with easy2boot to get the 64 BIT EFI-Centos 7 live workstation .iso purely running from USB on a 32 BIT UEFI 64 BIT ASUS-laptop with bitlocker only temporarily shut off and the internal encrypted disk left alone,

The final grub menu that worked (without persistent storage) was a mix constructed from a working UEFI-example for Fedora, that would probably also do for a persistent option as described in http://rmprepusb.blogspot.com/2017/04/a ... o-e2b.html, as Centos is a Fedora sibling:

This is now part of my (easy2boot) PTN2:\_ISO\MAINMENU\grub2\linux_menu.grub2:

if $EFI64; then
if [ -e "$isofpath/centos.iso" ]; then
menuentry "CentOS 7 Install(FAT32-only)" --unrestricted --class centos{
set isoname=centos.iso ; CHECK_MNU_FOLDER
set root=$root2
loopback loop $isofile
probe -u (loop) --set=loopuuid
set id=UUID=$loopuuid
echo "linuxefi..."
linuxefi (loop)/isolinux/vmlinuz0 root=$id iso-scan/filename=$isofile rootfstype=auto ro rd.live.image rhgb rd.luks=0 rd.md=0 rd.dm=0 nomodeset
# boot=images
echo "initrdefi..."
initrdefi (loop)/isolinux/initrd0.img
echo "booting..."
boot
}
fi
fi

promathesh
Posts: 1
Joined: 2018/09/20 19:18:38

Re: Can grub.cfg in CentOS iso used for loopback booting?

Post by promathesh » 2018/09/20 19:34:39

As I am also trying to boot Centos 7 ISO from grub2, initially i am unable to boot centos 7 iso. after reading "rn.mast@zonnet.nl" post i am finally boot Centos 7 ISO.

In my HDD i have two partition 1st partition is 250MB fat32 and 2nd partition is EXT2. CentOS 7 Iso is stored in 2nd partition /boot/iso/CentOS-7-x86_64-DVD-1804.iso

My final grub menu is written below

menuentry 'CentOS-7-x86_64-DVD-1804' --class fedora --class gnu-linux --class gnu --class os {
insmod loopback
insmod iso9660
insmod ext2
echo "Loading CentOS-7-x86_64-DVD-1804"
set root=(hd0,msdos2)
set isofile=/boot/iso/CentOS-7-x86_64-DVD-1804.iso
loopback loop $isofile
probe -u (loop) --set=loopuuid
set id=UUID=$loopuuid
linux (loop)/images/pxeboot/vmlinuz iso-scan/filename=$isofile inst.stage2=hd:$id rootfstype=auto rw rd.live.image quiet rhgb
initrd (loop)/images/pxeboot/initrd.img
}

Post Reply