Revert: to more simple ISO generation w/o root privileges

This commit is contained in:
xamidev
2024-08-18 21:46:21 +02:00
parent ca001598fc
commit a2a7ab52a1
4 changed files with 14 additions and 85 deletions

3
.gitignore vendored
View File

@@ -1,6 +1,7 @@
*.o *.o
build/ build/
kernel.elf kernel.elf
blankos-fat.img blankos.iso
iso/
i386-elf-7.5.0-Linux-x86_64/ i386-elf-7.5.0-Linux-x86_64/
i386-elf-7.5.0-Linux-x86_64.tar.xz i386-elf-7.5.0-Linux-x86_64.tar.xz

View File

@@ -27,7 +27,7 @@ The long-term goal of this OS is to be capable of running user programs and havi
Download the latest BlankOS disk image from the "Releases" tab, and start it using the QEMU emulator: Download the latest BlankOS disk image from the "Releases" tab, and start it using the QEMU emulator:
``` ```
qemu-system-i386 blankOS-i386-0.3.45.img qemu-system-i386 blankOS-i386-0.3.55.iso
``` ```
## Building from source ## Building from source
@@ -47,7 +47,7 @@ To run the OS on real hardware, you'll first need to have a BIOS-compatible comp
Burn your image file onto a USB stick: Burn your image file onto a USB stick:
``` ```
sudo dd bs=4M if=blankos-fat.img of=/dev/sdX status=progress oflag=sync sudo dd bs=4M if=blankos.iso of=/dev/sdX status=progress oflag=sync
``` ```
Replace `sdX` with your USB drive name (you can find it by doing `sudo fdisk -l`). Replace `sdX` with your USB drive name (you can find it by doing `sudo fdisk -l`).
@@ -56,7 +56,7 @@ Tada! You now have a working BlankOS USB stick. Go ahead and try it out!
## Debugging (QEMU w/ GDB) ## Debugging (QEMU w/ GDB)
``` ```
qemu-system-i386 -s -S -drive file=blankos-fat.img,format=raw qemu-system-i386 -s -S -drive file=blankos.iso,format=raw
``` ```
In another shell: In another shell:

View File

@@ -38,14 +38,17 @@ toolchain:
wget $(TOOLCHAIN_SRC) wget $(TOOLCHAIN_SRC)
tar xf $(TOOLCHAIN_FILE) tar xf $(TOOLCHAIN_FILE)
blankos-fat.img: iso: kernel.elf
sudo ./setup.sh mkdir -p iso/boot/grub
cp kernel.elf iso/boot/kernel.elf
cp grub.cfg iso/boot/grub/grub.cfg
grub-mkrescue iso -o blankos.iso
run: blankos-fat.img run: iso
qemu-system-i386 -drive file=blankos-fat.img,format=raw qemu-system-i386 -drive file=blankos.iso,format=raw
debug: debug:
qemu-system-i386 -s -S -drive file=blankos-fat.img,format=raw qemu-system-i386 -s -S -drive file=blankos.iso,format=raw
clean: clean:
rm -rf $(OBJ_DIR) kernel.elf blankos-fat.img $(TOOLCHAIN_FILE) rm -rf $(OBJ_DIR) kernel.elf blankos.iso $(TOOLCHAIN_FILE)

View File

@@ -1,75 +0,0 @@
#!/bin/bash
# A script to create a FAT32 loopback device, place a kernel onto it, and install GRUB.
# Inspired by JakeSteinburger's SpecOS setup script!
if [ "$EUID" -ne 0 ]; then
echo "Please execute this script with root privileges."
exit
fi
if [ -f "blankos-fat.img" ]; then
echo "Deleting previous disk image..."
rm blankos-fat.img
fi
if [ -d "/mnt/blankos" ]; then
echo "Deleting previous mountpoint..."
rm -rf /mnt/blankos
fi
echo "Creating new mountpoint..."
mkdir /mnt/blankos
echo "Creating an empty disk image..."
dd if=/dev/zero of=blankos-fat.img bs=512 count=131072
echo "Appending a parition to disk image..."
fdisk blankos-fat.img << EOF
n
p
1
a
w
EOF
echo "Creating loopback devices..."
losetup -fP blankos-fat.img
# Get first partition loopback
LOOP_DEVICE=$(losetup -l | grep blankos-fat.img | awk '{print $1}')
PARTITION="${LOOP_DEVICE}p1"
echo "Creating FAT32 partition..."
mkfs.vfat -F 32 $PARTITION
echo "Mounting partition..."
mount $PARTITION /mnt/blankos
echo "Installing GRUB on $LOOP_DEVICE"
grub-install --root-directory=/mnt/blankos --target=i386-pc --no-floppy --modules="normal part_msdos fat multiboot" $LOOP_DEVICE
echo "Copying kernel file and GRUB configuration file..."
cp kernel.elf /mnt/blankos/boot/
cp grub.cfg /mnt/blankos/boot/grub/
echo "Appending test files..."
mkdir /mnt/blankos/hello
echo "Hello, world from FAT32 text file." > /mnt/blankos/hello/testfile.txt
# cp program.elf /mnt/blankos/programs/
# In the future, when the OS can load programs and parse ELF
echo "Unmounting partition..."
umount /mnt/blankos
echo "Freeing loopback devices..."
losetup -d $LOOP_DEVICE
echo "Fixing disk image permissions..."
sudo chmod 666 blankos-fat.img
echo "The blankos-fat.img disk image is ready for use with QEMU or real hardware."