#!/bin/sh ######################################################################################## # multi-boot-iso.sh # Script to install and boot multiple iso on HD. # set -e # Clear the screen clear MINT_VERSION='20130926-1637' # Set the ip or name of the image server. echo "************** ATTENTION DATA WARNING ***********" echo "* This script erases data on target devices." echo "*************************************************" echo echo "Please enter the server ip address to pull images from: (defalut is 10.0.2.2)" read SERVERIP #SERVERIP=${SERVERIP:-mgrsync.mg} SERVERIP=${SERVERIP:-10.0.2.2} echo echo "Please enter a block device of something like: (default is /dev/sda)" read DEVICE DEVICE=${DEVICE:-/dev/sda} echo echo "WARNING - All data on ${DEVICE} will be lost forever! - WARNING" echo "Type YES (all caps) to continue:" read OK2CONTINUE if [ "${OK2CONTINUE}" = "YES" ] then echo "You requested to continue access!" else echo "You did not type YES so script stopping here!" exit 0 fi # Zero fill just a bit echo "Starting dd command for short zero fill..." dd if=/dev/zero of=${DEVICE} bs=1024 count=1024 # Make a single partition echo "Starting parted command to make lablel and partition..." #parted -s -a optimal ${DEVICE} mklabel gpt -- mkpart primary ext4 1 -1 #parted -s -a optimal ${DEVICE} mklabel msdos -- mkpart primary ext4 1 3000 #parted -s -a optimal ${DEVICE} -- mkpart primary ext4 3000 -1 parted -s -a optimal ${DEVICE} mklabel msdos -- mkpart primary ext4 1 -1 # Set the block device to boot. echo "Starting parted command to enable boot..." parted -s ${DEVICE} -- set 1 boot on # Make new filesystem on the new partitions. echo "Making filesystem..." mkfs.ext4 -L Firmware ${DEVICE}1 #mkfs.ext4 -L casper-rw ${DEVICE}2 # mount usb echo "Mounting file system to write iso to..." mount ${DEVICE}1 /mnt/ # install grub2 on usb pen echo "Installing grub on block device..." grub-install --no-floppy --root-directory=/mnt ${DEVICE} # create grub config echo "Creating grub boot grub.cfg file..." cat > /mnt/boot/grub/grub.cfg << EOF set timeout=1 menuentry "MG LinuxMint ${MINT_VERSION} 64bit" { loopback loop /boot/iso/MG-LinuxMint-${MINT_VERSION}.iso linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/boot/iso/MG-LinuxMint-${MINT_VERSION}.iso noeject splash noprompt initrd (loop)/casper/initrd.lz } menuentry "Memtest86+" { loopback loop /boot/iso/MG-LinuxMint-${MINT_VERSION}.iso linux16 (loop)/install/mt86plus } #menuentry "LinuxMint 15 Mate 64bit" { # loopback loop /boot/iso/linuxmint-15-mate-dvd-64bit.iso # linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/boot/iso/linuxmint-15-mate-dvd-64bit.iso noeject splash noprompt # initrd (loop)/casper/initrd.lz #} #menuentry "MG Gnome Desktop Debian 64bit" { # loopback loop /boot/iso/mg-gnome.iso # linux (loop)/live/vmlinuz boot=live config findiso=/boot/iso/mg-gnome.iso splash noeject noprompt -- # initrd (loop)/live/initrd.img #} # #menuentry "MG LXDE Desktop Debian 64bit" { # loopback loop /boot/iso/mg-lxde.iso # linux (loop)/live/vmlinuz boot=live config findiso=/boot/iso/mg-lxde.iso splash noeject noprompt -- # initrd (loop)/live/initrd.img #} # #menuentry "Ubuntu Live 13.04 64bit" { # loopback loop /boot/iso/ubuntu-13.04-desktop-amd64.iso # linux (loop)/casper/vmlinuz.efi boot=casper iso-scan/filename=/boot/iso/ubuntu-13.04-desktop-amd64.iso noeject noprompt -- # initrd (loop)/casper/initrd.lz #} #menuentry "LinuxMint 15 Cinnamon 64bit" { # loopback loop /boot/iso/linuxmint-15-cinnamon-dvd-64bit.iso # linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/boot/iso/linuxmint-15-cinnamon-dvd-64bit.iso noeject splash noprompt -- # initrd (loop)/casper/initrd.lz #} EOF # create iso directory echo "Creating iso dir..." mkdir /mnt/boot/iso # # download images # # #cat >> /etc/grub.d/custom.cfg << EOF #menuentry "Ubuntu Live 32bit" { # loopback loop /boot/ubuntu-live-desktop-i386.iso # linux (loop)/casper/vmlinuz.efi boot=casper iso-scan/filename=/boot/ubuntu-live-desktop-i386.iso noeject noprompt -- # initrd (loop)/casper/initrd.lz #} #EOF #?# sudo update-grub # Download images from server echo "Downloading iso file..." wget http://${SERVERIP}/iso/MG-LinuxMint-${MINT_VERSION}.iso -O /mnt/boot/iso/MG-LinuxMint-${MINT_VERSION}.iso #wget http://${SERVERIP}/iso/linuxmint-15-mate-dvd-64bit.iso -O /mnt/boot/iso/linuxmint-15-mate-dvd-64bit.iso #wget http://${SERVERIP}/iso/ubuntu-13.04-desktop-amd64.iso -O /mnt/boot/iso/ubuntu-13.04-desktop-amd64.iso #wget http://${SERVERIP}/iso/linuxmint-15-cinnamon-dvd-64bit.iso -O /mnt/boot/iso/linuxmint-15-cinnamon-dvd-64bit.iso #wget http://${SERVERIP}/iso/mg-gnome.iso -O /mnt/boot/iso/mg-gnome.iso #wget http://${SERVERIP}/iso/mg-lxde.iso -O /mnt/boot/iso/mg-lxde.iso # umount echo "Cleanup of sync and 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