Skip to content

Instantly share code, notes, and snippets.

@kylefeng28
Last active December 21, 2015 04:39
Show Gist options
  • Save kylefeng28/6250768 to your computer and use it in GitHub Desktop.
Save kylefeng28/6250768 to your computer and use it in GitHub Desktop.
A simple script to put in /etc/grub.d/ which makes iso files show up in your grub. This allows you to boot from iso files and use those for reinstalling your computer instead of using an external disk. :) You may need to alter variables to match your platform and the partition containing the iso files needs to be mounted during installation from…
#!/bin/sh
#Written by Remco Haszing: https://plus.google.com/u/0/101152546828331333610/
#Original post: https://plus.google.com/101152546828331333610/posts/8iaeaqd7hhz
for iso in /opt/iso/*.iso; do
if [ "`isoinfo -f -i $iso | grep '/CASPER/VMLINUZ.EFI;1'`" == "" ]; then
vmlinuz=vmlinuz
else
vmlinuz=vmlinuz.efi
fi
iso=`basename $iso`
echo Found iso $iso >&2
cat <<EOF
menuentry "$iso" {
loopback loop (hd0,1)/$iso
linux (loop)/casper/$vmlinuz boot=casper iso-scan/filename=/$iso file=(loop)/preseed/ubuntu.seed
initrd (loop)/casper/initrd.lz
}
EOF
done
@kylefeng28
Copy link
Author

Yep, done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment