MultiBoot USB with Grub2 (boot directly from iso files)

DEVICE=/dev/sdb
VOLUME=MultiBootUSB
 
 
# create filesystem on usb pen
sudo mkfs.vfat -n ${VOLUME} ${DEVICE}1
 
 
# mount usb
mount ${DEVICE}1 /mnt/
 
 
# install grub2 on usb pen
grub-install --no-floppy --root-directory=/mnt ${DEVICE}
 
 
# create grub config
cat <<EOF> /mnt/boot/grub/grub.cfg
menuentry "Ubuntu Live 11.04 64bit" {
        loopback loop /boot/iso/ubuntu-11.04-desktop-amd64.iso
        linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/boot/iso/ubuntu-11.04-desktop-amd64.iso noeject noprompt --
        initrd (loop)/casper/initrd.lz
}
 
menuentry "Ubuntu Live 9.10 32bit" {
 loopback loop /boot/iso/ubuntu-9.10-desktop-i386.iso
 linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/boot/iso/ubuntu-9.10-desktop-i386.iso noeject noprompt --
 initrd (loop)/casper/initrd.lz
}
 
menuentry "Ubuntu Live 9.10 64bit" {
 loopback loop /boot/iso/ubuntu-9.10-desktop-amd64.iso
 linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/boot/iso/ubuntu-9.10-desktop-amd64.iso noeject noprompt --
 initrd (loop)/casper/initrd.lz
}
 
menuentry "Grml small 2009.10" {
  loopback loop /boot/iso/grml-small_2009.10.iso
  linux (loop)/boot/grmlsmall/linux26 findiso=/boot/iso/grml-small_2009.10.iso apm=power-off lang=us vga=791 boot=live nomce noeject noprompt --
  initrd (loop)/boot/grmlsmall/initrd.gz
}
 
menuentry "tinycore" {
 loopback loop /boot/iso/tinycore_2.3.1.iso
 linux (loop)/boot/bzImage --
 initrd (loop)/boot/tinycore.gz
}
 
menuentry "Netinstall 32 preseed" {
  loopback loop /boot/iso/mini.iso
  linux (loop)/linux auto url=http://www.panticz.de/pxe/preseed/preseed.seed locale=en_US console-setup/layoutcode=de netcfg/choose_interface=eth0 debconf/priority=critical --
  initrd (loop)/initrd.gz
}
 
menuentry "debian-installer-amd64.iso" {
  loopback loop /boot/iso/debian-installer-amd64.iso
  linux (loop)/linux vga=normal --
  initrd (loop)/initrd.gz
}
 
menuentry "BackTrack 4" {
 linux /boot/bt4/boot/vmlinuz BOOT=casper boot=casper nopersistent rw vga=0x317 --
 initrd /boot/bt4/boot/initrd.gz
}
 
menuentry "Memory test (memtest86+)" {
 linux16 /boot/img/memtest86+.bin
}
 
menuentry "BackTrack ERR" {
 loopback loop /boot/iso/bt4-pre-final.iso
 linux (loop)/boot/vmlinuz find_iso/filename=/boot/iso/bt4-pre-final.iso BOOT=casper boot=casper nopersistent rw vga=0x317--
 initrd (loop)/boot/initrd.gz
}          
 
menuentry "XBMC ERR" {
 loopback loop /boot/iso/XBMCLive.iso
 linux (loop)/vmlinuz boot=cd isofrom=/dev/sda1/boot/iso/XBMCLive.iso xbmc=nvidia,nodiskmount,tempfs,setvolume loglevel=0 --
 initrd (loop)/initrd0.img
}
 
menuentry "netboot.me" {
 loopback loop /boot/iso/netbootme.iso
 linux16 (loop)/GPXE.KRN
}
 
menuentry "debian installer amd64 netboot XEN pressed" {
  linux /boot/debian/linux auto preseed/url=http://www.panticz.de/pxe/preseed/xen.seed locale=en_US console-setup/layoutcode=de netcfg/choose_interface=eth0 debconf/priority=critical --
  initrd /boot/debian/initrd.gz
}
EOF
 
