Skip to content

Commit f6bab25

Browse files
committed
create-image: use mtools to populate image
Use the `mtools` set of utilities to populate the image without the need to run mount the image (requring sudo).
1 parent be1e48d commit f6bab25

File tree

2 files changed

+11
-22
lines changed

2 files changed

+11
-22
lines changed

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,11 @@ x86) before running on bare metal.
6666
## Building and Running
6767

6868
### Prerequisites
69-
You will need QEMU for aarch64 emulation and dosfstools to create the virtual file system.
69+
You will need QEMU for aarch64 emulation, dosfstools and mtools to create the
70+
virtual file system.
7071

7172
```bash
72-
sudo apt install qemu-system-aarch64 dosfstools
73+
sudo apt install qemu-system-aarch64 dosfstools mtools
7374
```
7475

7576
Additionally you will need a version of the [aarch64-none-elf](https://developer.arm.com/Tools%20and%20Software/GNU%20Toolchain) toolchain installed.
@@ -100,14 +101,12 @@ into the `build` directory.
100101

101102
Once that is done, you can create the image using the following command:
102103
```bash
103-
sudo ./scripts/create-image.sh
104+
./scripts/create-image.sh
104105
```
105106

106-
This will create an image file named `moss.img` in the root directory of the project,
107-
format it as VFAT 32 and create the necessary files and directories for the kernel.
108-
109-
This script needs to run with sudo to mount the image through a loop device,
110-
which is required to properly create the image for the kernel to work.
107+
This will create an image file named `moss.img` in the root directory of the
108+
project, format it as VFAT 32 and create the necessary files and directories for
109+
the kernel.
111110

112111
### Running via QEMU
113112

scripts/create-image.sh

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,13 @@ base="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. && pwd )"
55
pushd "$base" &>/dev/null || exit 1
66

77
img="$base/moss.img"
8-
mount="$base/build/mount"
9-
10-
mkdir -p "$mount"
118

129
dd if=/dev/zero of="$img" bs=1M count=128
1310
mkfs.vfat -F 32 "$img"
1411

15-
if ! mountpoint -q "$mount"; then
16-
mount -o loop "$img" "$mount"
17-
fi
18-
19-
mkdir -p "$mount/bin"
20-
mkdir -p "$mount/dev"
12+
mmd -i "$img" ::/bin
13+
mmd -i "$img" ::/dev
2114

22-
cp "$base/build/bin"/* "$mount/bin"
15+
mcopy -i "$img" "$base/build/bin"/* "::/bin"
2316

24-
if mountpoint -q "$mount"; then
25-
umount "$mount"
26-
fi
27-
popd &>/dev/null || exit 1
17+
popd &>/dev/null || exit 1

0 commit comments

Comments
 (0)