Compare commits

..

5 Commits

Author SHA1 Message Date
BodgeMaster 4ad24cd144 procedure: update notes to self 2023-06-20 13:19:28 +02:00
BodgeMaster b4b73ef3f0 README: update documentation 2023-06-20 13:18:30 +02:00
BodgeMaster edb0c96796 grub-config: new script 2023-06-20 13:17:45 +02:00
BodgeMaster 35bdd361ab install stage 1: grub-install for BIOS, x86-32 EFI, and x86-64 EFI 2023-06-20 13:16:39 +02:00
BodgeMaster 269dfc498c install stage 1: minor fixes 2023-06-20 13:16:00 +02:00
4 changed files with 189 additions and 22 deletions

View File

@ -1,30 +1,61 @@
# Void Linux Minecraft Setup for USB Sticks # Void Linux Setup for USB Sticks
This repository holds a bunch of scripts for installing and customizing This repository holds scripts for installing a Void Linux setup specialized to run off a USB stick.
Void Linux to run off a USB stick.
There are a couple manual steps to get started before this script can take over: This is only for USB sticks (thumb drives, pen drives, whatever you wanna call them).
You dont need this if you want to use a USB HDD or SSD because these devices tend to just work normally.
If you want to use a USB HDD/SSD, just download the installer for the Linux distro of your choice and
install it on that drive. Most modern distros know how to cope with external drives.
The reason this is useful for USB sticks is that most of them are a bit shit.
Trying to run an operating system off a USB drive typically results in a corrupted drive pretty quickly
(if you can get the system to install properly in the first place).
## Installation
You need the following:
- Computer (duh)
- 8G of RAM or more
- Can boot off USB (most computers made after 2003)
- USB stick (at least 8G)
- Internet connection
There are a couple manual steps to get started before the installer scripts can take over:
- Set up a Void live medium - Set up a Void live medium
- Download here: https://voidlinux.org/download/ - Download here: https://voidlinux.org/download/
- The following instructions assume you downloaded the "base" image - The following instructions assume you downloaded the "base" image
- Burn to a CD/DVD or flash it to a USB stick - Burn to CD/DVD or flash it to USB stick
- Windows should have a built-in thing for burning ISOs. - Windows should have a built-in thing for burning ISOs.
- You can use something like Win32DiskImager or Rufus for USB sticks. - You can use something like Win32DiskImager or Rufus for USB sticks.
- This will delete whats on the stick. - This will delete whats on the stick.
- Boot into Void live and prepare things - Boot into Void live and prepare things
- Two things I cant help you with (sorry): - Things I cant help you with (sorry):
- How to boot off CD/USB depends on your computer, so youll have to find out elsewhere. - How to boot off CD/USB depends on your computer, so youll have to find out elsewhere.
- Be aware that Void uses a US keymap until you change it. If your keyboard is different, you might need to look up an image of a US keyboard to find the right keys. - Be aware that Void uses a US keymap until you change it. If your keyboard is different, you might need to look up an image of a US keyboard to find the right keys.
- If you are booting off the USB stick you want to install to, use the (RAM) option. - If booting off the USB stick you want to install to, use (RAM) option
- Log in as `root`, password `voidlinux` - Log in as `root`, password `voidlinux`
- If you need to use WiFi, run `void-installer` - If you need to use WiFi, run `void-installer`
- set your keyboard layout (optional) - Set your keyboard layout (optional)
- connect to your network - Connect to your network
- abort the installation - Abort the installation (dont touch anything else)
- Download and run stage 1 of the USB installation script - Download and run stage 1 of the USB installation script
- The base image doesnt come with a way to download files so you need to install that first: `xbps-install -S wget` - The base image doesnt come with a way to download files so you need to install that first: `xbps-install -S wget`
- if it yells at you about updating xbps, do that, then try again - If it yells at you about updating xbps, do that, then try again
- `wget https://lostcave.ddnss.de/git/BodgeMaster/void-minecraft-usb/raw/branch/master/install-stage1.sh` - `wget https://lostcave.ddnss.de/git/BodgeMaster/void-minecraft-usb/raw/branch/master/install-stage1.sh`
- `bash install-stage1.sh` - `bash install-stage1.sh`
The script will take it from there, asking you for information as needed. The scripts will take it from there, asking you for information and downloading things as needed.
## How It Works
`//TODO:` Add detailed documentation
## Files
- `install-stage1.sh`: sets up the base system and prepares for installation stage 2
- `install-stage2.sh`: continues setting up things after booting into the freshly installed base system
- `opt/grub-config`: the custom grub config generator to be installed in /opt/void-usb
- `procedure.txt`: notes to self, will disappear once finished
- `bootup.sh`: script that sets up the overlay
- `bashrc`: just a custom bashrc
- `update-squashfs.sh`: runs at shutdown, allows user to back up the system