# create iso directory
mkdir /mnt/boot/iso
 
#
# download images
#
# maverick test
sudo wget http://releases.ubuntu.com/10.10/ubuntu-10.10-desktop-i386.iso -P /boot/ubuntu-10.10-desktop-i386.iso
sudo ln -s /boot/ubuntu-10.10-desktop-i386.iso /boot/ubuntu-live-desktop-i386.iso
 
cat <<EOF>> /etc/grub.d/custom.cfg 
menuentry "Ubuntu Live 32bit" {
 loopback loop /boot/ubuntu-live-desktop-i386.iso
 linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/boot/ubuntu-live-desktop-i386.iso noeject noprompt --
 initrd (loop)/casper/initrd.lz
}
EOF
 
#?# sudo update-grub
 
 
# Ubuntu Live 9.10 32bit
wget http://ftp.uni-kl.de/pub/linux/ubuntu.iso/9.10/ubuntu-9.10-desktop-i386.iso -P /mnt/boot/iso
 
# Ubuntu Live 9.10 64bit
wget http://ftp.uni-kl.de/pub/linux/ubuntu.iso/9.10/ubuntu-9.10-desktop-amd64.iso -P /mnt/boot/iso
 
# grml
wget http://grml.deb.at/grml-small_2009.10.iso -P /mnt/boot/iso
 
# tinycore
wget http://distro.ibiblio.org/pub/linux/distributions/tinycorelinux/2.x/release/tinycore_2.3.1.iso -P /mnt/boot/iso
 
# netinstall
wget http://archive.ubuntu.com/ubuntu/dists/jaunty/main/installer-i386/current/images/netboot/mini.iso -P /mnt/boot/iso
 
# xbmc
# unzip http://downloads.sourceforge.net/sourceforge/xbmc/XBMC_Live-9.04.1.zip
 
# debian
wget http://ftp.debian.org/debian/dists/etch/main/installer-amd64/current/images/netboot/mini.iso -O /mnt/boot/iso/debian-installer-amd64.iso
 
# netboot.me
wget http://static.netboot.me/gpxe/netbootme.iso -P /mnt/boot/iso
 
# umount
sync
umount /mnt/
 
 
 
# test
# debian
wget http://cdimage.debian.org/debian-cd/5.0.2/amd64/iso-cd/debian-502-amd64-netinst.iso
 
 
menuentry "debian-502-amd64-netinst.iso" {
  loopback loop /boot/iso/debian-502-amd64-netinst.iso
  linux (loop)/install.amd/vmlinuz vga=normal --
  initrd (loop)/install.amd/initrd.gz
}
 
menuentry "debian installer amd64 netboot" {
  linux /boot/debian/linux auto=true priority=critical vga=normal --
  initrd /boot/debian/initrd.gz
}
 
# update debian installation files (/mnt/boot/debian/update.sh)
wget http://ftp.de.debian.org/debian/dists/stable/main/installer-amd64/current/images/netboot/debian-installer/amd64/initrd.gz -O initrd.gz
wget http://ftp.de.debian.org/debian/dists/stable/main/installer-amd64/current/images/netboot/debian-installer/amd64/linux -O linux
 
 
# links
https://bugs.launchpad.net/ubuntu/+bug/94204
http://debianforum.de/forum/viewtopic.php?f=32&t=111249
http://michael-prokop.at/blog/2009/05/25/boot-an-iso-via-grub2/
https://wiki.edubuntu.org/Grub2
http://wiki.ubuntuusers.de/GRUB_2/Konfiguration?highlight=cd

Comments

no device specified.

I'm working with a 16g patriot
OK so I enter:

sudo mkfs.vfat -n ${multipass} ${dev/sdb}1

And I keep getting the error - "No Device Specified!"
What am I doing wrong?

try this: sudo mkfs.vfat -n

