Multiple ISO images bootdisk

From hugovil.com
Jump to navigationJump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Script for creating a multiple ISO images bootdisk on a USB key

#!/bin/bash
set -o errexit

# Look in /dev/disk/by-id to find your ID
DEVICE_ID_DIR=/dev/disk/by-id
DEVICE_ID_UDEV="usb-Lexar_USB_Flash_Drive_HQS775KYVAWMRMNRWQ18-0:0"

VOLUME=MultiBoot8G
MNTPOINT=/mnt/usbdrive

IMAGES_SRCDIR=${HOME}/Downloads
IMAGES="ubuntu-10.04-desktop-i386.iso ubuntu-10.04-netbook-i386.iso \
        ubuntustudio-10.04-alternate-i386.iso ubuntustudio-10.04-alternate-amd64.iso"

if [ ! -h ${DEVICE_ID_DIR}/${DEVICE_ID_UDEV} ]; then
    echo "Device <${DEVICE_ID_UDEV}> not found"
    exit 1
fi

# Disk ID
DISK_ID=/dev/$(ls -al ${DEVICE_ID_DIR}/${DEVICE_ID_UDEV} | sed 's!.*\(sd[a-z]\)!\1!g')

# Partition ID = first partition
PART_ID=${DISK_ID}1

if [ ! -d ${MNTPOINT} ]; then
    mkdir ${MNTPOINT}
fi

# create filesystem on usb drive
sudo mkfs.vfat -n ${VOLUME} ${PART_ID}

# mount usb
sudo mount -o uid=hugo,gid=hugo ${PART_ID} ${MNTPOINT}

# Create some directories
mkdir -p ${MNTPOINT}/boot/{grub,iso}

echo "(hd0) ${DISK_ID}" > ${MNTPOINT}/boot/grub/device.map

# install grub2 on usb key
sudo grub-install --no-floppy --root-directory=${MNTPOINT} '(hd0)'

# create grub config
cat <<EOF> ${MNTPOINT}/boot/grub/grub.cfg
# grub.cfg

default  0
timeout  10

set menu_color_normal=white/cyan
set menu_color_highlight=yellow/blue

menuentry "Ubuntu 10.04 Desktop (x86)" {
  loopback loop /boot/iso/ubuntu-10.04-desktop-i386.iso
  linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/boot/iso/ubuntu-10.04-desktop-i386.iso noeject noprompt --
  initrd (loop)/casper/initrd.lz
}

menuentry "Ubuntu 10.04 Netbook (x86)" {
  loopback loop /boot/iso/ubuntu-10.04-netbook-i386.iso
  linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/boot/iso/ubuntu-10.04-netbook-i386.iso noeject noprompt --
  initrd (loop)/casper/initrd.lz
}

menuentry "Ubuntu Studio 10.04 (Intel x86)" {
  loopback loop /boot/iso/ubuntustudio-10.04-alternate-i386.iso
  linux (loop)/install/vmlinuz boot=casper persistent iso-scan/filename=/boot/iso/ubuntustudio-10.04-alternate-i386.iso noeject splash --
  initrd (loop)/install/initrd.gz
}

menuentry "Ubuntu Studio 10.04 (AMD64)" {
  loopback loop /boot/iso/ubuntustudio-10.04-alternate-amd64.iso
  linux (loop)/install/vmlinuz boot=casper persistent iso-scan/filename=/boot/iso/ubuntustudio-10.04-alternate-amd64.iso noeject noprompt --
  initrd (loop)/install/initrd.gz
}
EOF

# Copy images to usb key iso directory
for i in ${IMAGES}; do
    cp ${IMAGES_SRCDIR}/${i} ${MNTPOINT}/boot/iso
done

# un-mount
sudo umount ${MNTPOINT}

Error "(initramfs) Unable to find a medium containing a live file system"

With the above script, I have the following error:

(initramfs) Unable to find a medium containing a live file system

But:

 1. The kernel is loading
 2. The initrd is executing fine.

At the prompt, after having the error message, I tried:

 mount /dev/sdb2 /cdrom
 exit

But it doesn't work

Disk created by USB creator

Partitions layout:

root@server:/media# fdisk /dev/sdd

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): p

Disk /dev/sdd: 4001 MB, 4001366016 bytes
124 heads, 62 sectors/track, 1016 cylinders
Units = cylinders of 7688 * 512 = 3936256 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000d9d3f

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1   *           1        1016     3905473    c  W95 FAT32 (LBA)

Content:

ls /media/39E2-66BB/
autorun.inf  casper  dists  install  ldlinux.sys  md5sum.txt  pics  pool  preseed  README.diskdefines  syslinux  wubi.exe

If I take the USB key created by usb-creator, and I only install grub2 it works with the following configuration file /media/39E2-66BB/boot/grub/grub.cfg:

# grub.cfg

set default=0
set timeout=10

set menu_color_normal=white/cyan
set menu_color_highlight=yellow/blue

# Preferred and fallback resolutions:
set gfxmode="1024x576;800x600;640x480"
insmod gfxterm
insmod vbe
terminal_output gfxterm

menuentry "Ubuntu 10.04 Desktop (x86)" {
    # Set the grub "root" variable by locating the specified uuid
    search --no-floppy --fs-uuid 39E2-66BB --set=root
    linux /casper/vmlinuz append noprompt cdrom-detect/try-usb=true file=/cdrom/preseed/ubuntu.seed boot=casper initrd=/casper/initrd.lz quiet splash --
    initrd /casper/initrd.lz
}

It would seem that the problem was that the Ubuntu live CD is searching only on VFAT filesystems, not even ext2!