From dd948692c8116a822bbf061b055afcdbef07e9f4 Mon Sep 17 00:00:00 2001 From: Alexander Zhirov Date: Sun, 6 Oct 2024 06:10:22 +0300 Subject: [PATCH] init --- README.md | 26 ++++++ grub.cfg | 238 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 264 insertions(+) create mode 100644 README.md create mode 100644 grub.cfg diff --git a/README.md b/README.md new file mode 100644 index 0000000..e169a98 --- /dev/null +++ b/README.md @@ -0,0 +1,26 @@ +# GRUB for USB + +```sh +#!/bin/bash + +disk="${1}" + +parted ${disk} -s mklabel gpt +parted ${disk} -s -- mkpart primary 2048s 2099199s +parted ${disk} -s -- mkpart primary 2099200s 40G +parted ${disk} -s -- mkpart primary 40G 100% + +parted ${disk} -s set 1 boot on + +mkfs.fat -F32 ${disk}1 +mkfs.ext4 -F ${disk}2 + +mount -v -o umask=000 ${disk}1 /mnt + +grub-install --removable --boot-directory=/mnt/boot --efi-directory=/mnt --target=x86_64-efi ${disk} +grub-install --removable --boot-directory=/mnt/boot --efi-directory=/mnt --target=i386-efi ${disk} + +touch /mnt/boot/grub/grub.cfg + +umount -v ${disk}1 +``` diff --git a/grub.cfg b/grub.cfg new file mode 100644 index 0000000..d95688a --- /dev/null +++ b/grub.cfg @@ -0,0 +1,238 @@ +if [ -s $prefix/grubenv ]; then + set have_grubenv=true + load_env +fi + +if [ "${next_entry}" ] ; then + set default="${next_entry}" + set next_entry= + save_env next_entry + set boot_once=true +else + set default="0" +fi + +if [ x"${feature_menuentry_id}" = xy ]; then + menuentry_id_option="--id" +else + menuentry_id_option="" +fi + +export menuentry_id_option + +if [ "${prev_saved_entry}" ]; then + set saved_entry="${prev_saved_entry}" + save_env saved_entry + set prev_saved_entry= + save_env prev_saved_entry + set boot_once=true +fi + +function savedefault { + if [ -z "${boot_once}" ]; then + saved_entry="${chosen}" + save_env saved_entry + fi +} + +function recordfail { + set recordfail=1 + if [ -n "${have_grubenv}" ]; then + if [ -z "${boot_once}" ]; then + save_env recordfail + fi + fi +} + +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 [ x$feature_default_font_path = xy ] ; then + font=unicode +else + insmod part_msdos + insmod ext2 + set root='hd0,msdos1' + if [ x$feature_platform_search_hint = xy ]; then + search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 YOUR_UUID + else + search --no-floppy --fs-uuid --set=root YOUR_UUID + fi + font="/usr/share/grub/unicode.pf2" +fi + +if loadfont $font ; then + set gfxmode=auto + load_video + insmod gfxterm + set locale_dir=$prefix/locale + set lang=en_IN + insmod gettext +fi + +terminal_output gfxterm +insmod part_msdos +insmod ext2 + +insmod gfxmenu + +loadfont ($root)/boot/grub/themes/Stylish/dejavu_32.pf2 +loadfont ($root)/boot/grub/themes/Stylish/dejavu_sans_12.pf2 +loadfont ($root)/boot/grub/themes/Stylish/dejavu_sans_14.pf2 +loadfont ($root)/boot/grub/themes/Stylish/dejavu_sans_16.pf2 +loadfont ($root)/boot/grub/themes/Stylish/dejavu_sans_24.pf2 +loadfont ($root)/boot/grub/themes/Stylish/dejavu_sans_48.pf2 +loadfont ($root)/boot/grub/themes/Stylish/terminus-12.pf2 +loadfont ($root)/boot/grub/themes/Stylish/terminus-14.pf2 +loadfont ($root)/boot/grub/themes/Stylish/terminus-16.pf2 +loadfont ($root)/boot/grub/themes/Stylish/terminus-18.pf2 + +insmod jpeg +insmod png + +set theme=($root)/boot/grub/themes/Stylish/theme.txt +export theme + +if [ "${recordfail}" = 1 ] ; then + set timeout=30 +else + if [ x$feature_timeout_style = xy ] ; then + set timeout_style=menu + set timeout=10 + # Fallback normal timeout code in case the timeout_style feature is + # unavailable. + else + set timeout=10 + fi +fi + +#== BEGIN Menu Colors =========================# +set menu_color_normal=white/black +set menu_color_highlight=black/light-gray +#== END Menu Colors ===========================# + +if [ "${grub_platform}" = "efi" ]; then rmmod tpm; fi + +submenu "Linux" --class linux { + + regexp -s rootdevice '(.*),' $root + set root="(${rootdevice},2)" + + submenu "Solus" --class solus { + + menuentry "Solus 4.5 XFCE" --class solus { + set iso_path=/Solus-4.5-XFCE-Beta.iso + search --no-floppy --file ${iso_path} --set + + live_args="for-dracut --> iso-scan/filename=${iso_path}" + iso_args="initrd=/boot/initrd.img root=live:CDLABEL=SolusLiveXFCEBeta ro rd.luks=0 rd.md=0 rd.live.overlay.overlayfs=1 quiet splash --" + + loopback loop ${iso_path} + + linux (loop)/boot/kernel ${live_args} ${iso_args} + initrd (loop)/boot/initrd.img + } + } + + submenu "Arch Linux" --class arch { + + menuentry "Arch Linux 011024" --class arch { + set isofile="/archlinux-2024.10.01-x86_64.iso" + set dri="free" + search --no-floppy -f --set=root $isofile + probe -u $root --set=uuid + loopback loop $isofile + linux (loop)/arch/boot/x86_64/vmlinuz-linux img_dev=/dev/disk/by-uuid/$uuid img_loop=$isofile quiet splash + initrd (loop)/arch/boot/x86_64/initramfs-linux.img + } + } + + submenu "Debian" --class debian { + + menuentry "Debian 12.7 Install GTK" --class debian { + set isofile="/debian-12.7.iso" + loopback loop $isofile + linux (loop)/install.amd/vmlinuz vga=788 --- quiet splash + initrd (loop)/install.amd/gtk/initrd.gz + } + + menuentry "Debian 12.7 Install Terminal" --class debian { + set isofile="/debian-12.7.iso" + loopback loop $isofile + linux (loop)/install.amd/vmlinuz vga=788 --- quiet splash + initrd (loop)/install.amd/initrd.gz + } + } + + submenu "Astra" --class astra { + + menuentry "Astra 1.7 Install GTK" --class astra { + set isofile="/astra_1.7.iso" + loopback loop $isofile + linux (loop)/install.amd/gtk/vmlinuz modprobe.blacklist=evbug astra_install=1 debian-installer/locale=ru debian-installer/language=ru keyboard-configuration/xkb-keymap=ru console-keymaps-at quiet splash + initrd (loop)/install.amd/gtk/initrd.gz + } + + menuentry "Astra 1.7 Install Terminal" --class astra { + set isofile="/astra_1.7.iso" + loopback loop $isofile + linux (loop)/install.amd/vmlinuz modprobe.blacklist=evbug astra_install=1 debian-installer/locale=ru debian-installer/language=ru keyboard-configuration/xkb-keymap=ru console-keymaps-at quiet splash + initrd (loop)/install.amd/initrd.gz + } + + menuentry "Astra 1.8" --class astra { + set isofile="/astra_1.8.iso" + loopback loop $isofile + linux (loop)/vmlinuz boot=live findiso=$isofile toram=filesystem.squashfs quiet splash + initrd (loop)/initrd + } + } +} + +submenu "Windows" --class windows { + + regexp -s rootdevice '(.*),' $root + + menuentry "Windows 10" --class windows { + set root="(${rootdevice},5)" + insmod part_gpt + insmod ntfs + insmod chain + chainloader /efi/boot/bootx64.efi + } + + menuentry "Windows 10 Lite (8 в 1)" --class windows { + set root="(${rootdevice},3)" + insmod part_gpt + insmod ntfs + insmod chain + chainloader /EFI/boot/bootx64.efi + } + + menuentry "Windows 11" --class windows { + set root="(${rootdevice},4)" + insmod part_gpt + insmod ntfs + insmod chain + chainloader /efi/boot/bootx64.efi + } +} + +menuentry 'Перезагрузить компьютер' --class restart { + reboot +} + +menuentry 'Выключить компьютер' --class shutdown { + halt +}