<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:foaf="https://xmlns.com/foaf/0.1/" xmlns:og="https://ogp.me/ns#" xmlns:rdfs="https://www.w3.org/2000/01/rdf-schema#" xmlns:schema="https://schema.org/" xmlns:sioc="https://rdfs.org/sioc/ns#" xmlns:sioct="https://rdfs.org/sioc/types#" xmlns:skos="https://www.w3.org/2004/02/skos/core#" xmlns:xsd="https://www.w3.org/2001/XMLSchema#" version="2.0" xml:base="https://www.linuxjournal.com/tag/grub">
  <channel>
    <title>GRUB</title>
    <link>https://www.linuxjournal.com/tag/grub</link>
    <description/>
    <language>en</language>
    
    <item>
  <title>GRUB Boot from ISO</title>
  <link>https://www.linuxjournal.com/content/grub-boot-iso</link>
  <description>  &lt;div data-history-node-id="1339316" class="layout layout--onecol"&gt;
    &lt;div class="layout__region layout__region--content"&gt;
      
            &lt;div class="field field--name-field-node-image field--type-image field--label-hidden field--item"&gt;  &lt;img src="https://www.linuxjournal.com/sites/default/files/nodeimage/story/Terminalicon2.png" width="500" height="500" alt="" typeof="foaf:Image" class="img-responsive" /&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-node-author field--type-ds field--label-hidden field--item"&gt;by &lt;a title="View user profile." href="https://www.linuxjournal.com/users/kyle-rankin" lang="" about="https://www.linuxjournal.com/users/kyle-rankin" typeof="schema:Person" property="schema:name" datatype="" xml:lang=""&gt;Kyle Rankin&lt;/a&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"&gt;&lt;p&gt;
Last year I worked on a project to add an OEM-style rescue partition to a
computer. Where most OEM installs have a custom program that just rewrites
an install image over the top of the partition, in this case, everything
was based on open-source software. This rescue partition would be only a
few gigabytes in size—big enough to contain the install DVD ISO image and
a few preseed files to help automate the install. If users ever wanted
to get back to the factory-installed version of the operating system, they
could select a special option from the GRUB menu that would boot off 
the ISO and start the install as though they had used a USB key or DVD.
&lt;/p&gt;

&lt;p&gt;
If you read some past guides on how to boot an ISO from GRUB, you will
find a number of pretty complicated instructions in some cases because
they were writing for older versions of GRUB. With the recent versions of
GRUB2, booting from a standard ISO is fortunately not that complicated. I
base my example here off a recent Debian Stretch install DVD, but the
same steps should work for other distributions and install ISOs with
some tweaks.
&lt;/p&gt;

&lt;h3&gt;
Create the Partition&lt;/h3&gt;

&lt;p&gt;
The first step is to create the rescue partition. In my case, I automated
my install with a preseed script, but basically I just created a partition
that was big enough to hold the install DVD. I made sure to give it a
label so I could tell it apart from other disks later on and made it
the second partition on the disk. Because I was doing all of this via an
automated means, I ended up using &lt;code&gt;dd&lt;/code&gt; to create an image of the install
DVD that was currently in use as an end-of-install script and dumped
it to the root of that partition in a file called install_dvd1.iso. Of
course, you could just copy over your ISO directly to the disk if you do
this from a system that already has an OS on it.
&lt;/p&gt;

&lt;h3&gt;
Build the GRUB Config&lt;/h3&gt;

&lt;p&gt;
The next step was to build a GRUB config that would mount the ISO
loopback and boot off the kernel and initrd file within that ISO. On
Debian-based systems, you can add bash scripts that output extra GRUB
configuration to /etc/grub.d/ and run &lt;code&gt;update-grub&lt;/code&gt; to build a new grub.cfg
file. But, you also could just edit grub.cfg directly or otherwise use your
distribution's GRUB configuration scripts to add the following menu items:

&lt;/p&gt;&lt;pre&gt;
&lt;code&gt;
set root='hd0,msdos2'
set isofile="/install_dvd1.iso"
menuentry "Install OS" {
 loopback loop (hd0,msdos2)$isofile
 linux (loop)/install.amd/vmlinuz vga=788 auto=true
  ↪file=/media/preseed.cfg -- quiet
 initrd (loop)/install.amd/initrd.gz
}
menuentry "Install OS (Expert)" {
 loopback loop (hd0,msdos2)$isofile
 linux (loop)/install.amd/vmlinuz vga=788 -- quiet
 initrd (loop)/install.amd/initrd.gz
}
&lt;/code&gt;
&lt;/pre&gt;


&lt;p&gt;
Let's break this GRUB configuration down a bit. First, you set two
variables: the root partition GRUB will use (the second partition on
the first disk, which GRUB refers to as hd0,msdos2) and the ISO file:

&lt;/p&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-node-link field--type-ds field--label-hidden field--item"&gt;  &lt;a href="https://www.linuxjournal.com/content/grub-boot-iso" hreflang="und"&gt;Go to Full Article&lt;/a&gt;
&lt;/div&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;

</description>
  <pubDate>Tue, 14 Mar 2017 13:38:30 +0000</pubDate>
    <dc:creator>Kyle Rankin</dc:creator>
    <guid isPermaLink="false">1339316 at https://www.linuxjournal.com</guid>
    </item>

  </channel>
</rss>