try this:
sudo mkfs.vfat -n multipass /dev/sdb1

${NAME} is a bash variable, you have to define those first

Issues with harddrive geometry

Hi there,

Last night I gave it another try. I had issues with some "better" usbsticks I bought, because they promised more rw-performance. But I never got them up and running flawlessly.

Later that night I found out, that these premium-usbsticks have only 32 sectors/track instead of 63 sectors/track like normal hdds, so grub-install quitted with warnings. After changing the partition-scheme starting with cylinder 2 instead of 1 gave grub enough space for its core.img so it installed without warnings. I explain my experience in my blog-entry in german language.

Maybe someone can confirm my findings,

Jürgen

instructions?

i don't know programming or coding, but would like to make a multiboot linux usb stick. the multiboot usb creator i use now from i got from here http://www.pendrivelinux.com/multiboot-create-a-multiboot-usb-from-linux/ doesn't support fluppy, which i'd like to install.

how do i use the above code? do i enter that in a terminal, and it creates the usb asking where the iso files and usb drive are? a little explanation would help if not too complicated. i appreciate it.

kudos

What a nice work.
Straight forward, clean AND
mentioning your sources!

MKFS not working

Hi, Somehow when I type sudo mkfs.vfat -n ${VOLUME} ${DEVICE}1 I get that message : sudo mkfs.vfat -n &{VOLUME} &{DEVICE}1 [1] 6041 mkfs.vfat 2.11 (12 Mar 2005) [2] 6042 mkfs.vfat: option requires an argument -- 'n' Unknown option: ? Usage: mkdosfs [-A] [-c] [-C] [-v] [-I] [-l bad-block-file] [-b backup-boot-sector] [-m boot-msg-file] [-n volume-name] [-i volume-id] [-B bootcode] [-s sectors-per-cluster] [-S logical-sector-size] [-f number-of-FATs] [-h hidden-sectors] [-F fat-size] [-r root-dir-entries] [-R reserved-sectors] /dev/name [blocks] bash: {DEVICE}1: command not found [1]- Exit 1 sudo mkfs.vfat -n jairo@jairo-laptop:~$ bash: {VOLUME}: command not found

Re: MKFS not working

I see a couple of that should be ${}
Tony Godshall

Persistent mode

Hello,

Thanks for this tutorial, I have a question, can we add a persistent mode ?

Regards,

mad

Ubuntu dosen't boot properly

A few days ago i made a LiveUSB. I used GRUB2 because it can use ISO. It boots right Slax, Grml, but i have problems with Ubuntu 9.10 and Karmic Netbook Remix. After i select ubuntu in grub it gets until login but it stops at a black screen and it shows me the mouse and nothing more. I was able to enter in terminal with CTRL-ALT-F1-6 and i run dmesg. The stick is FAT32, but i used EXT3 too and i get same error.

This is dmesg | grep "error"

 render error detected, EIR: 0x00000010
