]>
code.delx.au - monosys/blob - hacks/multiboot-setup
8abc2be26cc0023191a351dd33b2c6ed156cd6ae
5 PARTITION_LABEL
="multiboot"
6 MULTIBOOT_MNT
="${MULTIBOOT_MNT:-/mnt/multiboot}"
9 if [ ! -b "${1:-}" ]; then
10 echo "Usage: $0 format /dev/sdX"
17 PARTITION_DEVICE
="${DISK_DEVICE}1"
18 echo -ne 'label: dos\ntype=c, bootable\n' | sudo sfdisk
"$DISK_DEVICE"
19 sudo mkfs.vfat
-n "$PARTITION_LABEL" "$PARTITION_DEVICE"
23 DISK_DEVICE
="$(findmnt -n -o source "$MULTIBOOT_MNT" | sed 's/[0-9]*$//')"
24 if [ ! -b "$DISK_DEVICE" ]; then
25 echo "ERROR! Could not find disk to install bootloader. Try using mount."
36 function cmd_grubcfg
{
41 function install_grub_bios
{
44 --boot-directory="$MULTIBOOT_MNT" \
48 function install_grub_efi
{
49 for arch
in i386-efi x86_64-efi
; do
54 --efi-directory="$MULTIBOOT_MNT" \
55 --boot-directory="$MULTIBOOT_MNT" \
60 function install_grub_cfg
{
61 if [[ -w "${MULTIBOOT_MNT}/grub/" ]]; then
62 # We already have write access, no need to use sudo
63 print_grub_cfg
> "${MULTIBOOT_MNT}/grub/grub.cfg"
65 print_grub_cfg | sudo
tee "${MULTIBOOT_MNT}/grub/grub.cfg" > /dev
/null
72 PARTITION_DEVICE
="$(readlink -f "/dev
/disk
/by-label
/${PARTITION_LABEL}")"
73 sudo mkdir
-p "$MULTIBOOT_MNT"
74 while sudo umount
"$PARTITION_DEVICE" &> /dev
/null
; do true
; done
75 sudo mount
"$PARTITION_DEVICE" "$MULTIBOOT_MNT" -o "uid=$(whoami)"
81 sudo umount
"$MULTIBOOT_MNT"
82 sudo
rmdir "$MULTIBOOT_MNT"
85 function cmd_freedos
{
88 local SYSLINUX_VERSION
="6.03"
89 local SYSLINUX_URL
="https://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-${SYSLINUX_VERSION}.tar.gz"
90 local FREEDOS_URL
="http://www.freedos.org/download/download/FD12LITE.zip"
92 curl
-fL "$SYSLINUX_URL" | \
93 tar xz
--no-same-owner --strip-components=3 -C "$MULTIBOOT_MNT" \
94 "syslinux-${SYSLINUX_VERSION}/bios/memdisk/memdisk"
96 curl
-fL "$FREEDOS_URL" > "${MULTIBOOT_MNT}/FD12LITE.zip"
99 function cmd_memtest
{
100 curl
-fL "https://www.memtest.org/download/5.01/memtest86+-5.01.bin.gz" | \
101 zcat
- > "${MULTIBOOT_MNT}/memtest.bin"
104 function print_grub_cfg
{
110 search --set=root --label $PARTITION_LABEL
112 function setup_arch {
115 echo "Loading kernel..."
116 linux (loop)/arch/boot/x86_64/vmlinuz-* img_label=${PARTITION_LABEL} img_loop=\$1 archisobasedir=arch earlymodules=loop
117 echo "Loading initrd (and microcode if they exist)..."
118 initrd (loop)/arch/boot/*.img (loop)/arch/boot/x86_64/initramfs-*.img
121 for iso in /archlinux-*.iso; do
122 if [ -f "\$iso" ]; then
127 function setup_debian {
133 for d in /debian-*-hd-media; do
134 if [ -d "\$d" ]; then
139 if [ -f /memdisk -a -f /FD12LITE.zip ]; then
140 menuentry /FD12LITE.zip {
141 if [ \${grub_platform} = pc ]; then
143 initrd16 /FD12LITE.zip
145 echo "FreeDOS only works with BIOS boot."
151 if [ -f /memtest.bin ]; then
152 menuentry "/memtest" {
157 function setup_fedora {
160 probe -s iso_label -l (loop)
161 linux (loop)/isolinux/vmlinuz root=live:CDLABEL=\$iso_label rd.live.image quiet iso-scan/filename=\$1
162 initrd (loop)/isolinux/initrd.img
165 for iso in /Fedora-Workstation-Live-*.iso; do
166 if [ -f "\$iso" ]; then
171 function setup_ubuntu {
174 linux (loop)/casper/vmlinuz* boot=casper quiet iso-scan/filename=\$1
175 initrd (loop)/casper/initrd*
178 for iso in /ubuntu-*-desktop-*.iso; do
179 if [ -f "\$iso" ]; then
190 if [ "$(type -t -- "$CMD")" = "function" ]; then
193 echo "Usage: $0 [format|mount|grub|grubcfg|freedos|memtest|umount]"