==== MultiBoot-USB-Stick_erstellen Script ==== Zum herunterladen - einfach Reiter anklicken und Datei speichern #!/bin/bash # Gerd Göhler 2016-07-08 gerdg-dd@gmx.de # CC BY-NC-SA 3.0 DE - https://creativecommons.org/licenses/by-nc-sa/3.0/de/# # https://creativecommons.org/licenses/by-nc-sa/3.0/de/legalcode # # - benutze ein Terminalprogramm und wechsele in das Verzeichnis # - führe das Script aus (es werden Administratorenrechte benötigt) # - gib folgendes auf der Komandozeite ein # # ./Multiboot-USB-Stick_erstellen /dev/sd.. ( Gerät/USB-Stick der benutzt werden soll ) # DEVICE=$1 # $1 = Gerät/USB-Stick der benutzt werden soll # (zu formatierendes Gerät/Device .z.B.: /dev/sdb ) LABEL=MULTIBOOT version=8.5.0 # Versionsnumer von Debian-Live download="wget -nv -T10 --no-http-keep-alive --show-progress -c" # -- toolbox -- sonstige Tools und System einfügen toolbox() { echo " Toolbox ausgewählt " tool=$(dialog --stdout --backtitle System-Auswahl --title Details --checklist "Welche Tools Syteme / Desktop-Umgebung möchten Sie installieren? Achten Sie bei der Auswahl auf die Speichergröße Ihres Datenträgers." 23 78 15 \ "amd64-netinst" "Debian GNU/Linux installer amd64 - 247 MB" off \ "i386-netinst" "Debian GNU/Linux installer i386 - 316 MB" off \ "grml64" "GRML Live Linux amd64 für Admins - 483 MB" off \ "grml32" "GRML Live Linux i586+ für Admins - 468 MB" off \ "SystemRescueCd" "SystemRescueCd-x86-4.7.3 - 461 MB" off \ "Kali-Linux-64" "Advanced Penetration Test Distribution - 2,8 GB" off \ "Kali-Linux-32" "Advanced Penetration Test Distribution - 2,8 GB" off \ "super-grub2-disk" "Toolbox - 13 MB" off \ "rescatux" "Toolbox - 603 MB" off \ "memtest86+" "Tool für Speichertest - 1,8 MB" on \ "hdt" "Hardware Test (HDT) - 1,3 MB" on \ ) clear for TOOL in ${tool}; do case "${TOOL}" in amd64-netinst) echo " ${TOOL} einfügen " tool_iso=/boot/iso/debian-${version}-amd64-netinst.iso cat <> /mnt/${LABEL}/boot/grub/grub.cfg menuentry "Debian GNU/Linux \$version netinstall amd64 " { echo " " echo " " echo " Bitte einen kleinen Moment Geduld " insmod ext2 insmod part_msdos set isofile=${tool_iso} loopback loop \$isofile linux (loop)/install.amd/vmlinuz boot=linux findiso=\$isofile \$bootoptions initrd (loop)/install.amd/initrd.gz } menuentry " Bootable ISO Image:Debian GNU/Linux \$version netinstall amd64 " { echo " " echo " " echo " Bitte Geduld - kann etwas länger dauern - dafür alle Optionen verfügbar " linux16 /boot/img/memdisk iso initrd16 ${tool_iso} } EOF memdisk ${download} http://cdimage.debian.org/debian-cd/${version}/amd64/iso-cd/${tool_iso##*/} -O /mnt/${LABEL}${tool_iso} fehler_test ;; i386-netinst) echo " ${TOOL} einfügen " tool_iso=/boot/iso/debian-${version}-i386-netinst.iso cat <> /mnt/${LABEL}/boot/grub/grub.cfg menuentry "Debian GNU/Linu \$version netinstall i386 " { echo " " echo " " echo " Bitte einen kleinen Moment Geduld " insmod ext2 insmod part_msdos set isofile=${tool_iso} loopback loop \$isofile linux (loop)/install.386/vmlinuz boot=linux findiso=\$isofile \$bootoptions initrd (loop)/install.386/initrd.gz } menuentry " Bootable ISO Image:Debian GNU/Linux \$version netinstall i386 " { echo " " echo " " echo " Bitte Geduld - kann etwas länger dauern - dafür alle Optionen verfügbar " linux16 /boot/img/memdisk iso initrd16 ${tool_iso} } EOF memdisk ${download} http://cdimage.debian.org/debian-cd/${version}/i386/iso-cd/${tool_iso##*/} -O /mnt/${LABEL}${tool_iso} fehler_test ;; grml64) echo " ${TOOL} einfügen " tool_iso=/boot/iso/grml64-full_2014.11.iso cat <> /mnt/${LABEL}/boot/grub/grub.cfg menuentry "grml64-full_2014.11 - amd64 " { echo " " echo " " echo " Bitte einen kleinen Moment Geduld " insmod ext2 insmod part_msdos set isofile=${tool_iso} loopback loop \$isofile linux (loop)/boot/grml64full/vmlinuz boot=live findiso=\$isofile lang=de live-media-path=/live/grml64-full/ bootid=grml64full201411 amp=power-off vga=971 nomce initrd (loop)/boot/grml64full/initrd.img } menuentry " Bootable ISO Image: Grml 64 full " { echo " " echo " " echo " Bitte Geduld - kann etwas länger dauern - dafür alle Optionen verfügbar " linux16 /boot/img/memdisk iso initrd16 ${tool_iso} } EOF memdisk ${download} http://download.grml.org/${tool_iso##*/} -O /mnt/${LABEL}${tool_iso} fehler_test ;; grml32) echo " ${TOOL} einfügen " tool_iso=/boot/iso/grml32-full_2014.11.iso cat <> /mnt/${LABEL}/boot/grub/grub.cfg menuentry "grml64-full_2014.11 - i586+ " { echo " " echo " " echo " Bitte einen kleinen Moment Geduld " insmod ext2 insmod part_msdos set isofile=${tool_iso} loopback loop \$isofile linux (loop)/boot/grml32full/vmlinuz boot=live findiso=\$isofile lang=de live-media-path=/live/grml32-full/ bootid=grml32full201411 amp=power-off vga=971 nomce initrd (loop)/boot/grml32full/initrd.img } menuentry " Bootable ISO Image: Grml 32 full " { echo " " echo " " echo " Bitte Geduld - kann etwas länger dauern - dafür alle Optionen verfügbar " linux16 /boot/img/memdisk iso initrd16 ${tool_iso} } EOF memdisk ${download} http://download.grml.org/${tool_iso##*/} -O /mnt/${LABEL}${tool_iso} fehler_test ;; SystemRescueCd) echo " ${TOOL} einfügen " tool_iso=/boot/iso/systemrescuecd-x86-4.7.3.iso cat <> /mnt/${LABEL}/boot/grub/grub.cfg menuentry "SystemRescueCd-x86-4.7.3 " { echo " " echo " " echo " Bitte einen kleinen Moment Geduld " insmod ext2 insmod part_msdos set isofile=${tool_iso} loopback loop \$isofile linux (loop)/isolinux/rescue32 boot=live findiso=\$isofile setkmap=de vga=791 initrd (loop)/isolinux/initram.igz } menuentry " Bootable ISO Image: SystemRescueCd-x86-4.7.3 " { echo " " echo " " echo " Bitte Geduld - kann etwas länger dauern - dafür alle Optionen verfügbar " linux16 /boot/img/memdisk iso initrd16 ${tool_iso} } EOF memdisk ${download} https://sourceforge.net/projects/systemrescuecd/files/sysresccd-x86/4.7.3/${tool_iso##*/} -O /mnt/${LABEL}${tool_iso} fehler_test ;; Kali-Linux-64) echo " ${TOOL} einfügen " tool_iso=/boot/iso/kali-linux-2016.1-amd64.iso cat <> /mnt/${LABEL}/boot/grub/grub.cfg menuentry "Kali-Linux-64 -2016.1 - Advanced Penetration Test Distribution " { echo " " echo " " echo " Bitte einen kleinen Moment Geduld " insmod ext2 insmod part_msdos set isofile=${tool_iso} loopback loop \$isofile linux (loop)/live/vmlinuz boot=live findiso=\$isofile username=root hostname=kali initrd (loop)/live/initrd.img } EOF ${download} http://cdimage.kali.org/kali-2016.1/${tool_iso##*/} -O /mnt/${LABEL}${tool_iso} fehler_test ;; Kali-Linux-32) echo " ${TOOL} einfügen " tool_iso=/boot/iso/kali-linux-2016.1-i386.iso cat <> /mnt/${LABEL}/boot/grub/grub.cfg menuentry "Kali-Linux-32 -2016.1 - Advanced Penetration Test Distribution " { echo " " echo " " echo " Bitte einen kleinen Moment Geduld " insmod ext2 insmod part_msdos set isofile=${tool_iso} loopback loop \$isofile linux (loop)/live/vmlinuz boot=live findiso=\$isofile username=root hostname=kali initrd (loop)/live/initrd.img } EOF ${download} http://cdimage.kali.org/kali-2016.1/${tool_iso##*/} -O /mnt/${LABEL}${tool_iso} fehler ;; super-grub2-disk) echo " ${TOOL} einfügen " tool_iso=/boot/iso/super_grub2_disk_hybrid_2.02s4.iso cat <> /mnt/${LABEL}/boot/grub/grub.cfg menuentry "Super Grub2 Disk " { echo " " echo " " echo " Bitte einen kleinen Moment Geduld " linux16 /boot/img/memdisk iso initrd16 ${tool_iso} } EOF memdisk ${download} https://sourceforge.net/projects/supergrub2/files/2.02s4/${tool_iso##*/} -O /mnt/${LABEL}${tool_iso} fehler_test ;; rescatux) echo " ${TOOL} einfügen " tool_iso=/boot/iso/rescatux-0.40b6.iso cat <> /mnt/${LABEL}/boot/grub/grub.cfg menuentry "Rescatux - amd64" { echo " " echo " " echo " Bitte einen kleinen Moment Geduld " insmod ext2 insmod part_msdos set isofile=${tool_iso} loopback loop \$isofile linux (loop)/live/vmlinuz1 boot=live findiso=\$isofile components locales=de_DE.UTF-8 selinux=1 security=selinux initrd (loop)/live/initrd1.img } menuentry " Bootable ISO Image: Rescatux " { echo " " echo " " echo " Bitte Geduld - kann etwas länger dauern - dafür alle Optionen verfügbar " linux16 /boot/img/memdisk iso initrd16 ${tool_iso} } EOF memdisk ${download} http://sourceforge.net/projects/rescatux/files/rescatux_0_40_b6/${tool_iso##*/} -O /mnt/${LABEL}${tool_iso} fehler_test ;; memtest86+) echo " ${TOOL} einfügen " tool_iso=/boot/iso/memtest86+-5.01.iso cat <> /mnt/${LABEL}/boot/grub/grub.cfg menuentry "Memory test (memtest86+) iso " { linux16 /boot/img/memdisk iso initrd16 /boot/iso/memtest86+-5.01.iso } EOF memdisk if [ ! -f /mnt/${LABEL}${tool_iso} ]; then ${download} http://www.memtest.org/download/5.01/${tool_iso##*/}.gz -O /mnt/${LABEL}${tool_iso}.gz fehler_test gzip -d /mnt/${LABEL}/boot/iso/memtest86+-5.01.iso.gz fehler_test fi ;; hdt) echo " ${TOOL} einfügen " tool_iso=/boot/iso/hdt-0.5.2.iso cat <> /mnt/${LABEL}/boot/grub/grub.cfg menuentry "Hardware Test (HDT) " { linux16 /boot/img/memdisk iso initrd16 ${tool_iso} } EOF memdisk ${download} http://www.hdt-project.org/raw-attachment/wiki/hdt-0.5.0/${tool_iso##*/} -O /mnt/${LABEL}${tool_iso} fehler_test ;; *) echo " ENDE Toolbox " ;; esac done } ## -- toolbox ende -- memdisk() { if [ ! -f /mnt/${LABEL}/boot/img/memdisk ]; then cp /usr/lib/syslinux/memdisk /mnt/${LABEL}/boot/img/memdisk ; fi } fehler_test() { if [ $? -gt 0 ]; then echo " Es ist ein Fehler aufgetreten " echo " Möchten sie weiter fortfahren geben sie >> y << ein und die Eingabetaste, Abbruch mit jeder anderen Taste ... : " read FEHLER if [ ! "$FEHLER" == 'y' ]; then echo "Skript wird abgebrochen " entfernen exit 1 fi fi } entfernen() { echo " Gerät ${DEVICE} wird wieder freigegeben " umount /${DEVICE}${p}1 rmdir /mnt/${LABEL} echo "Fertig - USB Stick enternen" } if echo "$DEVICE" | grep -q "/dev/nbd" then p=p else p="" fi # teste benötigte Programme / Pakete for paket in "sudo" "grub2" "parted" "dosfstools" "gzip" "syslinux-common" "wget" "dialog" # "Test-Paket" do if dpkg -l | grep -q ${paket} then echo 2>&1> /dev/null else echo "Das Paket >> $paket << ist nicht installiert" echo "Instalieren sie es mit" echo " sudo apt-get install $paket " exit 1 fi done clear echo " (1) Das Gerät ${DEVICE} soll neu genutzt werden. " echo " (2) Das Gerät ${DEVICE} ist schon ein MULTIBOOT und soll nicht neu formatiert werden " echo " Gib >> 1 << oder >> 2 << ein und die Eingabetaste, Abbruch mit jeder anderen Taste ... : " read WA case "${WA}" in 1) echo " Das Gerät ${DEVICE} soll neu formatiert werden. " echo " ALLE DATEN GEHEN VERLOREN ! " echo " Möchten sie weiter fortfahren geben sie >> JA << ein und die Eingabetaste, Abbruch mit jeder anderen Taste ... : " read format if [ "${format}" == 'JA' ] then echo "${DEVICE} wird formatieren" parted -s ${DEVICE} mklabel msdos parted -s ${DEVICE} mkpart primary fat32 0% 100% parted -s ${DEVICE} set 1 boot on parted -s ${DEVICE} align-check optimal 1 mkfs.vfat -F32 -n ${LABEL} ${DEVICE}${p}1 parted -s ${DEVICE} print else echo "Abbruch." exit 1 fi ;; 2) echo " Weiter ohne neu zu formatieren. " ;; *) echo "Abbruch." exit 1 ;; esac echo " Gerät ${DEVICE} wird eingebunden " if [ ! -d /mnt/${LABEL} ]; then mkdir /mnt/${LABEL}; fi mount ${DEVICE}${p}1 /mnt/${LABEL} fehler_test if [ ! -d /mnt/${LABEL}/boot/grub ]; then echo "grub-install wird ausführt - Bitte warten " grub-install --no-floppy --force --removable --root-directory=/mnt/${LABEL} ${DEVICE} else echo " Grub bereites installiert. " fi ## grub.cfg anlegen cat < /mnt/${LABEL}/boot/grub/grub.cfg ## grub.cfg - generiert - $(date) set timeout=15 set default=0 insmod part_msdos insmod ntfs insmod ext2 insmod iso9660 insmod font function load_video { if [ x$feature_all_video_module = xy ]; then insmod all_video else # insmod efi_gop # insmod efi_uga # insmod ieee1275_fb insmod vbe insmod vga insmod video_bochs insmod video_cirrus fi } if loadfont \${prefix}/fonts/unicode.pf2 then set gfxmode=auto load_video insmod gfxterm set locale_dir=$prefix/locale set lang=de_DE insmod gettext set gfxpayload=keep terminal_output gfxterm fi insmod png if background_image \${prefix}/.background_cache.png; then set color_normal=white/black set color_highlight=black/white else set menu_color_normal=cyan/blue set menu_color_highlight=white/blue fi set bootoptions="locales=de_DE.UTF-8 keyboard-layouts=de vga=971 components " set version=$version EOF auswahl=$(dialog --stdout --backtitle System-Auswahl --title Details --checklist "Welche Syteme / Desktop-Umgebung möchten Sie installieren? Achten Sie bei der Auswahl auf die Speichergröße Ihres Datenträgers." 23 78 15 \ "amd64-standard" "Die Standard Terminal-Umgebung - 471 MB" off \ "amd64-gnome-desktop" "Die GNOME Desktop Umgebung - 1,3 GB" off \ "amd64-cinnamon-desktop" "Die Cinnamon Desktop Umgebung - 1,1 GB" off \ "amd64-mate-desktop" "Die MATE Desktop Umgebung - 1,0 GB" on \ "amd64-kde-desktop" "Die KDE Desktop Umgebung - 1,2 GB" off \ "amd64-lxde-desktop" "Die LXDE Desktop Umgebung - 959 MB" off \ "amd64-xfce-desktop" "Die XFCE Desktop Umgebung - 953 MB" off \ \ "i386-standard" "Die Standard Terminal-Umgebung - 523 MB" off \ "i386-gnome-desktop" "Die GNOME Desktop Umgebung - 1,4 GB" off \ "i386-cinnamon-desktop" "Die Cinnamon Desktop Umgebung - 1,2 GB" off \ "i386-mate-desktop" "Die MATE Desktop Umgebung - 1,1 GB" off \ "i386-kde-desktop" "Die KDE Desktop Umgebung - 1,3 GB" off \ "i386-lxde-desktop" "Die LXDE Desktop Umgebung - 1,1 GB" off \ "i386-xfce-desktop" "Die XFCE Desktop Umgebung - 1,1 GB" off \ "tools" "Tools und weiter Systeme" on \ ) # echo "Sie haben Ausgewählt : $auswahl " clear for SYSTEM in $auswahl do if [ "${SYSTEM}" == 'tools' ] then echo " Tools ist ausgewählt" else echo "Gewähles System_iso anlegen: $SYSTEM" cat <> /mnt/${LABEL}/boot/grub/grub.cfg set ${SYSTEM//-/}_iso="/boot/iso/debian-live-\${version}-${SYSTEM}.iso" EOF fi done echo "Verzeichnise und Datein kopieren" if [ ! -d /mnt/${LABEL}/boot/iso ]; then mkdir /mnt/${LABEL}/boot/iso; echo "/mnt/${LABEL}/boot/iso angelegt "; fi if [ ! -d /mnt/${LABEL}/boot/img ]; then mkdir /mnt/${LABEL}/boot/img; echo "/mnt/${LABEL}/boot/img angelegt "; fi ${download} https://wiki.fsfw-dresden.de/lib/exe/fetch.php/playground/beispiele/media/bilder/fsfw-background_640x480.png -O /mnt/${LABEL}/boot/grub/.background_cache.png fehler_test for SYSTEM in ${auswahl} do if [ "${SYSTEM}" == 'tools' ] then # echo " Tools ist ausgewählt" toolbox echo " Toolbox ist fertig" else echo "Gewähle Systemdaten werden kopiert: ${SYSTEM}" system_iso="/boot/iso/debian-live-${version}-${SYSTEM}.iso" echo " gespeichert in /mnt/${LABEL}${system_iso}" if echo "${SYSTEM}" | grep -q "i386" ; then architectur=i386 z=1 elif echo "${SYSTEM}" | grep -q "amd64"; then architectur=amd64 z="" fi echo " Architectur : ${architectur}" echo "Gewähles System-Menü anlegen: $SYSTEM" cat <> /mnt/${LABEL}/boot/grub/grub.cfg menuentry "debian-live-\$version-$SYSTEM" { insmod ext2 insmod part_msdos set isofile=\$${SYSTEM//-/}_iso loopback loop \$isofile linux (loop)/live/vmlinuz${z} boot=live findiso=\$isofile \$bootoptions initrd (loop)/live/initrd${z}.img } EOF ${download} http://cdimage.debian.org/debian-cd/current-live/${architectur}/iso-hybrid/debian-live-${version}-${SYSTEM}.iso -O /mnt/${LABEL}${system_iso} fehler_test fi echo " Systemauswahl beendet " done echo "grub.cfg ergänzen " cat <> /mnt/${LABEL}/boot/grub/grub.cfg ## sonstige Menüeinträge menuentry "Booten von HDD - Rechner von Festplatte starten " { set root=(hd1) chainloader +1 } menuentry "lspci - Hardware Infos " { lspci read } menuentry "____________________________ Neustart _________________________________" { echo } menuentry "Restart - Rechner neu Starten " { reboot } menuentry "Shut Down - Rechner ausschalten " { halt } EOF sync entfernen --- //[[gerdg-dd@gmx.de|gerd]] 2016/06/29 08:50//