grub-mkrescue fails to create a bootable CD image
<p>I have this iso image which apparently VirtualBox can not read. I am currently using GRUB And following <a href="https://www.youtube.com/watch?v=ZiHtuBnVrx4&amp;list=PLHh55M_Kq4OApWScZyPl5HhgsTJS9MZ6M&amp;index=3" rel="nofollow">this</a> tutorial and in the episode of OS-VM Installation. i have screen-recorded the error as i went through the steps here:</p>

<p><a href="https://www.youtube.com/watch?v=ZGnPo34wOAw&amp;feature=youtu.be" rel="nofollow">https://www.youtube.com/watch?v=ZGnPo34wOAw&amp;feature=youtu.be</a></p>

<p>here are my files currently:</p>

<p>Makefile:</p>

<pre><code>GPPARAMS =  -m32 -Iinclude -fno-use-cxa-atexit -nostdlib -fno-builtin -fno-rtti -fno-exceptions -fno-leading-underscore -Wno-write-strings
ASPARAMS =  --32
LDPARAMS =  -melf_i386
objects = kernel.o loader.o 

all:
    g++ -m32 -Iinclude -fno-use-cxa-atexit -nostdlib -fno-builtin -fno-rtti -fno-exceptions -fno-leading-underscore -Wno-write-strings  -o kernel.o -c kernel.cc
    as $(ASPARAMS) -o loader.o loader.S

BoneOS.bin : linker.ld $(objects)
    ld $(LDPARAMS) -T $&lt; -o $@ $(objects)

install: BoneOS.bin
    sudo cp $&lt; /boot/BoneOS.bin

clean:
      rm $(objects)
      rm -rf iso

qemu_compile: all BoneOS.bin qemu


qemu:
    qemu-system-i386 -kernel BoneOS.bin 

BoneOS.iso: BoneOS.bin
    mkdir iso
    mkdir iso/boot
    mkdir iso/boot/grub
    cp BoneOS.bin iso/boot/BoneOS.bin
    echo 'set timeout=0'                      &gt; iso/boot/grub/grub.cfg
    echo 'set default=0'                     &gt;&gt; iso/boot/grub/grub.cfg
    echo ''                                  &gt;&gt; iso/boot/grub/grub.cfg
    echo 'menuentry "My Operating System" {' &gt;&gt; iso/boot/grub/grub.cfg
    echo '  multiboot /boot/BoneOS.bin'    &gt;&gt; iso/boot/grub/grub.cfg
    echo '  boot'                            &gt;&gt; iso/boot/grub/grub.cfg
    echo '}'                                 &gt;&gt; iso/boot/grub/grub.cfg
    grub-mkrescue -o BoneOS.iso iso
</code></pre>

<p>kernel.cc:</p>

<pre><code>#define SWAP(a, b) do { typeof(a) temp = a; a = b; b = temp; } while (0)


static  unsigned short* ViedoMemory =((unsigned short*)0xb8000);

typedef void (*constructor)();
extern "C" constructor start_ctors;
extern "C" constructor end_ctors;
extern "C" void callConstructors()
{
    for(constructor* i = &amp;start_ctors; i != &amp;end_ctors; i++)
        (*i)();
}



class Foo
{
public:
    Foo(int r)
    {
        x=r;
    }

    int getX()
    {
        return x;
    }
private:
    int x=0;
};

int strlen(char* str)
{
    int l=0;
    while(str[l]!='\0')l++;
    return l;
}


char* str_cat(char *dest, const char *src)
{

    while (*dest!= '\0')
        *dest++ ;
    do
    {
        *dest++ = *src++;
    }
    while (*src != '\0') ;

    return dest;
}

/* A utility function to reverse a string  */
void reverse(char str[], int length)
{
    int start = 0;
    int end = length -1;
    while (start &lt; end)
    {
        SWAP(*(str+start), *(str+end));
        start++;
        end--;
    }
}

