usbdrv Read from USB flash drive

This commit is contained in:
2026-04-06 10:38:44 +02:00
parent 0b25061afa
commit fe628466b4
6 changed files with 211 additions and 10 deletions

30
aux/limine_img_amd64.sh Executable file
View File

@@ -0,0 +1,30 @@
#!/bin/sh
make -C boot/limine
rm -rf img_root
mkdir -p img_root/boot/limine
mkdir -p img_root/EFI/BOOT
cp -v kernel/build/kernel.elf img_root/boot/
cp -v boot/limine/limine-bios.sys boot/limine/limine.conf img_root/boot/limine/
cp -v boot/limine/limine-bios-cd.bin boot/limine/limine-uefi-cd.bin img_root/boot/limine/
cp -v boot/limine/BOOTX64.EFI boot/limine/BOOTIA32.EFI img_root/EFI/BOOT/
cp -v mop3dist.tar.lz4 img_root/boot/
dd if=/dev/zero of=mop3.img bs=1M count=64
parted -s mop3.img mklabel msdos mkpart primary fat32 1MiB 100% set 1 boot on
LOOPDEV=$(sudo losetup -Pf --show mop3.img)
sudo mkfs.fat -F 32 ${LOOPDEV}p1
mkdir -p mnt
sudo mount ${LOOPDEV}p1 mnt
sudo cp -rv img_root/* mnt/
sudo umount mnt
sudo losetup -d $LOOPDEV
rmdir mnt
boot/limine/limine bios-install mop3.img

19
aux/write_img.sh Executable file
View File

@@ -0,0 +1,19 @@
#!/bin/sh
# Requires sudo
# USAGE: ./aux/write_img.sh /dev/sda
TARGET="$1"
if [ -z "$TARGET" ]; then
exit 1
fi
if [ ! -b "$TARGET" ]; then
echo "Not a block device"
exit 1
fi
set -x
dd if=./mop3.img of="$TARGET" bs=4M status=progress oflag=direct conv=notrunc,sync && sync