View File

@ -34,6 +34,10 @@ function yesno {
done done
} }
function run_in_target {
xchroot /mnt/target "$@"
}
clear clear
echo " echo "
This script will now download and install Void Linux on your USB stick. This script will now download and install Void Linux on your USB stick.
@ -169,7 +173,7 @@ XBPS_ARCH="$TARGET_TYPE" xbps-install --yes --sync --rootdir /mnt/target --repos
wifi-firmware traceroute grep gzip file sed gawk less coreutils findutils \ wifi-firmware traceroute grep gzip file sed gawk less coreutils findutils \
diffutils pciutils usbutils tzdata base-files ncurses mdocml procps-ng \ diffutils pciutils usbutils tzdata base-files ncurses mdocml procps-ng \
kbd xbps sudo ethtool kmod eudev runit-void removed-packages nano acpid \ kbd xbps sudo ethtool kmod eudev runit-void removed-packages nano acpid \
squashfs-tools grub grub-i386-efi grub-x86_64-efi squashfs-tools grub grub-i386-efi grub-x86_64-efi dracut
echo "repository=$TARGET_MIRROR" > /mnt/target/etc/xbps.d/00-repository-main.conf echo "repository=$TARGET_MIRROR" > /mnt/target/etc/xbps.d/00-repository-main.conf
@ -184,7 +188,7 @@ echo "# See fstab(5).
# TODO: add script path # TODO: add script path
UUID=$(blkid --output value --match-tag UUID $TARGET_PART_BOOT) /boot f2fs defaults,nodev,nosuid 0 2 UUID=$(blkid --output value --match-tag UUID $TARGET_PART_BOOT) /boot f2fs defaults,nodev,nosuid 0 2
UUID=$(blkid --output value --match-tag UUID $TARGET_PART_EFI) /boot/efi vfat defaults 0 2 UUID=$(blkid --output value --match-tag UUID $TARGET_PART_EFI) /boot/efi vfat defaults,fmask=0077,dmask=0077 0 2
/container/home /home none bind 0 0 /container/home /home none bind 0 0
" > /mnt/target/etc/fstab " > /mnt/target/etc/fstab
@ -262,6 +266,15 @@ done
echo "$TARGET_HOSTNAME" > /mnt/target/etc/hostname echo "$TARGET_HOSTNAME" > /mnt/target/etc/hostname
mkdir /mnt/target/boot/efi/LOADER
echo "GRUB has been deliberately installed to a non-standard location.
This avoids default kernel hooks breaking the custom config." > /mnt/target/boot/efi/LOADER/README.TXT
# no idea if any of these are even necessary/relevant but it cant hurt...
TARGET_PRELOAD_GRUB_MODULES="usb usbms uhci ehci ohci part_gpt f2fs"
run_in_target grub-install --target=i386-pc --boot-directory=/boot/efi/LOADER --disk-module=native --modules="$TARGET_PRELOAD_GRUB_MODULES" "/dev/$TARGET_DISK"
run_in_target grub-install --target=i386-efi --boot-directory=/boot/efi/LOADER --efi-directory=/boot/efi --removable --no-nvram --modules="$TARGET_PRELOAD_GRUB_MODULES" "/dev/$TARGET_DISK"
run_in_target grub-install --target=x86_64-efi --boot-directory=/boot/efi/LOADER --efi-directory=/boot/efi --removable --no-nvram --modules="$TARGET_PRELOAD_GRUB_MODULES" "/dev/$TARGET_DISK"

102
opt/grub-config Normal file
View File

