-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisk.sh
More file actions
executable file
·108 lines (86 loc) · 2.4 KB
/
disk.sh
File metadata and controls
executable file
·108 lines (86 loc) · 2.4 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/sh
set -e
. ./build.sh
cp -r base/* $SYSROOT
DISK_NAME=frog-os.img
DISK_SIZE=$[50 * 1024 * 1024]
MOUNT_DIR=/mnt
dd if=/dev/zero of=$DISK_NAME bs=512 count=$[$DISK_SIZE / 512]
sed -e 's/\s*\([-\+[:alnum:]]*\).*/\1/' << EOF | fdisk $DISK_NAME
g # gpt
n # new partition
1 # partition number 1
# default (from the beginning of the disk)
+1MiB # bios boot partiton size
n # new partition
3 # partition number 3
# default (right after bios boot partition)
+10Mib# partition size
n # new partition
2 # partition number 2
# default (right after bios boot partition)
# default (to the end of disk)
t # set type
1 # ... of partition 1
4 # bios . ./disk.shx filesystem
x # expert menu
n # partition name
3 # ... of partition 3
frog-mount
n # partition name
2 # ... of partition 2
frog-root
r # back to main menu
w # write changes
EOF
LOOP_DEV=$(sudo losetup -f --show $DISK_NAME)
sudo partprobe $LOOP_DEV
PARTITION1=${LOOP_DEV}p1
PARTITION2=${LOOP_DEV}p2
PARTITION3=${LOOP_DEV}p3
sudo mkfs.ext2 $PARTITION3
sudo mount $PARTITION3 $MOUNT_DIR
sudo echo 'hello from mnt' > ${MOUNT_DIR}/hello.txt
sudo umount $MOUNT_DIR
sudo mkfs.ext2 $PARTITION2
sudo mount $PARTITION2 $MOUNT_DIR
# Create the mount point directory if it doesn't exist
sudo mkdir -p ${MOUNT_DIR}/mnt/
sudo cp -r ${SYSROOT}/* ${MOUNT_DIR}/
sudo grub-install --no-floppy --target=i386-pc --modules="normal ext2 multiboot" --boot-directory=${MOUNT_DIR}/boot $LOOP_DEV
sudo cp assets/frog.jpg ${MOUNT_DIR}/boot/grub/background.jpg
echo -e '
set timeout=5
set default=0
set color_normal=light-gray/black
set color_highlight=light-green/green
if loadfont /boot/grub/fonts/unicode.pf2; then
set gfxmode=auto
insmod gfxterm
insmod vbe
terminal_output gfxterm
fi
insmod jpeg
background_image /boot/grub/background.jpg
menuentry "frog-os" {
set gfxpayload=keep
multiboot /boot/frog-os.kernel
}
menuentry "frog-os (no serial)" {
set gfxpayload=keep
multiboot /boot/frog-os.kernel noserial
}
menuentry "frog-os (no apic)" {
set gfxpayload=keep
multiboot /boot/frog-os.kernel noapic
}
menuentry "frog-os (no apic, no serial)" {
set gfxpayload=keep
multiboot /boot/frog-os.kernel noapic noserial
}
menuentry "Exit" {
halt
}
' | sudo cat > ${MOUNT_DIR}/boot/grub/grub.cfg
sudo umount $MOUNT_DIR
sudo losetup -d $LOOP_DEV