# Grub 2, Booting ISO from HD



## theswiffervac (Nov 16, 2009)

Hey, i have an ISO image on my hard drive that i would like to boot, using grub 2 in Ubuntu 9.10. I have read TONS of stuff about this, but can't really figure it out. I have 2 partitions on my HD. #1 (/dev/sdb1) has Ubuntu 9.10 on it, and is the partition that i boot from, #2 (/dev/sdb2) only has one file on it; the ISO. I would like to be able to boot that ISO (/dev/sdb2) using either Grub2 or Lilo. I really dont know the difference lol. Thanks for any help!


----------



## lotuseclat79 (Sep 12, 2003)

Hi theswiffervac,

Welcome to TSG!

The booting process starts from the MBR with contains a link to the boot file with the boot selections between different OS/partitions, and a partition table.

Read the following post for information: Inside the Linux boot process, and then follow-up with reading GRUB 2 bootloader - Full tutorial.

-- Tom


----------



## saikee (Jun 11, 2004)

Whichever boot loader, Grub legacy, Grub2 or Lilo, you need to have the kernel and initrd files available. This means you must "expand" the iso file into a normal format and store it in a partition of the drive.

Some distro can mount the iso file automatically for your but the basoc step is to mount the iso file on a loop back device. All of these are part of the "mount" command so read its man page would help.

The basic principle is described here.

Some examples on mounting the iso and writing Grub commands are here.. The examples are mainly from Grub lagacy but I expect Grub2 and Lilo are just different in the command syntax. I have not done much with Lilo because unlilke Grub lagacy and Grub2 Lilo does not support manual booting from a floppy. I have done enough to be confident to say that both Grub2 and Lilo will work successfully the same way.

Much will depend on the content of the iso as the full booting instructions will be inside the file isolinux.cfg.

An sio file is a Linux to be booted by isolinuxwhich is a boot loader specially written for the CD/DVD rom. You need to convert the instructions to Grub2, Grub lagacy of Lilo for booting off from a hard disk.

Despite the effort the success cannot be guaranteed because the Linux might have been assembled for the system files to be fetched from a CD/DVD drive during the booting up process. So try it by all means but do take note that you are using the horse on a course not designed for it initially.


----------



## theswiffervac (Nov 16, 2009)

ok.... I remember reading something that said that the ISO's have to be constructed so that they can boot from the hard drive via Grub. Also, do i have remember that i had to mount my second partition in /mnt and then mount the ISO in /mnt/LiveISO or something like that? BTW thanks for all the help


----------



## saikee (Jun 11, 2004)

An iso file is a file arranged in iso9660 format. It can be read from a CD drive. If the file is in hard disk then you have to simulate it as running on a CD drive. You do this by mounting it on a loopback device which is a standard device in Linux. You can see these devices in /dev.

Here is my output if I list it in Ubuntu terminal

```
[email protected]:~$ ls /dev
adsp                psaux       sg0       tty37           usbdev3.1_ep81
audio               ptmx        sg1       tty38           usbdev4.1_ep00
block               pts         sg2       tty39           usbdev4.1_ep81
bus                 ram0        sg3       tty4            usbdev5.1_ep00
cdrom               ram1        shm       tty40           usbdev5.1_ep81
cdrw                ram10       snapshot  tty41           usbdev5.2_ep00
char                ram11       snd       tty42           usbdev5.2_ep02
console             ram12       sndstat   tty43           usbdev5.2_ep04
core                ram13       sr0       tty44           usbdev5.2_ep06
cpu_dma_latency     ram14       stderr    tty45           usbdev5.2_ep81
disk                ram15       stdin     tty46           usbdev5.2_ep83
dsp                 ram2        stdout    tty47           usbdev5.2_ep85
dvd                 ram3        tty       tty48           usbdev5.2_ep8b
dvdrw               ram4        tty0      tty49           usblp0
ecryptfs            ram5        tty1      tty5            usbmon0
fd                  ram6        tty10     tty50           usbmon1
full                ram7        tty11     tty51           usbmon2
fuse                ram8        tty12     tty52           usbmon3
hidraw0             ram9        tty13     tty53           usbmon4
hpet                random      tty14     tty54           usbmon5
initctl             rtc         tty15     tty55           vcs
input               rtc0        tty16     tty56           vcs1
kmem                scd0        tty17     tty57           vcs2
kmsg                sda         tty18     tty58           vcs3
log                 sda1        tty19     tty59           vcs4
[COLOR="Purple"]loop0[/COLOR]               sda10       tty2      tty6            vcs5
[COLOR="Purple"]loop1 [/COLOR]              sda11       tty20     tty60           vcs6
[COLOR="Purple"]loop2[/COLOR]               sda12       tty21     tty61           vcs7
[COLOR="Purple"]loop3[/COLOR]               sda13       tty22     tty62           vcs8
[COLOR="Purple"]loop4[/COLOR]               sda14       tty23     tty63           vcsa
[COLOR="Purple"]loop5[/COLOR]               sda15       tty24     tty7            vcsa1
[COLOR="Purple"]loop6[/COLOR]               sda2        tty25     tty8            vcsa2
[COLOR="Purple"]loop7[/COLOR]               sda3        tty26     tty9            vcsa3
mapper              sda4        tty27     ttyS0           vcsa4
mem                 sda5        tty28     ttyS1           vcsa5
mixer               sda6        tty29     ttyS2           vcsa6
net                 sda7        tty3      ttyS3           vcsa7
network_latency     sda8        tty30     urandom         vcsa8
network_throughput  sda9        tty31     usb             watchdog
null                sdb         tty32     usbdev1.1_ep00  xconsole
oldmem              sdb1        tty33     usbdev1.1_ep81  zero
pktcdvd             sdc         tty34     usbdev2.1_ep00
port                sequencer   tty35     usbdev2.1_ep81
ppp                 sequencer2  tty36     usbdev3.1_ep00
```
Say you have a file called My_linux.iso in directory /home you can mount it as a root user by instructing the command "mount" the filetype is iso9660, the option is "readonly" the loopback device is /dev/loop0 and the mounting point is /mnt/my_CDrom as follow

```
mkdir /mnt/my_CDrom
mount -t iso9660 -o ro,loop=/dev/loop0 /home/My_linux.iso /mnt/My_CDrom
```
Thereafter you will find the iso file will be expanded into a full set of directories.

Since you can view the internal data of the iso file in /mnt/My_CDRom you then copy the entire content to a pre-formatted partition and use Grub to boot it up as any Linux, except in this case you you boot up only the installer itself. However if the iso is a Live CD then you boot up a Live CD except from a hard disk without burning the iso into a CD/DVD first.

The above scheme will work if

(1) The iso has been arranged bootable from a hard disk

(2) You know how to write the Grub command to call up its kernel and initrd files (both in /boot directory and examples are available from my suggested link).


----------



## theswiffervac (Nov 16, 2009)

Hey, sorry it took so long for me to respond. I finally got Ubuntu to boot lol. I was messing with grub and something went wrong i guess and i couldn't boot my computer (again)... so anyway, how do i know if the ISO is arranged right?


----------



## saikee (Jun 11, 2004)

theswiffervac,

If the system boots and kernel doesn't panic then the iso is alright for booting from the hard disk.

From memory Debian (from which Ubuntu originated) and Red hat variants seem to do well in this respect.


----------



## theswiffervac (Nov 16, 2009)

ok thanks... btw this is a windows ISO. not linux, if that helps any. I am trying to reinstall windows because my puppy chewed up my disc (imagine that), so i downloaded a torrent, and i am trying to install with an ISO. I have been reading some more, and i came across something saying that i have to mount the ISO to /mnt/ISO_NAME (just like you mentioned) and then get the boot files from the ISO and copy them over to /boot. idk if this is accurate or not, but instead of mounting it, i extracted the files from the ISO, because whenever i mount it, i just get a readme.txt file.


In the Images i posted, the readme.txt mentions something about "UDF filesystem" and "ISO-13346". I wonder if that would have anything to do with the ISO?


----------



## saikee (Jun 11, 2004)

theswiffervac,

Judging from the Internet information the support of iso 13346 is available for reading CD/DVD. I am not sure if the mount command has been rigged for this file type. It appears you are asking something too new.

I would suggest burn the iso into CD or DVD and see if the operating system can read it first.


----------



## theswiffervac (Nov 16, 2009)

ok..... well i dont have any cd/dvd's right now, so i will try to pick some up tomorrow on my way home... i read about iso 13346 and i understand that it is primarily used for windows, and i believe there is a way to mount it on ubuntu, but not quite sure. time to start experimenting.


----------



## saikee (Jun 11, 2004)

The support of iso 13346 in Linux if available would be confined to reading the data off the CD/DVD in the first instance.

What you are requiring is a little bit beyond because you want a command to mount the iso.

If you "find" the Make iso file commands you will find (in my case from Ubuntu using 2.6.28 kernel)

```
[email protected]:/home/saikee# find / -name mkiso*
/usr/bin/mkisofs
[email protected]:/home/saikee#
```
The above indicates there is a command in /usr/bin called mkisofs. I could not find a manual page for it but some documentation is showed if you type

```
mkisofs -help
```
I have checked its content and could not find any reference to iso 13346 but iso 6990 is featured as one of the option. I have used this command to make bootable iso for both CD and DVD before.

The mkiso command, a standard command in Bash for users to make their own CD and DVD, is a good indication if the iso 13346 is supported or not because logically it will be extended to cover it as an additional option.

If there is a demand to use the iso 13346 then Linux will implement it eventually. It does not look like to be a high priority but the Internet literature indicates the support is available for CD/DVD read currently.


----------



## theswiffervac (Nov 16, 2009)

ok... so what if i extracted the ISO contents, and then made an iso with them using the command you mentioned above? do you think the iso would be able to boot from the HD?


----------



## saikee (Jun 11, 2004)

If you manage to can extract the the content from an 13346 iso, copy it to a directory and make an iso 9660 from it then of course you can make it bootable.

There are two bootloaders for Linux; isolinux (developed by Peter Alvin and used by the majority distros) and Grub lagacy. Not done the former but the latter is well documented by Grub manual. It is simple to use. Here is an example of combining several iso together and use Grub to make a bootable DVD.


----------



## theswiffervac (Nov 16, 2009)

ok thanks... i have used the isolinux bootloader thing before, and it is pretty helpful. Well anyway, i got Windows installed from a friend, and it works great now. Thanks a lot for all the help.


----------