[    4.895248] page table error
[    4.895255] [drm:i915_handle_error] *ERROR* EIR stuck: 0x00000010, masking
[    4.895265] render error detected, EIR: 0x00000010
[    4.895268] page table error
[   56.440384] end_request: I/O error, dev sdb, sector 285357
[   56.445558] Buffer I/O error on device loop0, logical block 63168
[   56.445586] Buffer I/O error on device loop0, logical block 63169
[   56.445605] Buffer I/O error on device loop0, logical block 63170
[   56.445623] Buffer I/O error on device loop0, logical block 63171
[   56.445641] Buffer I/O error on device loop0, logical block 63172
[   56.445659] Buffer I/O error on device loop0, logical block 63173
[   56.445677] Buffer I/O error on device loop0, logical block 63174
[   56.445695] Buffer I/O error on device loop0, logical block 63175
[   56.445713] Buffer I/O error on device loop0, logical block 63176
[   56.445731] Buffer I/O error on device loop0, logical block 63177
[   56.532491] SQUASHFS error: squashfs_read_data failed to read block 0x21a8afcc
[   56.532501] SQUASHFS error: Unable to read fragment cache entry [21a8afcc]
[   56.532505] SQUASHFS error: Unable to read page, block 21a8afcc, size 6742
[   56.532515] SQUASHFS error: Unable to read fragment cache entry [21a8afcc]
[   56.532519] SQUASHFS error: Unable to read page, block 21a8afcc, size 6742
[   56.532525] SQUASHFS error: Unable to read fragment cache entry [21a8afcc]
[   56.532529] SQUASHFS error: Unable to read page, block 21a8afcc, size 6742
[   56.532539] SQUASHFS error: Unable to read fragment cache entry [21a8afcc]
[   56.532543] SQUASHFS error: Unable to read page, block 21a8afcc, size 6742
[   56.532549] SQUASHFS error: Unable to read fragment cache entry [21a8afcc]
[   56.532553] SQUASHFS error: Unable to read page, block 21a8afcc, size 6742
[   56.814690] SQUASHFS error: squashfs_read_data failed to read block 0x25b75b75
[   56.814700] SQUASHFS error: Unable to read fragment cache entry [25b75b75]
[   56.814704] SQUASHFS error: Unable to read page, block 25b75b75, size a809
[   56.814713] SQUASHFS error: Unable to read fragment cache entry [25b75b75]
[   56.814716] SQUASHFS error: Unable to read page, block 25b75b75, size a809
[   56.814723] SQUASHFS error: Unable to read fragment cache entry [25b75b75]
[   56.814727] SQUASHFS error: Unable to read page, block 25b75b75, size a809
[   56.814733] SQUASHFS error: Unable to read fragment cache entry [25b75b75]
[   56.814737] SQUASHFS error: Unable to read page, block 25b75b75, size a809
[   56.814743] SQUASHFS error: Unable to read fragment cache entry [25b75b75]
[   56.814747] SQUASHFS error: Unable to read page, block 25b75b75, size a809
[   56.954914] SQUASHFS error: squashfs_read_data failed to read block 0x31599fe
[   56.954924] SQUASHFS error: Unable to read fragment cache entry [31599fe]
[   56.954929] SQUASHFS error: Unable to read page, block 31599fe, size 5110
[   56.954939] SQUASHFS error: Unable to read fragment cache entry [31599fe]
[   56.954942] SQUASHFS error: Unable to read page, block 31599fe, size 5110
[   57.002056] SQUASHFS error: Unable to read fragment cache entry [31599fe]
[   57.002065] SQUASHFS error: Unable to read page, block 31599fe, size 5110
[   57.009387] SQUASHFS error: Unable to read fragment cache entry [31599fe]
[   57.009396] SQUASHFS error: Unable to read page, block 31599fe, size 5110
[   57.025542] SQUASHFS error: Unable to read fragment cache entry [31599fe]
[   57.025550] SQUASHFS error: Unable to read page, block 31599fe, size 5110
[   57.028183] SQUASHFS error: Unable to read fragment cache entry [31599fe]
[   57.028190] SQUASHFS error: Unable to read page, block 31599fe, size 5110
[   57.523797] SQUASHFS error: squashfs_read_data failed to read block 0x31599fe
[   57.523807] SQUASHFS error: Unable to read fragment cache entry [31599fe]
[   57.523812] SQUASHFS error: Unable to read page, block 31599fe, size 5110 </code>
 
<b>This is grub.cfg</b> 
<code>### BEGIN /etc/grub.d/00_header ###
if [ -s /boot/grub/grubenv ]; then
  have_grubenv=true
  load_env
fi
set default="0"
if [ ${prev_saved_entry} ]; then
  saved_entry=${prev_saved_entry}
  save_env saved_entry
  prev_saved_entry=
  save_env prev_saved_entry
