Difference between revisions of "Multiple ISO images bootdisk"
(New page: =Script for creating a multiple ISO images bootdisk on a USB key= <source lang="bash"> #!/bin/bash set -o errexit # Look in /dev/disk/by-id to find your ID DEVICE_ID_DIR=/dev/disk/by-id ...) |
|||
Line 12: | Line 12: | ||
MNTPOINT=/mnt/usbdrive |
MNTPOINT=/mnt/usbdrive |
||
− | IMAGES_SRCDIR=/ |
+ | IMAGES_SRCDIR=${HOME}/Downloads |
IMAGES="ubuntu-10.04-desktop-i386.iso ubuntu-10.04-netbook-i386.iso \ |
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" |
ubuntustudio-10.04-alternate-i386.iso ubuntustudio-10.04-alternate-amd64.iso" |
Revision as of 01:01, 13 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}