Difference between revisions of "Multiple ISO images bootdisk"

From Hugo Villeneuve
Jump to: navigation, search
(Error "(initramfs) Unable to find a medium containing a live file system")
Line 99: Line 99:
 
But:
 
But:
   
1. The kernel is loading
+
1. The kernel is loading
2. The initrd is executing fine.
+
2. The initrd is executing fine.

Revision as of 00:26, 18 August 2010

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.