fi
insmod fat
set root=(hd0,1)
search --no-floppy --fs-uuid --set 3E9C-5D00
if loadfont /boot/grub/unicode.pf2 ; then
  set gfxmode=640x480
  insmod gfxterm
  insmod vbe
  if terminal_output gfxterm ; then true ; else
    # For backward compatibility with versions of terminal.mod that don't
    # understand terminal_output
    terminal gfxterm
  fi
fi
if [ ${recordfail} = 1 ]; then
  set timeout=-1
else
  set timeout=10
fi
### END /etc/grub.d/00_header ###
 
 
### BEGIN /etc/grub.d/05_debian_theme ###
insmod fat
set root=(hd0,1)
search --no-floppy --fs-uuid --set 3E9C-5D00
insmod tga
if background_image /boot/images/Windbuchencom.tga ; then
  set color_normal=black/black
  set color_highlight=magenta/black
else
  set menu_color_normal=white/black
  set menu_color_highlight=black/white
fi
### END /etc/grub.d/05_debian_theme ###
 
### BEGIN LiveUSB
 
menuentry "Ubuntu Live 9.04 32bit" {
loopback loop /boot/iso/ubuntu-9.10-desktop-i386.iso
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/boot/iso/ubuntu-9.10-desktop-i386.iso quiet splash noprompt--
initrd (loop)/casper/initrd.lz
}
 
menuentry "Grml small 2009.10" {
  loopback loop /boot/iso/grml-small_2009.10.iso
  linux (loop)/boot/grmlsmall/linux26 findiso=/boot/iso/grml-small_2009.10.iso apm=power-off lang=us vga=791 boot=live nomce noeject noprompt --
  initrd (loop)/boot/grmlsmall/initrd.gz
}
 
menuentry "Karmic Netbook Remix" {
 loopback loop /boot/iso/karmic-netbook-remix-i386.iso
 linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/boot/iso/karmic-netbook-remix-i386.iso noeject noprompt --
 initrd (loop)/casper/initrd.lz
}
 
menuentry "Slax" {
    set isofile="/boot/iso/slax-6.1.2.iso"
 
    loopback loop $isofile 
    linux (loop)/boot/vmlinuz from=$isofile ramdisk_size=6666 root=/dev/ram0 rw
    initrd (loop)/boot/initrd.gz
}
 
menuentry "Netinstall 32 preseed" {
  loopback loop /boot/iso/mini.iso
  linux (loop)/linux auto url=http://www.panticz.de/pxe/preseed/preseed.seed locale=en_US console-setup/layoutcode=de netcfg/choose_interface=eth0 debconf/priority=critical --
  initrd (loop)/initrd.gz
}
 
menuentry "Puppy Linux" {
 loopback loop /boot/iso/puppy-4.2retro-k2.6.21.7-seamonkey.iso
 linux (loop)/vmlinuz from=/boot/iso/puppy-4.2retro-k2.6.21.7-seamonkey.iso
 initrd (loop)/initrd.gz
}
 
menuentry "Fedora 12" {
 linux /boot/iso/Fedora12/EFI/boot/vmlinuz0 root=/boot/iso/Fedora12/EFI/boot rootfstype=auto ro liveimg quiet  rhgb
 initrd /boot/iso/Fedora12/EFI/boot/initrd0.img 
# loopback loop /boot/iso/Fedora-12-i686-Live.iso
# linux (loop)/EFI/boot/vmlinuz0 boot=EFI/boot iso-scan/filename=/boot/iso/Fedora-12-i686-Live.iso
# initrd (loop)/EFI/boot/initrd0.img
}
 
menuentry "Grub2 HDD" {
 set root=(hd1)
 chainloader +1
}
 
### END LiveUSB
 
menuentry "Restart" {
 reboot
}
 
menuentry "Shut Down" {
 halt
}
</code>

ok, I did all of that and

ok, I did all of that and when I boot the drive it just goes to a GRUB> prompt. did I do something wrong? or is there a command that I need to run from that prompt?

Fixed some issues

I worked a little bit on it, and could solve some of the issues, wasn't fixed yet, see: http://blog.p-mt.net/archives/644

Regards, Peter