Skip to content

Instantly share code, notes, and snippets.

@saschanaz
Last active April 21, 2021 21:17
Show Gist options
  • Save saschanaz/407a1428f2661137becba097db8749b4 to your computer and use it in GitHub Desktop.
Save saschanaz/407a1428f2661137becba097db8749b4 to your computer and use it in GitHub Desktop.
Android-x86 USB boot
set timeout=0
# $1 Kernel dir
# $2 Title
# $3... Kernel cmdline
function add_boot_entry {
menuentry "$2" "$@" --class android-x86 {
savedefault
set root=$android
if [ -e $2/kernel ]; then
true
else
search --no-floppy --set root -f $2/kernel
fi
set kd=$2
shift 3
linux $kd/kernel root=/dev/ram0 androidboot.selinux=permissive $src $@
initrd $kd/initrd.img
}
}
# $1 Title
# $2... Kernel cmdline
function add_entry {
set title="Android-x86 8.1-r1 $1"
shift 1
add_boot_entry "$kdir" "$title" "$@"
}
# $1 EFI to chainload
# $2 OS name
# $3 Class
function add_os_if_exists {
# Is there a better way to find ESP?
for d in hd0,gpt1 hd0,gpt2 hd1,gpt1 hd1,gpt2 hd0,msdos1 hd0,msdos2 hd1,msdos1 hd1,msdos2; do
if [ "($d)$1" != "$cmdpath/$bootefi" -a -e ($d)$1 ]; then
menuentry "$2 at $d ->" "$d" "$1" --class "$3" {
savedefault
set root=$2
chainloader ($root)$3
}
break
fi
done
}
function savedefault {
if [ -s $prefix/grubenv -a "$chosen" != "$default" ]; then
set default="$chosen"
save_env default
fi
}
function load_theme {
loadfont DejaVuSansMono-18
set gfxmode=1024x768
terminal_output gfxterm
set theme=$prefix/theme/theme.txt
export theme
}
if [ "$root" == "loop0" ]; then
set prefix=($root)/boot/grub
fi
if [ -s $prefix/theme/theme.txt ]; then
load_theme
fi
if [ -s $prefix/grubenv ]; then
load_env
fi
if [ "$grub_cpu" = "i386" ]; then
set bootefi=bootia32.efi
set grub=grubia32
else
set bootefi=BOOTx64.EFI
set grub=grubx64
fi
if [ -z "$src" -a -n "$isofile" ]; then
set src=iso-scan/filename=$isofile
fi
search --no-floppy --set android -f $kdir/kernel
export android bootefi grub kdir live src
# Create main menu
add_entry "USB boot" quiet DATA=mmcblk0p4
set timeout=30
menuentry 'Android-x86 7.1-rc0 USB boot' --class android-x86 {
search --file --no-floppy --set=root /system.sfs
linux /kernel root=/dev/ram0 androidboot.selinux=permissive buildvariant=userdebug quiet DATA=mmcblk0p5
initrd /initrd.img
}
menuentry 'Android-x86 7.1-rc0 Live' --class android-x86 {
search --file --no-floppy --set=root /system.sfs
linux /kernel root=/dev/ram0 androidboot.selinux=permissive buildvariant=userdebug quiet DATA=
initrd /initrd.img
}
menuentry 'Android-x86 7.1-rc0 DEBUG mode' --class android-x86 {
search --file --no-floppy --set=root /system.sfs
linux /kernel root=/dev/ram0 androidboot.selinux=permissive buildvariant=userdebug DATA= DEBUG=2
initrd /initrd.img
}
menuentry 'Android-x86 7.1-rc0 Installation' --class android-x86 {
search --file --no-floppy --set=root /system.sfs
linux /kernel root=/dev/ram0 androidboot.selinux=permissive buildvariant=userdebug DEBUG= INSTALL=1
initrd /initrd.img
}
menuentry 'Windows' {
search --file --no-floppy --set=root /EFI/Microsoft/Boot/bootmgfw.efi
chainloader (${root})/EFI/Microsoft/Boot/bootmgfw.efi
}
set prefix=/efi/RemixOS
search --no-floppy -f /EFI/RemixOS/theme.cfg --set=efi --hint hd0,msdos1
set prefix=(${efi})/EFI/RemixOS
if [ -e ${prefix}/theme.cfg ]; then
source ${prefix}/theme.cfg
else
set timeout=30
fi
terminal_output gfxterm
set timeout=30
set root=(hd1,gpt3)
set prefix=/RemixOS/efi/RemixOS
if [ -s $prefix/themes/Aurora-Penguinis/theme.cfg ]; then
source $prefix/themes/Aurora-Penguinis/theme.cfg
elif [ -s /RemixOS/isolinux/remixos.png ]; then
background_image /RemixOS/isolinux/remixos.png
elif [ -s /RemixOS/isolinux/android-x86.png ]; then
background_image /RemixOS/isolinux/android-x86.png
fi
menuentry 'Resident mode - All your data and apps are saved ' --class remixos --class android-x86 --class gnu-linux --class os {
search --file --no-floppy --set=root /RemixOS/kernel
linux /RemixOS/kernel root=/dev/ram0 androidboot.selinux=permissive quiet SERIAL=random logo.showlogo=1 DATA= CREATE_DATA_IMG=1
initrd /RemixOS/initrd.img
}
menuentry 'Guest mode - No data will be saved after each session' --class remixos --class android-x86 --class gnu-linux --class os {
search --file --no-floppy --set=root /RemixOS/kernel
linux /RemixOS/kernel root=/dev/ram0 androidboot.selinux=permissive quiet SERIAL=random logo.showlogo=1 REMOUNT_RW=0 DATA= DATA_IN_MEM=1
initrd /RemixOS/initrd.img
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment