BarinkOS/scripts/create_harddrive.sh
Nigel 50bf952a49 Basic idea's are created for the storage solution
- Added boot device info parsing to the kernel
- Added a pointer in the kernel to our pre-kernel BootInfo structure
- Created a layout for the FAT driver
- Created a layout for the virtual filesystem
- Separated IDE driver from the basic atapio driver.
	This will ensure we are not using one or the other
- The create_harddrive shell script will now actually build a harddrive image of
	the kernel
- The virtual filesystem initializes and creates a filesystem structure
	for every FAT16 partition in the master boot record
2023-02-21 21:43:14 +01:00

62 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
#
# How to build a boot image
# NOTE: This script cant run properly yet
# Things described here should be done manually for now
#
# COPYRIGHT © Nigel Barink 2023
#
echo "Building a FAT16 filesystem"
dd if=/dev/zero of=disk.img bs=512 count=131072
fdisk disk.img
# Use the following options in fdisk (Format Disk Tool)
# We want to create a MBR (NOT GPT) Partition table containing 1 logical disk
# with a primary FAT16 partition marked bootable
#OPTIONs
# Create new DOS disklabel
# o
# Create new partition
# n
# Choose Primary as partition type
# p
# hit enter to choose default for the other options
# Mark partition 1 as bootable
# a
# Change partition type to FAT16
# t
# Choose Partition 1
# 1
# Choose HEX 6 for FAT16
# 6
# Sync and write changes to disk
# w
# Create a "block" device from the disk.img
losetup /dev/loop9 disk.img
# Format the partition on the disk as FAT16
mkdosfs -F16 /dev/loop9
# Mount the disk to a folder on our dev machine
mount /dev/loop9 /mnt
# Install the grub bootloader onto the disk
grub-install --no-floppy --modules="normal multiboot" /dev/loop9 --target=i386-pc --boot-directory=/mnt/boot --force
# copy the necessary OS files
cp root/boot/myos.bin /mnt/boot/myos.bin
cp root/boot/grub/grub.cfg /mnt/boot/grub/grub.cfg
# Unmount the device
umount /mnt
# Destroy the loop device
losetup -d /dev/loop9