You are not logged in.

#1 2016-05-06 00:08:24

pepemopap
Member
Registered: 2015-09-30
Posts: 49

Grub2 Chainloader to partition

Hi! Iam researching whith Grub2 and chaindloader to a some OS (bunsenlabs, Windows Rescue CD, Konboot, etc).
I would like to have some partitions in a USB with each one.

When i do:

dd if=bl.iso of=/dev/sdb 

I can do in Grub2 a chainloader to sdb and run the Linux live.

set root(hd0)
chainload +1

When I do the same but using a partition identifier as output (instead a disk id):

dd if=bl.iso of=/dev/sdb1 

I cant find a way to run the live using chainloader in Grub.

set root(hd0,msdos1)
chainload +1

I know there are others easy ways to run a liveUSB, but I dont understand why if Grub chainload to the same data location doesnt work.

Offline

#2 2016-05-06 06:28:20

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 9,069
Website

Re: Grub2 Chainloader to partition

pepemopap wrote:
dd if=bl.iso of=/dev/sdb1

That won't work because the BL ISO image has it's own partition table:

empty@alpine ~ % fdisk -l Desktop/bl-Hydrogen-amd64.iso 
Disk Desktop/bl-Hydrogen-amd64.iso: 836 MiB, 876609536 bytes, 1712128 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x3dacb69b

Device                         Boot Start     End Sectors  Size Id Type
Desktop/bl-Hydrogen-amd64.iso1 *       64 1712127 1712064  836M 17 Hidden HPFS/NTFS

For a multiboot live USB device, see https://wiki.archlinux.org/index.php/Mu … _USB_drive

Offline

#3 2016-05-06 09:06:48

pepemopap
Member
Registered: 2015-09-30
Posts: 49

Re: Grub2 Chainloader to partition

Thanks for your response.

That won't work because the BL ISO image has it's own partition table:

Curiously Linux can mount sdb1 despite the partation start with a MBR and partition table.
I have tried to do a dd skipping the first 64 sectors (64*512 bytes) to sdb1 but grub chainloader dosent work.

For a multiboot live USB device, see https://wiki.archlinux.org/index.php/Mu … _USB_drive

Grub2 loopback is really amazing, but only works in Linux isos.
Im doing a multiboot usb installing in the MBR SuperGrub2Disk (SGD). SGD recognizes all OS in the computer, very usefull, and recognizes the live systems installed in the USB too for multiboot.
Im doing it only for fan. I know there are specifc tools, but I prefer do it manually for learn.

Grub2 iso loopback works perfect for BL, Ubuntu, Clonezilla, Kali, etc.
But I would like boot to others systems, like KonBoot, Windows recovery disk...

Seems Grub4dos can do it with some similar that:

title Kon-Boot
map --mem /FD0-konboot-v1.1-2in1.img (fd0)
map (hd1) (hd0)
map (hd0) (hd1)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)

But i cant do the same work in Grub2.

Thanks.

Last edited by pepemopap (2016-05-09 09:12:12)

Offline

#4 2016-05-07 04:16:58

Horizon_Brave
Operating System: Linux-Nettrix
Registered: 2015-10-18
Posts: 1,473

Re: Grub2 Chainloader to partition

Hey pepemopap, Here:

I cant find a way to run the live using chainloader in Grub.

set root(hd0,msdos1)
chainload +1

Why do you specifiy the partition as msdos1  instead of 1 or 2  etc..?


"I have not failed, I have found 10,000 ways that will not work" -Edison

Offline

#5 2016-05-07 10:30:12

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 9,069
Website

Re: Grub2 Chainloader to partition

@OP: Have you seen http://www.gooplusplus.com/multiboot-collections/?

They were put together by a #! community member.

Offline

#6 2016-05-07 16:51:58

pepemopap
Member
Registered: 2015-09-30
Posts: 49

Re: Grub2 Chainloader to partition

Horizon_Brave wrote:

Hey pepemopap, Here:

I cant find a way to run the live using chainloader in Grub.

set root(hd0,msdos1)
chainload +1

Why do you specifiy the partition as msdos1  instead of 1 or 2  etc..?

Because in Grub CLI mode, when i press <tab> grub complete with this nomenclature. But (hd0,2) works too.

Offline

#7 2016-05-08 01:38:14

pepemopap
Member
Registered: 2015-09-30
Posts: 49

Re: Grub2 Chainloader to partition

Head_on_a_Stick wrote:

@OP: Have you seen http://www.gooplusplus.com/multiboot-collections/?

They were put together by a #! community member.

Very interesting linkg, thanks. There are a lot of ideas for include in a multiboot usb.

Offline

#8 2016-05-08 12:05:01

pepemopap
Member
Registered: 2015-09-30
Posts: 49

Re: Grub2 Chainloader to partition

Ok, I desist. I believe there arent a way to chainload a iso or img directly from Grub2, only using loopback (for Linux kernels that can receive the param for loopback the iso). If so, it is disappointing.

The solution Ive found is call GRUB4DOS (grub.exe) from GRUB2, and let G4D do the job.
These are some samples i have tested in my grub.cfg file, maybe help someone:

#############################################################################
#### LINUX LOOPBACK
#############################################################################
menuentry "########### LINUX LOOPBACK #######################################" {
  true
}

