Is there a Linux equivalent for VHD from which it can boot?

All we need is an easy explanation of the problem, so here it is.

I have searched for this quite a lot, yet all I could find was VLite. By the way, I’m talking about an equivalent for Windows native VHD boot and not virtualization.

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

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 mapping

    • Memory 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 the loopback command which can be used to boot both read-only and read-write images

    5.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 or xnu_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

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply