diff --git a/README.md b/README.md index b26df29..3181526 100644 --- a/README.md +++ b/README.md @@ -66,10 +66,11 @@ x86) before running on bare metal. ## Building and Running ### Prerequisites -You will need QEMU for aarch64 emulation and dosfstools to create the virtual file system. +You will need QEMU for aarch64 emulation, dosfstools and mtools to create the +virtual file system. ```bash -sudo apt install qemu-system-aarch64 dosfstools +sudo apt install qemu-system-aarch64 dosfstools mtools ``` Additionally you will need a version of the [aarch64-none-elf](https://developer.arm.com/Tools%20and%20Software/GNU%20Toolchain) toolchain installed. @@ -104,14 +105,12 @@ into the `build` directory. Once that is done, you can create the image using the following command: ```bash -sudo ./scripts/create-image.sh +./scripts/create-image.sh ``` -This will create an image file named `moss.img` in the root directory of the project, -format it as VFAT 32 and create the necessary files and directories for the kernel. - -This script needs to run with sudo to mount the image through a loop device, -which is required to properly create the image for the kernel to work. +This will create an image file named `moss.img` in the root directory of the +project, format it as VFAT 32 and create the necessary files and directories for +the kernel. ### Running via QEMU diff --git a/scripts/create-image.sh b/scripts/create-image.sh index 6748217..1c04d70 100755 --- a/scripts/create-image.sh +++ b/scripts/create-image.sh @@ -5,23 +5,13 @@ base="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. && pwd )" pushd "$base" &>/dev/null || exit 1 img="$base/moss.img" -mount="$base/build/mount" - -mkdir -p "$mount" dd if=/dev/zero of="$img" bs=1M count=128 mkfs.vfat -F 32 "$img" -if ! mountpoint -q "$mount"; then - mount -o loop "$img" "$mount" -fi +mmd -i "$img" ::/bin +mmd -i "$img" ::/dev -mkdir -p "$mount/bin" -mkdir -p "$mount/dev" +mcopy -i "$img" "$base/build/bin"/* "::/bin" -cp "$base/build/bin"/* "$mount/bin" - -if mountpoint -q "$mount"; then - umount "$mount" -fi -popd &>/dev/null || exit 1 \ No newline at end of file +popd &>/dev/null || exit 1