@ -0,0 +1,102 @@
#!/usr/bin/env bash
OS_NAME="Void Linux USB"
GRUB_PREFIX="/boot/efi/LOADER/grub"
CFG_CUSTOM_BEFORE="custom_before.cfg"
CFG_CUSTOM_AFTER="custom_after.cfg"
LINUX_CMDLINE=""
DEFAULT_LINUX=/boot/vmlinu?
if [ ! -f "$DEFAULT_LINUX" ]; then
# in cases where its a .gz or .xz or whatever
DEFAULT_LINUX=$(find /boot -type l -name "vmlinu*" 2>/dev/null | sort | head -n1)
fi
DEFAULT_INITRAMFS=/boot/initramfs.img
if [ ! -f "$DEFAULT_INITRAMFS" ]; then
# hope to find anything named initramfs or initrd
DEFAULT_INITRAMFS=$(find /boot -type l -name "init*" 2>/dev/null | sort | head -n1)
fi
function make_menuentry {
# $1 is the kernel path
# We dont want duplicate entries for /boot/vmlinuz symlink
if [ -L $1 ]; then
return 0
fi
# exclude garbage globbing results
if [ ! -f $1 ]; then
return 0
fi
LINUX="$(basename "$1")"
LINUX_VERSION="$(sed 's/^kernel//;s/^vm//;s/^linuz//;s/^linux//;s/^-//' <<< "$LINUX")"
if grep -e ".gz$" -e ".xz$" -e ".bz$" -e ".bz2$" -e ".lzma$" -e ".lz$" -e ".img$" >/dev/null 2>&1 <<< "$LINUX"; then
LINUX_VERSION="$(sed 's/[^.]*$//;s/.$//' <<< "$LINUX_VERSION")"
fi
INITRAMFS="$(basename "$(find /boot -name "init*$LINUX_VERSION*" 2>/dev/null | sort | head -n1)")"
# user output
echo " -> Found $LINUX (version $LINUX_VERSION, initramfs $INITRAMFS)"
# grub.cfg
echo "
menuentry 'Linux $LINUX_VERSION' {
echo 'Loading $LINUX...'
linux /$LINUX $LINUX_CMDLINE
echo 'Loading initial ramdisk...'
initrd /$INITRAMFS
}" >> "$GRUB_PREFIX/grub.cfg"
}
# user output
echo "Generating grub config..."
# grub.cfg
echo "# This file is auto-generated by $0.
# Changes will be overwritten automatically.
# If you want to add custom entries or other changes, add them to
# $GRUB_PREFIX/$CFG_CUSTOM_BEFORE or
# $GRUB_PREFIX/$CFG_CUSTOM_AFTER
search --fs-uuid --set=root $(blkid --output value --match-tag UUID "$(grep " /boot " /proc/mounts | sed -e 's/ .*//')")
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
timeout=5
if [ -f \${config_directory}/$CFG_CUSTOM_BEFORE ]; then
source \${config_directory}/$CFG_CUSTOM_BEFORE
elif [ -z \"\${config_directory}\" -a -f \$prefix/$CFG_CUSTOM_BEFORE ]; then
source \$prefix/$CFG_CUSTOM_BEFORE
fi
menuentry '$OS_NAME' {
echo 'Loading Linux...'
linux $DEFAULT_LINUX
echo 'Loading initial ramdisk...'
initrd $DEFAULT_INITRAMFS
}
submenu 'Choose kernel version...' {" > "$GRUB_PREFIX/grub.cfg"
for FILE in /boot/{vm,}linu{x,z}* /boot/kernel*; do
make_menuentry "$FILE"
done
# grub.cfg
echo "
}
if [ -f \${config_directory}/$CFG_CUSTOM_AFTER ]; then
source \${config_directory}/$CFG_CUSTOM_AFTER
elif [ -z \"\${config_directory}\" -a -f \$prefix/$CFG_CUSTOM_AFTER ]; then
source \$prefix/$CFG_CUSTOM_AFTER
fi" >> "$GRUB_PREFIX/grub.cfg"
# user output
echo "done"

View File

@ -1,7 +1,17 @@
make it bootable with UEFI and BIOS? TODO:
compare sizes of glibc and musl installations compare sizes of glibc and musl installations
try running multiple MC versions on musl try running multiple MC versions on musl (incl ThatModPack)
need xdg menu maker? need xdg menu maker?
check if there are problems with GRUBs --disk-module=native on real USB drives on real hardware
test that the (RAM) boot option allows you to install to the stick the system booted off
adjust required USB stick and RAM size in README
musl downsides:
- no nvidia drivers
- may be janky in regards to running some Minecraft versions
musl upsides:
- ??
ideas: ideas:
use shell script for init, call real init via exec use shell script for init, call real init via exec
@ -12,11 +22,13 @@ system lives on squashfs
-> fstrim (if applicable) -> fstrim (if applicable)
swap on zram swap on zram
f2fs for home f2fs for home
tmpfs for package cache, /tmp, logs?
when backing up when backing up
- do not cross file system boundaries - do not cross file system boundaries
- exclude /tmp, package cache, logs - exclude /tmp, package cache, logs
- possibly only save the changes in separate squashfs images
- either until it takes up too much space or until a certain number of images exist
- consolidate when the user requests it or when exceeding the limit
Steps to install: Steps to install:
- (user does this:) boot Void installer - (user does this:) boot Void installer
@ -49,7 +61,7 @@ Steps to install:
-> select installation type (x86_32/x86_64/aarch64, glibc/musl) -> select installation type (x86_32/x86_64/aarch64, glibc/musl)
-> if musl, add that bit to repo url -> if musl, add that bit to repo url
-> install packages -> install packages
-> linux bash shadow f2fs-tools dosfstools dbus NetworkManager iana-etc iw wpa_supplicant util-linux which tar man-pages iproute2 iputils wifi-firmware traceroute grep gzip file sed gawk less coreutils findutils diffutils pciutils usbutils tzdata base-files ncurses mdocml procps-ng kbd xbps sudo ethtool kmod eudev runit-void removed-packages nano acpid squashfs-tools -> linux bash shadow f2fs-tools dosfstools dbus NetworkManager iana-etc iw wpa_supplicant util-linux which tar man-pages iproute2 iputils wifi-firmware traceroute grep gzip file sed gawk less coreutils findutils diffutils pciutils usbutils tzdata base-files ncurses mdocml procps-ng kbd xbps sudo ethtool kmod eudev runit-void removed-packages nano acpid squashfs-tools grub grub-i386-efi grub-x86_64-efi
-> configure XBPS mirror -> configure XBPS mirror
-> configure sudo -> configure sudo
-> drop a file with "%wheel ALL=(ALL:ALL) ALL" in /etc/sudoers.d/sudo_group -> drop a file with "%wheel ALL=(ALL:ALL) ALL" in /etc/sudoers.d/sudo_group
@ -68,10 +80,18 @@ Steps to install:
-> selection dialog? -> selection dialog?
-> symlink /etc/localtime -> symlink /etc/localtime
-> configure host name -> configure host name
-> configure and install bootloader -> install and configure bootloader
-> if x86 install for both UEFI and BIOS -> install GRUB for i386-pc, i386-efi, x86_64-efi
-> Is there a way we can make this work with 32-bit AND 64-bit EFI at the same time? -> --removable and --no-nvram for EFI
-> if ARM install only UEFI -> --boot-directory set to /boot/loader to prevent grub-mkconfig kernel hook from running
-> state as much in a text file in there
-> add kernel hooks
-> script to run /opt/void-usb/grub-config
-> a script that updates vmlinu{z,x} and initramfs.img symlinks
-> add symlinks for newly installed kernel
-> guess best choice when removing the currently symlinked kernel
-> ask whether to run vkpurge if disk space is low
-> download grub-config and its resources and drop them in /opt/void-usb
-> xbps-reconfigure -fa -> xbps-reconfigure -fa
-> prepare 2nd stage installation -> prepare 2nd stage installation
-> auto login root -> auto login root
@ -94,6 +114,7 @@ Steps to install:
-> pipewire (pulsemixer?) -> pipewire (pulsemixer?)
-> ask about nvidia driver -> ask about nvidia driver
-> install if needed -> install if needed
-> find out when and where to set `nvidia-drm.modeset=1`
-> ask whether to use CTWM or IceWM -> ask whether to use CTWM or IceWM
-> short description of up and downsides -> short description of up and downsides
-> if CTWM, also install -> if CTWM, also install