-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_image.sh
More file actions
executable file
·37 lines (31 loc) · 1.08 KB
/
update_image.sh
File metadata and controls
executable file
·37 lines (31 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
# Check if the kernel path argument is provided
if [ -z "$1" ]; then
echo "Usage: $0 <path_to_kernel_executable>"
echo "Example: $0 ./build/kernel"
exit 1
fi
# Check if the kernel file exists
if [ ! -f "$1" ]; then
echo "Error: Kernel file '$1' does not exist"
exit 1
fi
# Make sure build directory exists
mkdir -p build
# Copy the original floppy image to the build directory
cp floppy.img build/kernel_floppy.img
# Update the image using mtools with the correct file name format
# Use uppercase KERNEL as FAT filesystems are typically case-insensitive but often store in uppercase
echo "Updating floppy image with kernel using mtools..."
mcopy -i build/kernel_floppy.img -D o "$1" ::KERNEL
if [ $? -eq 0 ]; then
echo "Successfully updated kernel image using mtools!"
else
echo "Attempting alternative approach..."
# Try without the -D o flag
mcopy -i build/kernel_floppy.img "$1" ::KERNEL 2>/dev/null || {
echo "Error: Failed to update kernel in floppy image"
exit 1
}
echo "Successfully updated kernel image using mtools!"
fi