Debian – How to specify an ISO as the location of root filesystem for GRUB

bootdebiangrub2kernelsystem-installation

I'm trying to understand the Debian "booting from Hard Disk" installation manual.

The process is as follows: I copy a kernel image, a ramdisk initrd and an ISO with installer to the hard drive and then configure GRUB to start the kernel and ramdisk, but also I have to tell GRUB, where is the root filesystem (it should be located at the ISO), so that the kernel could pivot root to it. But the debian-supplied grub configurations seem to specify the whole hard drive as the root filesystem, not the ISO file within it:

GRUB1:

title  New Install
root   (hd0,0)
kernel /boot/newinstall/vmlinuz
initrd /boot/newinstall/initrd.gz

GRUB2:

menuentry 'New Install' {
insmod part_msdos
insmod ext2
set root='(hd0,msdos1)'
linux /boot/newinstall/vmlinuz
initrd /boot/newinstall/initrd.gz
}

Why would that work? Is GRUB so smart to mount the ISO file on the hard disk as root filesystem, not the whole hard disk? Or do I have to dd the contents of ISO right onto the hard disk? Debian is vague on this.

Best Answer

Copied from frostshutz comment:

the initrd.gz (initramfs) contains the busybox userland and Debian scripts written to that purpose. GRUB2 also supports loop mounting ISO directly, but usually just to grab the kernel/initrd from the ISO itself, and once that's loaded again the ISO has to be found and loopmounted by the kernel/initrd.