Random notes from mg

a blog by Marius Gedminas

Marius is a Python hacker. He works for Programmers of Vilnius, a small Python/Zope 3 startup. He has a personal home page at http://gedmin.as. His email is marius@gedmin.as. He does not like spam, but is not afraid of it.

Mon, 03 May 2010

Booting ISO images from a USB drive

Dear lazyweb, I would like to download an arbitrary ISO image (say, a Ubuntu 10.04 Desktop CD) into a directory of a USB flash drive, and then make that USB flash drive boot that ISO image. I do not want to

I just want a bootloader on the USB to read the VFAT filesystem, mount the ISO image as a loop device, then chain-load the bootloader from that ISO. Bonus points for having a menu letting me choose one of several ISO images. Running a script to edit a text file (say, grub's config) to get that menu is fine.

Is this even possible? If not, can I at least have two out of three (no partition/extraction, but skipping intrinsic bootloader is fine)?

Solution that I finally chose (from Ubuntu forums):

Plug in USB key. Find out the mount point (/media/disk) and the device name (/dev/sdx) of the USB key with

$ mount|grep /media

Install GRUB 2 into the USB key with

$ sudo grub-install --root-directory=/media/usbdisk /dev/sdx

If it says something about embedding being impossible and falling back to UNRELIABLE blocklist-based setup, run

$ sudo grub-install --root-directory=/media/usbdisk /dev/sdx --force

Download a CD image, let's say ubuntu-10.10-desktop-i386.iso. Put it into /media/usbdisk/ubuntu/.

Create a text file /media/usbdisk/boot/grub/grub.cfg with

menuentry "Ubuntu 10.10 (x86 desktop livecd)" {
    set isofile="/ubuntu/ubuntu-10.10-desktop-i386.iso"
    loopback loop $isofile
    linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile quiet splash noprompt --
    initrd (loop)/casper/initrd.lz
}

You can have as many ISO images as you want, just make sure to add a menuentry for each. There's no need to run grub-install again after adding or removing a .iso file. Oh, and if you want to use an ISO file for a different distribution, you'll have to figure out the correct linux and initrd lines somehow.

Update: Ubuntu 13.04 changed the name of the kernel -- use (loop)/casper/vmlinuz.efi instead of (loop)/casper/vmlinuz.

I tested it with the following images

This solution skips the CD-ROM's boot menu. I haven't found a better one.

posted at 20:24 | tags: , | permanent link to this entry | 22 comments
Use BootMyISO from http://www.pendrivelinux.com
Comes with a menu, and you can add your own ISOs. And for me, this one actually works :)
posted by Koen at Mon May 3 22:40:12 2010
I got something similar working with Grub for DOS thanks to a little utility found at http://www.pendrivelinux.com/boot-multiple-iso-from-usb-multiboot-usb/

I had to go in and edit the menu.lst to suit the images I am using but that aside it was rather easy to setup. The only downside was that the utility only runs in windows... although I see no reason it would need to assuming one could install Grub on the key some other way...

HTH!

Cheers,
Tim
posted by Tim at Mon May 3 22:53:23 2010
I can tell that your linux-fu is much stronger than mine. Would something like this work for you?
http://www.pendrivelinux.com/boot-multiple-iso-from-usb-multiboot-usb/
You drop .ISOs onto a usb device, then, from the site, "MultiBootISOs Works by using Syslinux  to chainload GRUB4DOS."
I haven't used this but I have used their pendrivelinux (just updated to include lucid lynx). I used it to create a Mint 8 bootable SD card that included persistent storage.
btw, their usb creator was a standalone exe (no install needed). Not sure if it's the same for multibootisos.exe.
good luck.
posted by fluke at Tue May 4 00:59:51 2010
I'ts doable using grub2, with some configuration magic.

I think this will help you: http://rww.dreamwidth.org/3100.html
posted by Olivier at Tue May 4 10:58:44 2010
posted by TGM at Tue May 4 13:46:35 2010
Oops - I meant this one...

http://rww.dreamwidth.org/3100.html
posted by TGM at Tue May 4 13:52:10 2010
The MultiBootISOs thing is very intriguing, but it requires me to find a Windows machine and download/run random exe files from the Internet.  Not gonna happen.

I ended up following this recipe: http://ubuntuforums.org/showthread.php?t=1288604 (which I found linked from a comment at http://rww.dreamwidth.org/3100.html) with a slight twist: I had to add '--force' to grub-install, since it said embedding wasn't possible and it had to fall back to UNRELIABLE blocklist-based setup.

Will boot now and see if it works.  Thanks everyone for answers!
posted by Marius Gedminas at Wed May 5 18:05:21 2010
http://liveusb.info/dotclear/

sorry it's in french, but this solution seems quite flexible.
posted by tshirtman at Thu May 6 00:20:21 2010
Mariau, did it work?

Can Grub2 chainload ISO bootloader already?
Until recent times it was only GRUB4Dos who could.
posted by s2 at Sat May 8 10:34:12 2010
The USB drive boots (although there's a scarily-long pause with a black text-mode screen and a blinking cursor; in my first attempt I thought it didn't work and rebooted before Ubuntu had a chance to initialize its boot splash).

It's not really chainloading, though; grub2 boots the kernel and initramfs directly and requires the OS to do its own ISO-image loading.
posted by Marius Gedminas at Sat May 8 19:47:30 2010
> there's a scarily-long pause
> with a black text-mode screen

Does it do some disk activity?  Then maybe it is: https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/420933

> It's not really chainloading, though

Ah, it's a pity. I've talked to some italian guy "cod" who was interested in writing BIOS Disk emulation from an ISO (several months ago).  So it could work with any bootable CD/DVD image.

Judging from his site, he hasn't made a progess since:
http://my.opera.com/wolfcod/blog/

But you could probably contact him to be sure, if interested. 

OTOH, Grub4Dos can emulate BIOS disk/ATAPI also, so it's possible the code to be backported to Grub2 in some future:
https://gna.org/projects/grub4dos/
posted by s2 at Sun May 9 18:14:56 2010
Grub4DOS does INT 13h disk emulation, but this only works for ancient OSes -- neither Windows nor Linux  use the BIOS to access CD-ROMs after entering protected mode.

Since I wasn't planning to boot MS-DOS from a CD, I didn't research whether Grub2 supports that or not.
posted by Marius Gedminas at Sun May 9 19:56:27 2010
OK, I see now, Mariau.  I gave it a second thought and it seems to me the solution will need either firmware level CD-ROM emulator or the bootkit capable of virtualizing x86 machine.

As for the first, I know of specialized USB sticks:
ww w.hsc-us.c om/Embedded/udrw/index.htm

Plus I've heard (from the same italian guy), some KINGSTONs also provides similar functionality in their firmwares.

Now for the second:
en.wikipedia.o rg/wiki/X86_virtualization

If you're lucky to get hardware assisted (native) virtualization (on latest x86* CPUs) running, then the needed bootkit will probably be thin, nice and give you near-native performance.

But should you use full virtualization or even paravirtualization (on older CPUs), the performance in guest OS would drop significantly, I believe (like it being run inside Qemu running on the same machine).  I mean, not only virtual CD/DVD transfers would suffer, but the whole OS execution too :(

So you are left with two pratical choices: AMD-V/Intel VT-x bootkit or USB firmware level CD/DVD-ROM emulator.

Do you like any of these two?  Or have you some other thoughts accumulated by the time? :)
posted by s2 at Tue Oct 19 23:33:06 2010
I guess you don't :)
posted by s2 at Sat Nov 6 10:15:51 2010
Yes, that sounds like lots of work for little benefit.  I'm only interested in booting Linux CDs, and those usually support a native boot-from-iso-image option.  All I lose is the CD boot menu.
posted by Marius Gedminas at Sat Nov 6 16:34:31 2010
Added a TL;DR version of the forum instructions to this post.  The original instructions are excellent, but long.  Go there if you want to know how to boot non-Ubuntu ISO images.
posted by Marius Gedminas at Fri Dec 3 21:24:32 2010
FWIW, there are some HowTo (in russian) on the second way I offered.  They are UFD-controller specific, but sometimes it's better than nothing:

http://flashboot.ru/index.php?name=iflash

http://flashboot.ru/index.php?name=News&op=article&sid=33

http://flashboot.ru/index.php?name=News&op=article&sid=29

http://flashboot.ru/index.php?name=News&op=article&sid=23
posted by s2 at Wed Jan 12 23:41:33 2011
Sorry, I forgot to add: this is MS way ;(
posted by s2 at Wed Jan 12 23:45:09 2011
I copied ubuntu 10.04 os files in my computer from my friend cd. now i want to install it with my pendrive. But it didn't works. it asks iso image.  i just tried from many softwares but those are also asks .iso image type file.I didn't find such image file in ubuntu os files. how can i get it? plz help me.
posted by Keerthana N at Fri May 11 21:02:59 2012
This technique continues to work fine with all Ubuntu versions up to and including 12.10.

Incidentally you can test the bootable USB stick by doing
sudo umount /media/usbdisk
sudo kvm -hdb /media/sdx
posted by Marius Gedminas at Fri Oct 19 18:09:40 2012
Urk, make that last line
sudo kvm -hdb /dev/sdx
posted by Marius Gedminas at Thu Jan 3 20:44:56 2013
here is a good way to run linux(ubuntu/bt) without usb in windows ,it do not uses iso emulation like grub[grab it you will find it interesting][1]



http://www.hk416.co.nf/booter.html


  [1]: http://www.hk416.co.nf/booter.html
posted by manox at Sat Apr 12 03:57:50 2014

Name (required)


E-mail (will not be shown)


URL


Comment (some HTML allowed)