menuentry "BunsenLabs: bl-Hydrogen-amd64.iso" {
	set isofile="/boot-isos/bl-Hydrogen-amd64.iso"
	loopback loop (hd0,2)$isofile
	linux (loop)/live/vmlinuz boot=live findiso=$isofile noeject
	initrd (loop)/live/initrd.img
}

menuentry "Clonezilla: clonezilla-live-2.4.5-23-amd64.iso" {
	set isofile="/boot-isos/clonezilla-live-2.4.5-23-amd64.iso"
        loopback loop (hd0,2)$isofile
	linux (loop)/live/vmlinuz boot=live union=overlay username=user config components quiet noswap nolocales edd=on nomodeset nodmraid ocs_live_run=\"ocs-live-general\" ocs_live_extra_param=\"\" keyboard-layouts= ocs_live_batch=\"no\" locales= vga=788 ip=frommedia nosplash toram=filesystem.squashfs findiso=$isofile
	initrd (loop)/live/initrd.img
}

menuentry "Parted Magic: pmagic_2016_01_06.iso" {
	set isofile="/boot-isos/pmagic_2016_01_06.iso"
	loopback loop (hd0,2)$isofile
	linux (loop)/pmagic/bzImage64 iso_filename=$isofile
 	initrd (loop)/pmagic/initrd.img (loop)/pmagic/fu.img (loop)/pmagic/m64.img
}

menuentry "MiniTool Partition Wizard: pwfree91-x64.iso" {
	set isofile="/boot-isos/pwfree91-x64.iso"
	loopback loop (hd0,2)$isofile
	linux (loop)/casper/vmlinuz.efi boot=casper iso-scan/filename=$isofile ramdisk_size=409600 root=/dev/ram0 rw	
 	initrd (loop)/casper/tinycore.gz
}
#############################################################################
#### GRUB4DOS
#############################################################################
menuentry "########### GRUB4DOS #############################################" {
  true
}

menuentry "GRUB4DOS" {
	linux16 (hd0,2)/boot/grub/grub.exe 
}

menuentry "Konboot-2.4" {
	set isofile="/boot-isos/konboot-2.4.img"
	menulst="find --set-root $isofile; map --mem $isofile (fd0); map (hd1) (hd0); map (hd0) (hd1); map --hook; chainloader (fd0)+1; rootnoverify (fd0)"
	linux16 (hd0,2)/boot/grub/grub.exe --config-file=$menulst
}

menuentry "SpinRite v6: spinrite6.img" {
	set isofile="/boot-isos/spinrite6.img"
	menulst="find --set-root $isofile; map --mem $isofile (fd0); map (hd1) (hd0); map (hd0) (hd1); map --hook; chainloader (fd0)+1; rootnoverify (fd0)"
	linux16 (hd0,2)/boot/grub/grub.exe --config-file=$menulst
}

menuentry "Ultimate Boot CD: ubcd535.iso" {
	set isofile="/boot-isos/ubcd535.iso"
	menulst="find --set-root $isofile; map $isofile (hd32); map --hook; root (hd32); chainloader (hd32)"
	linux16 (hd0,2)/boot/grub/grub.exe --config-file=$menulst
}

menuentry "AVG Rescue CD: avg_arl_cdi_all_120_160420a12074.iso" {
	set isofile="/boot-isos/avg_arl_cdi_all_120_160420a12074.iso"
	menulst="find --set-root $isofile; map $isofile (hd32); map --hook; root (hd32); chainloader (hd32)"
	linux16 (hd0,2)/boot/grub/grub.exe --config-file=$menulst
}

menuentry "Windows 7 64 bits Repair Disk" {
	set isofile="/boot-isos/w7recovery64.iso"
	menulst="find --set-root $isofile; map $isofile (hd32); map (hd1) (hd0); map (hd0) (hd1); map --hook; root (hd32); chainloader (hd32)"
	linux16 (hd0,2)/boot/grub/grub.exe --config-file=$menulst
}

menuentry "Windows 7 32 bits Repair Disk" {
	set isofile="/boot-isos/w7recovery32.iso"
	menulst="find --set-root $isofile; map $isofile (hd32); map (hd1) (hd0); map (hd0) (hd1); map --hook; root (hd32); chainloader (hd32)"
	linux16 (hd0,2)/boot/grub/grub.exe --config-file=$menulst
}

Last edited by pepemopap (2016-05-10 10:19:45)

Offline

#9 2016-05-10 19:14:24

Horizon_Brave
Operating System: Linux-Nettrix
Registered: 2015-10-18
Posts: 1,473

Re: Grub2 Chainloader to partition

Hey, I don't want to take over the thread, or switch topics too drastically, so if the mod gods think this should spin off to it's own thread, I can whip one up...

I get the point of chainloading the bootloaders on an MBR. The MBR can only be "pointed to" one bootloader at a time.  So in order to have a single physical drive that has multiple OS' on it, it needs to point to the first bootloader, which in turn has some menu-entries that points to other boot sectors (or even other bootloaders) elsewhere on the drive.

That being said, does a GPT drive have the same restriction? I would think that it being newer and created more for optimization, you wouldn't need to go through this, albeit clever, work around that we do for MBR's.


"I have not failed, I have found 10,000 ways that will not work" -Edison

Offline

Board footer

Powered by FluxBB