Grub can map pretty much any disk image files and boot from that
grub4dos and grub1 support the
map
command for booting from read-only images. I'm not sure about their capabilities to boot read-write images. There are 2 types of mappingMemory map: The image is loaded onto memory before mapping as disk, usually used with floppy disk images. When memory mapping is used the disk image file can be non-contiguous. For example:
map (hd0,0)/win98.ima (fd0)
Direct map: map the file using int13, requires the file to be contiguous
map (device)/path/file.iso (hd32)
After all mappings were done you'll need to commit them with
map --hook
These types of mapping allow you to easily boot any live Linux distros. If necessary you can use a casper rw persistent disk image for non-volatile data. For more information read LiveCD/Persistence
In
grub2
you'll have to use theloopback
command which can be used to boot both read-only and read-write images5.2 Loopback booting
GRUB is able to read from an image (be it one of CD or HDD) stored on any of its accessible storages (refer to see loopback command). However the OS itself should be able to find its root.
This usually involves running a userspace program running before the real root is discovered. This is achieved by GRUB loading a specially made small image and passing it as ramdisk to the kernel. This is achieved by commands
kfreebsd_module
,knetbsd_module_elf
,kopenbsd_ramdisk
,initrd
(see initrd),initrd16
(see initrd),multiboot_module
,multiboot2_module
orxnu_ramdisk
depending on the loader.
In the past wubi used the same technique to boot Ubuntu from an image without an ext4 root partition
If you're using syslinux then there's an equivalent feature called MEMDISK
MEMDISK is meant to allow booting legacy operating systems. MEMDISK can boot floppy images, hard disk images and some ISO images.
MEMDISK simulates a disk by claiming a chunk of high memory for the disk and a (very small - typically, 2K) chunk of low (DOS) memory for the driver itself, then hooking the INT 13h (disk driver) and INT 15h (memory query) BIOS interrupts.
See
- Booting an EXT4 image file from GRUB2
- grub: boot from ISO
- How to boot Fedora Live CD iso from a Hard Drive?
- How to boot Linux from image on disk or "Poor Man's Install"?
- Can I boot Linux from a VHD?
- Install Ubuntu from ISO image directly from hard disk of a system running Linux?
- Deploy Linux into, and boot from, VHD
- How to Boot Linux ISO Images Directly From Your Hard Drive
- Is it possible to native boot Linux from raw disk image?
- booting linux from a loop file system