char* itoa(int num, char* str, int base)
{
    int i = 0;
    unsigned int isNegative = 0;

    /* Handle 0 explicitely, otherwise empty string is printed for 0 */
    if (num == 0)
    {
        str[i++] = '0';
        str[i] = '\0';
        return str;
    }

    /* In standard itoa(), negative numbers are handled only with
       base 10. Otherwise numbers are considered unsigned. */
    if (num &lt; 0 &amp;&amp; base == 10)
    {
        isNegative = 1;
        num = -num;
    }

    /* Process individual digits */
    while (num != 0)
    {
        int rem = num % base;
        str[i++] = (rem &gt; 9)? (rem-10) + 'a' : rem + '0';
        num = num/base;
    }

    /* If number is negative, append '-' */
    if (isNegative)
        str[i++] = '-';

    str[i] = '\0'; /* Append string terminator */

    /* Reverse the string */
    reverse(str, i);

    return str;
}

void printf(char *str)
{

    for(int i=0;str[i]!='\0'; ++i)
        ViedoMemory[i + 20 * 80]= (ViedoMemory[i + 20 * 80] &amp; 0xFF00)|str[i];
}




Foo bar(2);
extern "C" void kernelMain(void* multiboot_structure, unsigned int magicnumber)
{

   int *multiboot_struct_int = (int*)multiboot_structure;
   char *str = "",*ram="RAM";
   char* RAM_AM = itoa(*multiboot_struct_int,str,10);

   printf(itoa(bar.getX(),str,10));
   while(1);
}
</code></pre>

<p>loader.S:</p>

<pre><code>#Global MultiBoot Kernel Recongnzation
.set MAGIC,0x1badb002
.set FLAGS , (1&lt;&lt;0 | 1&lt;&lt;1)
.set CHECKSUM, -(MAGIC + FLAGS)

#Putting in object file
.section .multiboot
    .long MAGIC
    .long FLAGS
    .long CHECKSUM


.section .text

    .extern kernelMain
    .extern callConstructors
    .globl loader

        loader:
                mov $kernel_stack , %esp
            #    call callConstructors
                push %eax
                push %ebx
                call kernelMain

        _eof:
             cli
             hlt 
             jmp _eof


.section .bss
.space 2*1024*1024 #2 MiB
kernel_stack:
</code></pre>

<p>linker.ld:</p>

<pre><code>ENTRY(loader)
OUTPUT_FORMAT(elf32-i386)
OUTPUT_ARCH(i386:i386)

SECTIONS
{
  . = 0x0100000;

  .text :
  {
    *(.multiboot)
    *(.text*)
    *(.rodata)
  }

  .data  :
  {
    start_ctors = .;
    KEEP(*( .init_array ));
    KEEP(*(SORT_BY_INIT_PRIORITY( .init_array.* )));
    end_ctors = .;

    *(.data)
  }

  .bss  :
  {
    *(.bss)
  }

  /DISCARD/ : 
  { 
    *(.fini_array*) 
    *(.comment) 
  }
}
</code></pre>

<p>iso/boot/grub/grub.cfg:</p>

<pre><code>set timeout=0
set default=0

menuentry "My Operating System" {
  multiboot /boot/BoneOS.bin
  boot
}
</code></pre>

<p>Above code for some reason when ran via VirtualBox(video above shows you how i did it) , gets me the error 'Error: Could not read from Bootable Medium'. Help would be appreciated</p>

<h2>Edit</h2>

<p>The catch here though is for some reason it works on qemu when i do:</p>

<pre><code>qemu-system-i386 -kernel BoneOS.bin 
</code></pre>

<p>But does not show me the menu selection</p>

<h2>With Qemu</h2>

<p>When i run the command:</p>

<pre><code>qemu-system-i386 -cdrom BoneOS.iso
</code></pre>

<p>I get no Bootable Device just like Virtual Box, here is a viedo illustrating it:</p>

<p><a href="https://www.youtube.com/watch?v=8D6LtcMoztw&amp;feature=youtu.be" rel="nofollow">https://www.youtube.com/watch?v=8D6LtcMoztw&amp;feature=youtu.be</a></p>